Boost logo

Boost-Commit :

From: stipe_at_[hidden]
Date: 2008-07-12 23:26:45


Author: srajko
Date: 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
New Revision: 47378
URL: http://svn.boost.org/trac/boost/changeset/47378

Log:
glv logic gui works
Added:
   sandbox/SOC/2007/signals/libs/dataflow/build/managed/
   sandbox/SOC/2007/signals/libs/dataflow/build/managed/Jamfile (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/src/managed/
   sandbox/SOC/2007/signals/libs/dataflow/src/managed/component.cpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/test_managed_port.cpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_fusion_component.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/signals/Jamfile.v2 | 7 +++++
   sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp | 21 +++++++++++++++
   sandbox/SOC/2007/signals/boost/dataflow/managed/network.hpp | 24 ++++++++++++++++++
   sandbox/SOC/2007/signals/boost/dataflow/managed/port.hpp | 1
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/Jamfile.v2 | 1
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp | 52 +++++++++++++++++++++++++++++++++++----
   sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_network.cpp | 7 +++--
   sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_port.cpp | 3 +
   8 files changed, 105 insertions(+), 11 deletions(-)

Modified: sandbox/SOC/2007/signals/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/Jamfile.v2 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -10,4 +10,11 @@
    
 project dataflow
    : build-dir bin.v2
+ : usage-requirements
+ <include>.
+ <include>$(BOOST_ROOT)
+ : requirements
+ <include>.
+ <include>$(BOOST_ROOT)
+
    ;
\ No newline at end of file

Modified: sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -9,6 +9,7 @@
 #include <boost/dataflow/support/fusion_component.hpp>
 #include <boost/dataflow/managed/port.hpp>
 #include <boost/dataflow/managed/component.hpp>
+#include <boost/dataflow/support/component_operation.hpp>
 #include <boost/mpl/map.hpp>
 
 namespace boost { namespace dataflow { namespace managed {
@@ -52,6 +53,24 @@
     port<InOutType, ports::producer> m_producer_port;
 };
 
-} } }
+}
+
+namespace extension {
+
+ template<typename T>
+ struct component_operation_impl<managed::component_traits<T>, operations::invoke >
+ {
+ typedef void result_type;
+
+ template<typename Component>
+ void operator()(Component &component)
+ {
+ component.invoke();
+ }
+ };
+
+}
+
+} }
 
 #endif // BOOST_DATAFLOW_MANAGED_FUSION_COMPONENT_HPP
\ No newline at end of file

Modified: sandbox/SOC/2007/signals/boost/dataflow/managed/network.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/managed/network.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/managed/network.hpp 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -9,8 +9,10 @@
 #include <vector>
 #include <set>
 
+#include <iostream>
 #include <boost/dataflow/managed/component.hpp>
 #include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/topological_sort.hpp>
 
 namespace boost { namespace dataflow { namespace managed {
 
@@ -37,9 +39,19 @@
 public:
     void register_component(component *c)
     {
+ std::cout << this << " registering " << c << std::endl;
         graph_type::vertex_descriptor v = add_vertex(m_graph);
         m_graph[v].ptr = c;
+ std::cout << m_descriptor_map.size() << std::endl;
         m_descriptor_map[c]=v;
+ std::cout << m_descriptor_map.size() << std::endl;
+ }
+ void notify_connect(component &producer, component &consumer)
+ {
+ std::cout << this << " connecting " << &producer << " and " << &consumer << std::endl;
+ std::cout << m_descriptor_map.size() << std::endl;
+ add_edge(m_descriptor_map[&producer], m_descriptor_map[&consumer], m_graph);
+ update_topological_sort();
     }
     void notify_change(component &changed)
     {
@@ -59,6 +71,18 @@
         for(topological_sort_type::const_iterator it=topological_sort.begin(); it!=topological_sort.end(); it++)
             m_changed.insert(*it);
     }
+ void update_topological_sort()
+ {
+ m_changed.clear();
+ std::vector<graph_type::vertex_descriptor> topological_sort;
+ boost::topological_sort(m_graph, std::back_inserter(topological_sort));
+ std::reverse(topological_sort.begin(), topological_sort.end());
+ for(std::vector<graph_type::vertex_descriptor>::iterator it=topological_sort.begin(); it!=topological_sort.end(); it++)
+ m_graph[*it].ptr->topological_sort_index(it - topological_sort.begin());
+ for(std::vector<graph_type::vertex_descriptor>::iterator it=topological_sort.begin(); it!=topological_sort.end(); it++)
+ m_changed.insert(m_graph[*it].ptr);
+
+ }
     void update()
     {
         while(!m_changed.empty())

Modified: sandbox/SOC/2007/signals/boost/dataflow/managed/port.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/managed/port.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/managed/port.hpp 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -38,6 +38,7 @@
         disconnect(consumer.connected_producer(), consumer);
     producer.m_consumers.insert(&consumer);
     consumer.m_producer = &producer;
+ producer.component_context().network_context().notify_connect(producer.component_context(), consumer.component_context());
 }
 
 template<typename T>

Added: sandbox/SOC/2007/signals/libs/dataflow/build/managed/Jamfile
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/build/managed/Jamfile 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,15 @@
+# Copyright 2007 Stjepan Rajko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+project dataflow/managed
+ : source-location ../../src/managed
+ ;
+
+SOURCES = component ;
+
+lib dataflow_managed : $(SOURCES).cpp
+ :
+ <include>../../../..
+ ;

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/Jamfile.v2 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -13,6 +13,7 @@
       <include>glv
       <library>glv
       <library>/boost/signals//boost_signals/<link>static
+ <library>../../build/managed//dataflow_managed/<link>static
       <define>BOOST_ALL_NO_LIB=1
       <toolset>darwin:<linkflags>"-framework AGL"
       <toolset>darwin:<linkflags>"-framework GLUT"

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -23,30 +23,69 @@
 using df::managed::fusion_component;
 
 // source just provides an output port
-class source : public fusion_component<bool>
+class source : public fusion_component<bool>, public glv::Button
 {
 public:
+ typedef glv::View runtime_base_class_type;
     source(df::managed::network &network)
         : fusion_component<bool>(network)
+ , glv::Button(glv::Rect(100,100),true)
     {
+ anchor(glv::Place::CL);
 // m_producer_port.set(value);
     }
+ void invoke()
+ {
+ if(m_consumer_port.connected())
+ {
+ value(m_consumer_port.get(), 0);
+ m_producer_port.set(m_consumer_port.get());
+ }
+ }
+ bool onEvent(glv::Event::t e, glv::GLV& glv)
+ {
+ bool response = glv::Button::onEvent(e, glv);
+ std::cout <<"preval: " << value(0) << std::endl;
+ m_producer_port.set(value(0));
+ return response;
+ }
 };
 
 // adder has two input ports and an output port.
 // invoking adds the two inputs into the output.
-class not_operation : public fusion_component<bool>
+class not_operation : public fusion_component<bool>, public glv::Button
 {
 public:
+ typedef glv::View runtime_base_class_type;
     not_operation(df::managed::network &network)
         : fusion_component<bool>(network)
- {}
+ , glv::Button(glv::Rect(100,100),true)
+ {
+ anchor(glv::Place::CL);
+ }
     void invoke()
     {
- m_producer_port.set(!m_consumer_port.get());
+ if(m_consumer_port.connected())
+ {
+ m_producer_port.set(!m_consumer_port.get());
+ value(m_producer_port.get(), 0);
+ }
     }
 };
 
+// adder has two input ports and an output port.
+// invoking adds the two inputs into the output.
+class update_network : public fusion_component<bool>
+{
+public:
+ update_network(df::managed::network &network)
+ : fusion_component<bool>(network)
+ {}
+ void invoke()
+ {
+ network_context().update();
+ }
+};
 
 
 // A component_bank with some components
@@ -55,8 +94,9 @@
 public:
     example_bank()
     {
- add_component<source>("src", m_network);
- add_component<not_operation>("not", m_network);
+ add_component<source>("src", boost::ref(m_network));
+ add_component<not_operation>("not", boost::ref(m_network));
+ add_component<update_network>("upd", boost::ref(m_network));
     }
 private:
     df::managed::network m_network;

Added: sandbox/SOC/2007/signals/libs/dataflow/src/managed/component.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/src/managed/component.cpp 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,17 @@
+// Copyright 2008 Stjepan Rajko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/dataflow/managed/component.hpp>
+#include <boost/dataflow/managed/network.hpp>
+
+namespace boost { namespace dataflow { namespace managed {
+
+component::component(network &network_context) : m_network_context(network_context), m_topological_sort_index(0)
+{
+ network_context.register_component(this);
+};
+
+}}}
+

Added: sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/test_managed_port.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/test_managed_port.cpp 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,30 @@
+// Copyright Stjepan Rajko 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/dataflow/blueprint/port_t.hpp>
+#include <boost/dataflow/managed/runtime_support.hpp>
+#include <boost/dataflow/managed/fusion_component.hpp>
+#include <boost/dataflow/managed/network.hpp>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+namespace df = boost::dataflow;
+namespace blueprint = df::blueprint;
+using namespace boost;
+
+int test_main(int, char* [])
+{
+ df::managed::network network;
+ df::managed::fusion_component<bool> component(network);
+
+ blueprint::port_t<df::managed::port<bool, df::ports::producer> &, df::managed::tag > source(component.producer_port());
+ blueprint::port_t<df::managed::port<bool, df::ports::consumer>, df::managed::tag > sink(component.consumer_port());
+
+ BOOST_CHECK((df::is_complemented_port<df::managed::port<bool, df::ports::producer>, df::managed::tag>::value));
+ BOOST_CHECK(source.is_complemented_port());
+ BOOST_CHECK(sink.is_complemented_port());
+ BOOST_CHECK(blueprint::are_binary_operable<df::operations::connect>(source, sink));
+ return 0;
+}

Added: sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_fusion_component.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_fusion_component.cpp 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,26 @@
+// Copyright Stjepan Rajko 2008. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#include <boost/dataflow/managed/fusion_component.hpp>
+#include <boost/dataflow/managed/network.hpp>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+int test_main(int, char* [])
+{
+ using namespace boost;
+ namespace df=boost::dataflow;
+ df::managed::network network;
+ df::managed::fusion_component<bool> c(network);
+
+ BOOST_CHECK_EQUAL((&df::get_port<boost::mpl::int_<0>, df::managed::tag >(c)), &c.consumer_port());
+ BOOST_CHECK_EQUAL((&df::get_port<boost::mpl::int_<1>, df::managed::tag >(c)), &c.producer_port());
+
+ return 0;
+} // int test_main(int, char* [])
+
+
+

Modified: sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_network.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_network.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_network.cpp 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -107,9 +107,10 @@
     using namespace boost::assign;
     
     // provide a hard coded topological sort for now
- std::vector<df::managed::component *> topological_sort;
- topological_sort += &sourceA, &sourceB, &sourceC, &sourceD, &AplusB, &CplusD, &ApBtimesCpD;
- network.topological_sort(topological_sort);
+// std::vector<df::managed::component *> topological_sort;
+// topological_sort += &sourceA, &sourceB, &sourceC, &sourceD, &AplusB, &CplusD, &ApBtimesCpD;
+// network.topological_sort(topological_sort);
+
     
     // update will invoke all components that need to be invoked
     network.update();

Modified: sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_port.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_port.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_port.cpp 2008-07-12 23:26:44 EDT (Sat, 12 Jul 2008)
@@ -26,10 +26,11 @@
     
     BOOST_CHECK_EQUAL(network.changed_components().size(), 0u);
     connect(output, input);
+ network.update();
     output.set(1);
 
     BOOST_CHECK_EQUAL(output.get(), 1);
- BOOST_CHECK_EQUAL(input.get(), 1);
+ BOOST_CHECK_EQUAL(input.get(), 1);
     
     BOOST_CHECK_EQUAL(network.changed_components().size(), 1u);
     BOOST_CHECK_EQUAL(*network.changed_components().begin(), &input_component);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk