Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r48678 - in sandbox/SOC/2007/signals: boost/dataflow/blueprint libs/dataflow/build/vc8ide libs/dataflow/example/extension libs/dataflow/example/signals
From: stipe_at_[hidden]
Date: 2008-09-08 19:36:06


Author: srajko
Date: 2008-09-08 19:36:05 EDT (Mon, 08 Sep 2008)
New Revision: 48678
URL: http://svn.boost.org/trac/boost/changeset/48678

Log:
extension example completed
Text files modified:
   sandbox/SOC/2007/signals/boost/dataflow/blueprint/binary_operation.hpp | 4 ++++
   sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp | 2 ++
   sandbox/SOC/2007/signals/libs/dataflow/build/vc8ide/example.vcproj | 20 ++++++++++++++++++++
   sandbox/SOC/2007/signals/libs/dataflow/example/extension/extension_example.cpp | 28 +++++++++++++++++++++++++++-
   sandbox/SOC/2007/signals/libs/dataflow/example/signals/modifier_example.cpp | 2 +-
   5 files changed, 54 insertions(+), 2 deletions(-)

Modified: sandbox/SOC/2007/signals/boost/dataflow/blueprint/binary_operation.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/blueprint/binary_operation.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/binary_operation.hpp 2008-09-08 19:36:05 EDT (Mon, 08 Sep 2008)
@@ -60,6 +60,10 @@
     get_binary_operation<operations::extract>(producer, consumer)->invoke(producer, consumer);
 }
 
+inline void connect(port & producer, port & consumer)
+{
+ get_binary_operation<operations::connect>(producer, consumer)->invoke(producer, consumer);
+}
 
 
 } } } // namespace boost::dataflow::blueprint

Modified: sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp 2008-09-08 19:36:05 EDT (Mon, 08 Sep 2008)
@@ -107,6 +107,8 @@
     component_t(const T0 &t0) : c(t0) {component_t_();}
     template<typename T0>
     component_t(T0 &t0) : c(t0) {component_t_();}
+ template<typename T0, typename T1>
+ component_t(const T0 &t0, const T1 &t1) : c(t0, t1) {component_t_();}
     component_t(const component_t &rhs) : c(rhs.c)
     { component_t_(); }
     

Modified: sandbox/SOC/2007/signals/libs/dataflow/build/vc8ide/example.vcproj
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/build/vc8ide/example.vcproj (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/build/vc8ide/example.vcproj 2008-09-08 19:36:05 EDT (Mon, 08 Sep 2008)
@@ -205,6 +205,26 @@
>
                         </File>
                 </Filter>
+ <Filter
+ Name="threadpool"
+ >
+ <File
+ RelativePath="..\..\example\threadpool\threadpool_component_example.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="extension"
+ >
+ <File
+ RelativePath="..\..\example\extension\component_add.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\example\extension\extension_example.cpp"
+ >
+ </File>
+ </Filter>
                 <File
                         RelativePath="..\..\example\edit_distance.cpp"
>

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/extension/extension_example.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/extension/extension_example.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/extension/extension_example.cpp 2008-09-08 19:36:05 EDT (Mon, 08 Sep 2008)
@@ -4,11 +4,16 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 
 #include <boost/dataflow/blueprint/component.hpp>
+#include <boost/dataflow/blueprint/binary_operation.hpp>
+#include <boost/dataflow/signals/component/storage.hpp>
+#include <boost/dataflow/signals/runtime_support.hpp>
 
 #include <boost/extension/factory_map.hpp>
 #include <boost/extension/shared_library.hpp>
 #include <boost/extension/convenience.hpp>
 
+#include <boost/fusion/include/make_vector.hpp>
+#include <boost/scoped_ptr.hpp>
 #include <iostream>
 #include <list>
 #include <map>
@@ -23,8 +28,29 @@
     std::cout << "load_single_library returned: "
         << load_single_library(fm, library_path, "extension_export_components") << std::endl;
 
- std::map<std::string, boost::extensions::factory<boost::dataflow::blueprint::component> > map = fm.get<blueprint::component, std::string>();
+ typedef std::map<std::string, boost::extensions::factory<boost::dataflow::blueprint::component> > map_type;
+ map_type map = fm.get<blueprint::component, std::string>();
     std::cout << "Loaded " << map.size() << " components" << std::endl;
 
+ if(map.find("add") != map.end())
+ {
+ // create the component
+ boost::scoped_ptr<blueprint::component> filter(map["add"].create());
+ std::cout << "Created component with " << filter->num_ports() << " ports.";
+
+ // storage components for the input and the result
+ blueprint::component_t<boost::signals::storage<void(int, int)>,boost::dataflow::signals::tag > one_two(boost::fusion::make_vector(1, 2));
+ blueprint::component_t<boost::signals::storage<void(int)>,boost::dataflow::signals::tag > result;
+
+ std::cout << "Connecting component with input storage (1,2) and result storage..." << std::endl;
+ blueprint::connect(one_two.get_port(0), filter->get_port(1));
+ blueprint::connect(filter->get_port(0), result.get_port(1));
+
+ // invoke the input to send and process its contents
+ one_two.invoke();
+ // print the result
+ std::cout << "Result storage: " << result.get().at<0>() << std::endl;
+ }
+
     return 0;
 }

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/signals/modifier_example.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/signals/modifier_example.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/signals/modifier_example.cpp 2008-09-08 19:36:05 EDT (Mon, 08 Sep 2008)
@@ -34,7 +34,7 @@
     template<typename T>
     T operator()(T t) const
     {
- return t * m_factor;
+ return static_cast<T>(t * m_factor);
     }
     
     double m_factor;


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