Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r48679 - sandbox/SOC/2007/signals/libs/dataflow/example/extension
From: stipe_at_[hidden]
Date: 2008-09-08 20:00:26


Author: srajko
Date: 2008-09-08 20:00:25 EDT (Mon, 08 Sep 2008)
New Revision: 48679
URL: http://svn.boost.org/trac/boost/changeset/48679

Log:
added more comments to extension example
Text files modified:
   sandbox/SOC/2007/signals/libs/dataflow/example/extension/component_add.cpp | 12 ++++++++++--
   sandbox/SOC/2007/signals/libs/dataflow/example/extension/extension_example.cpp | 15 ++++++++++-----
   2 files changed, 20 insertions(+), 7 deletions(-)

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/extension/component_add.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/extension/component_add.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/extension/component_add.cpp 2008-09-08 20:00:25 EDT (Mon, 08 Sep 2008)
@@ -16,9 +16,12 @@
 
 namespace component {
 
+// a regular Dataflow.Signals component
 class add : public boost::signals::filter<
     add,
+ // output signature
     void (int),
+ // input signature (must be listed to be accessible at runtime)
     void (int, int)>
 {
 public:
@@ -35,6 +38,11 @@
 {
     using namespace boost::extensions;
     namespace blueprint = boost::dataflow::blueprint;
- fm.get<blueprint::component, std::string>()["add"].set<blueprint::component_t<component::add, boost::dataflow::signals::tag> >();
- std::cout << "hello!" << std::endl;
+ using boost::dataflow::signals::tag;
+
+ // "add" is the string key for this component
+ // blueprint::component is a polymorphic base class for components
+ fm.get<blueprint::component, std::string>()["add"]
+ // component_t inherits blueprint::component
+ .set<blueprint::component_t<component::add, tag> >();
 }

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 20:00:25 EDT (Mon, 08 Sep 2008)
@@ -20,6 +20,7 @@
 
 int main()
 {
+ // Boost.Extension code to load the library
     namespace blueprint = boost::dataflow::blueprint;
     using namespace boost::extensions;
     std::string library_path = "libcomponent_add.extension";
@@ -32,24 +33,28 @@
     map_type map = fm.get<blueprint::component, std::string>();
     std::cout << "Loaded " << map.size() << " components" << std::endl;
 
+ // check for the "add" component
     if(map.find("add") != map.end())
     {
- // create the component
+ // create the component, output some information about it
         boost::scoped_ptr<blueprint::component> filter(map["add"].create());
- std::cout << "Created component with " << filter->num_ports() << " ports.";
+ std::cout << "Created component \"add\" with " << filter->num_ports() << " ports." << std::endl;
 
         // 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;
+ using boost::dataflow::signals::tag;
+ blueprint::component_t<boost::signals::storage<void(int, int)>, tag> one_two(boost::fusion::make_vector(1, 2));
+ blueprint::component_t<boost::signals::storage<void(int)>, tag> result;
 
         std::cout << "Connecting component with input storage (1,2) and result storage..." << std::endl;
+ // port 0 is the default output, port 1 the default input for
+ // Dataflow.Signals components based on signals::filter
         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;
+ std::cout << "Result storage contains: " << result.get().at<0>() << std::endl;
     }
 
     return 0;


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