|
Boost-Commit : |
From: stipe_at_[hidden]
Date: 2007-11-15 21:10:22
Author: srajko
Date: 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
New Revision: 41134
URL: http://svn.boost.org/trac/boost/changeset/41134
Log:
add blueprint layer
Added:
sandbox/SOC/2007/signals/boost/dataflow/blueprint/
sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection_t.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/blueprint/get_port.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/blueprint/network.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/blueprint/port.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/blueprint/port_t.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/signals/runtime_support.hpp (contents, props changed)
sandbox/SOC/2007/signals/libs/dataflow/doc/blueprint/
sandbox/SOC/2007/signals/libs/dataflow/doc/blueprint/blueprint.qbk (contents, props changed)
sandbox/SOC/2007/signals/libs/dataflow/doc/introduction/blueprint_example.qbk (contents, props changed)
sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/
sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/Jamfile.v2 (contents, props changed)
sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/blueprint_example.cpp (contents, props changed)
Text files modified:
sandbox/SOC/2007/signals/boost/dataflow/signals/component/storage.hpp | 47 +++++++++++++++++++++++++++++++++++---
sandbox/SOC/2007/signals/boost/dataflow/signals/support.hpp | 14 +++++++----
sandbox/SOC/2007/signals/boost/dataflow/support.hpp | 5 ---
sandbox/SOC/2007/signals/boost/dataflow/support/reflective_component.hpp | 17 ++++++++++++-
sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/signal_network.xcodeproj/project.pbxproj | 48 ++++++++++++++++++++++++++++++++++++++++
sandbox/SOC/2007/signals/libs/dataflow/doc/concepts.qbk | 37 +++++++++++++++++++++++++++++-
sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk | 5 ++++
sandbox/SOC/2007/signals/libs/dataflow/doc/future.qbk | 15 -----------
sandbox/SOC/2007/signals/libs/dataflow/doc/introduction.qbk | 13 ++++++++++
sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 | 1
10 files changed, 171 insertions(+), 31 deletions(-)
Added: sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,58 @@
+// 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)
+
+#ifndef BOOST_DATAFLOW_BLUEPRINT_COMPONENT_HPP
+#define BOOST_DATAFLOW_BLUEPRINT_COMPONENT_HPP
+
+#include <boost/dataflow/blueprint/get_port.hpp>
+#include <boost/dataflow/support/reflective_component.hpp>
+#include <boost/dataflow/support/component_operation.hpp>
+#include <boost/dataflow/support/binary_operation.hpp>
+
+#include <boost/mpl/size.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace boost { namespace dataflow { namespace blueprint {
+
+struct mechanism;
+
+class component
+{
+public:
+ virtual void invoke()=0;
+ virtual int num_ports() const=0;
+ virtual std::auto_ptr<port> get_port(int port_num)=0;
+ virtual ~component() {};
+};
+
+template<typename Mechanism, typename Component>
+class component_t : public component
+{
+public:
+ component_t() {}
+ template<typename T0>
+ component_t(const T0 &t0) : component(t0) {}
+
+ void invoke()
+ {
+ component_operation<operations::invoke, Mechanism>(component);
+ }
+ int num_ports() const
+ {
+ return mpl::size<typename component_traits_of<Mechanism, Component>::type::ports>::value;
+ }
+ std::auto_ptr<port> get_port(int port_num)
+ {
+ return blueprint::get_port<Mechanism, Component>(component, port_num);
+ }
+ Component &get() {return component;}
+private:
+ Component component;
+};
+
+} } } // namespace boost::dataflow::blueprint
+
+#endif // BOOST_DATAFLOW_BLUEPRINT_COMPONENT_HPP
+
Added: sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,23 @@
+// 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)
+
+#ifndef BOOST_DATAFLOW_BLUEPRINT_CONNECTION_HPP
+#define BOOST_DATAFLOW_BLUEPRINT_CONNECTION_HPP
+
+#include <boost/dataflow/blueprint/port.hpp>
+
+
+namespace boost { namespace dataflow { namespace blueprint {
+
+class connection
+{
+public:
+ virtual void connect(port &producer, port &consumer)=0;
+ virtual ~connection() {};
+};
+
+} } } // namespace boost::dataflow::blueprint
+
+#endif // BOOST_DATAFLOW_BLUEPRINT_CONNECTION_HPP
\ No newline at end of file
Added: sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection_t.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection_t.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -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)
+
+#ifndef BOOST_DATAFLOW_BLUEPRINT_CONNECTION_T_HPP
+#define BOOST_DATAFLOW_BLUEPRINT_CONNECTION_T_HPP
+
+#include <boost/dataflow/blueprint/connection.hpp>
+#include <boost/dataflow/support/binary_operation.hpp>
+
+#include <boost/type_traits/remove_reference.hpp>
+
+namespace boost { namespace dataflow { namespace blueprint {
+
+template <typename Mechanism, typename ProducerPort, typename ConsumerPort>
+class connection_t : public connection
+{
+public:
+ virtual void connect(port &producer, port &consumer)
+ {
+ dataflow::binary_operation<operations::connect, Mechanism>(
+ *(typename remove_reference<ProducerPort>::type *) producer.get(),
+ *(typename remove_reference<ConsumerPort>::type *) consumer.get());
+ }
+};
+
+} } } // namespace boost::dataflow::blueprint
+
+#endif // BOOST_DATAFLOW_BLUEPRINT_CONNECTION_HPP
\ No newline at end of file
Added: sandbox/SOC/2007/signals/boost/dataflow/blueprint/get_port.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/get_port.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,75 @@
+// 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)
+
+#ifndef BOOST_DATAFLOW_BLUEPRINT_GET_PORT_HPP
+#define BOOST_DATAFLOW_BLUEPRINT_GET_PORT_HPP
+
+#include <boost/dataflow/blueprint/port_t.hpp>
+#include <boost/dataflow/support/reflective_component.hpp>
+
+#include <memory>
+
+namespace boost { namespace dataflow { namespace blueprint {
+
+namespace detail {
+
+template<typename Mechanism, typename Component, int Ports>
+struct get_port_impl;
+
+template<typename Mechanism, typename Component>
+struct get_port_impl<Mechanism, Component, 2>
+{
+ std::auto_ptr<port> operator()(Component &c, int port_num)
+ {
+ std::auto_ptr<port> ret;
+ switch(port_num)
+ {
+ case 0:
+ ret.reset(new port_t<
+ typename mpl::at_c<
+ typename component_traits_of<Mechanism, Component>::type::ports,
+ 0
+ >::type,
+ typename get_component_port_result_type<
+ Mechanism,
+ mpl::int_<0>,
+ Component
+ >::type
+ >(get_component_port<Mechanism, mpl::int_<0>, Component >(c)));
+ break;
+ case 1:
+ ret.reset(new port_t<
+ typename mpl::at_c<
+ typename component_traits_of<Mechanism, Component>::type::ports,
+ 1
+ >::type,
+ typename get_component_port_result_type<
+ Mechanism,
+ mpl::int_<1>,
+ Component
+ >::type
+ >(get_component_port<Mechanism, mpl::int_<1>, Component>(c)));
+ }
+ return ret;
+ }
+};
+
+} // namespace detail
+
+template<typename Mechanism, typename Component>
+std::auto_ptr<port> get_port(Component &c, int port_num)
+{
+ return detail::get_port_impl<
+ Mechanism,
+ Component,
+ mpl::size<typename component_traits_of<Mechanism, Component>::type::ports>::value
+ >()(c, port_num);
+}
+
+} } } // namespace boost::dataflow::blueprint
+
+
+
+#endif // BOOST_DATAFLOW_BLUEPRINT_GET_PORT_HPP
\ No newline at end of file
Added: sandbox/SOC/2007/signals/boost/dataflow/blueprint/network.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/network.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,106 @@
+// 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)
+
+#ifndef BOOST_DATAFLOW_BLUEPRINT_NETWORK_HPP
+#define BOOST_DATAFLOW_BLUEPRINT_NETWORK_HPP
+
+#include <boost/dataflow/blueprint/component.hpp>
+#include <boost/dataflow/blueprint/connection_t.hpp>
+
+#include <boost/graph/adjacency_list.hpp>
+
+#include <exception>
+#include <iostream>
+
+namespace boost { namespace dataflow { namespace blueprint {
+
+template<typename Mechanism>
+class network
+{
+ struct node_t
+ {
+ boost::shared_ptr<component> ptr;
+ };
+ struct edge_t
+ {
+ boost::shared_ptr<connection> ptr;
+ int producer_port;
+ int consumer_port;
+ };
+public:
+ typedef boost::adjacency_list<
+ boost::vecS, boost::vecS, boost::bidirectionalS, node_t, edge_t> graph_type;
+
+ typedef typename graph_type::vertex_descriptor component_type;
+
+ template<typename Component>
+ component_type add_component()
+ {
+ typename graph_type::vertex_descriptor v = add_vertex(g);
+ g[v].ptr.reset(new component_t<Mechanism, Component>());
+ return v;
+ }
+ template<typename Component, typename T0>
+ component_type add_component(const T0 &t0)
+ {
+ typename graph_type::vertex_descriptor v = add_vertex(g);
+ g[v].ptr.reset(new component_t<Mechanism, Component>(t0));
+ return v;
+ }
+ template<typename ProducerPort, typename ConsumerPort>
+ void add_connection(component_type p, int p_port, component_type c, int c_port)
+ {
+ add_connection_(p, p_port, c, c_port, new connection_t<Mechanism, ProducerPort, ConsumerPort>());
+ }
+ void add_connection(component_type p, int p_port, component_type c, int c_port)
+ {
+ if (!are_connectable(p, p_port, c, c_port))
+ throw(std::exception());
+
+ add_connection_(p, p_port, c, c_port, get_port(p, p_port)->connector());
+ }
+ bool are_connectable(component_type p, int p_port, component_type c, int c_port)
+ {
+ return (
+ (typeid(*get_port(p, p_port)->connector().get())
+ == typeid(*get_port(c, c_port)->connector().get()))
+ && (get_port(p, p_port)->category_uuid() == 0)
+ && (get_port(c, c_port)->category_uuid() == 1));
+ }
+ void connect()
+ {
+ typename graph_type::edge_iterator it;
+ for (it = edges(g).first; it!=edges(g).second; it++)
+ g[*it].ptr->connect(
+ *g[source(*it, g)].ptr->get_port(g[*it].producer_port),
+ *g[target(*it, g)].ptr->get_port(g[*it].consumer_port));
+ }
+ component &operator[](component_type c)
+ {
+ return *g[c].ptr;
+ }
+ std::auto_ptr<port> get_port(component_type c, int port)
+ {
+ return g[c].ptr->get_port(port);
+ }
+ const graph_type &graph()
+ {
+ return g;
+ }
+private:
+ void add_connection_(component_type p, int p_port, component_type c, int c_port,
+ boost::shared_ptr<connection>)
+ {
+ typename graph_type::edge_descriptor e = add_edge(p, c, g).first;
+ g[e].ptr = g[p].ptr->get_port(p_port)->connector();
+ g[e].producer_port = p_port;
+ g[e].consumer_port = c_port;
+ }
+ graph_type g;
+};
+
+} } } // namespace boost::dataflow::blueprint
+
+#endif // BOOST_DATAFLOW_BLUEPRINT_NETWORK_HPP
\ No newline at end of file
Added: sandbox/SOC/2007/signals/boost/dataflow/blueprint/port.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/port.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,34 @@
+// 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)
+
+#ifndef BOOST_DATAFLOW_BLUEPRINT_PORT_HPP
+#define BOOST_DATAFLOW_BLUEPRINT_PORT_HPP
+
+#include <boost/shared_ptr.hpp>
+
+namespace boost { namespace dataflow { namespace blueprint {
+
+class connection;
+
+class port_traits
+{
+public:
+ virtual const char *category() const=0;
+ virtual int category_uuid() const=0;
+ virtual shared_ptr<connection> connector()=0;
+ virtual ~port_traits() {};
+};
+
+class port : public port_traits
+{
+public:
+ virtual void *get()=0;
+};
+
+} } } // namespace boost::dataflow::blueprint
+
+
+
+#endif // BOOST_DATAFLOW_BLUEPRINT_GET_PORT_HPP
\ No newline at end of file
Added: sandbox/SOC/2007/signals/boost/dataflow/blueprint/port_t.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/port_t.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,89 @@
+// 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)
+
+#ifndef BOOST_DATAFLOW_BLUEPRINT_PORT_T_HPP
+#define BOOST_DATAFLOW_BLUEPRINT_PORT_T_HPP
+
+#include <boost/dataflow/blueprint/port.hpp>
+#include <boost/dataflow/support/port.hpp>
+
+namespace boost { namespace dataflow { namespace blueprint {
+
+namespace runtime
+{
+ template<typename T, typename PropertyType>
+ struct property;
+
+ template < >
+ struct property<ports::producer, const char *>
+ {
+ const char *operator()()
+ {
+ return "producer";
+ }
+ };
+
+ template < >
+ struct property<ports::consumer, const char *>
+ {
+ const char *operator()()
+ {
+ return "consumer";
+ }
+ };
+
+ template < >
+ struct property<ports::producer, int>
+ {
+ int operator()()
+ {
+ return 0;
+ }
+ };
+
+ template < >
+ struct property<ports::consumer, int>
+ {
+ int operator()()
+ {
+ return 1;
+ }
+ };
+}
+
+
+template<typename PortTraits, typename Port>
+class port_t : public port
+{
+ typedef typename PortTraits::mechanism::template runtime_connection<PortTraits>::type connection_type;
+public:
+ port_t(Port p) : p(p), c(new connection_type()){}
+
+ const char * category() const
+ {
+ return runtime::property<typename PortTraits::category, const char *>()();
+ }
+ int category_uuid() const
+ {
+ return runtime::property<typename PortTraits::category, int>()();
+ }
+ void *get()
+ {
+ return &p;
+ }
+ virtual shared_ptr<connection> connector()
+ {
+ return c;
+ };
+private:
+ Port p;
+ boost::shared_ptr<connection> c;
+};
+
+} } } // namespace boost::dataflow::blueprint
+
+
+
+#endif // BOOST_DATAFLOW_BLUEPRINT_GET_PORT_HPP
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/boost/dataflow/signals/component/storage.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signals/component/storage.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signals/component/storage.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -26,8 +26,14 @@
>
class storage;
+template<typename T>
struct storage_component_traits
- : public dataflow::component_traits<dataflow::signals::mechanism>
+ : public dataflow::reflective_component_traits<
+ dataflow::signals::mechanism,
+ mpl::vector<
+ dataflow::signals::producer<T>, // outgoing signal
+ dataflow::signals::consumer<T> // incoming signal
+ > >
{};
namespace detail
@@ -96,7 +102,7 @@
typedef typename storage_modifier<Signature>::storable_types storable_types;
typedef typename storage_modifier<Signature>::storable_vector storable_vector;
- typedef storage_component_traits component_traits;
+ typedef storage_component_traits<Signature> component_traits;
/** Initializes the stored parameter values using the provided sequence.
\param[in] seq Sequence from which the stored parameter sequence is initialized from.
@@ -199,8 +205,8 @@
namespace extension {
- template<>
- struct component_operation_impl<operations::invoke, boost::signals::storage_component_traits>
+ template<typename T>
+ struct component_operation_impl<operations::invoke, boost::signals::storage_component_traits<T> >
{
template<typename Invocable>
void operator()(Invocable &invocable)
@@ -209,6 +215,39 @@
}
};
+ template<typename T>
+ struct get_component_port_impl<boost::signals::storage_component_traits<T> >
+ {
+ template<typename FArgs> struct result;
+
+ template<typename F, typename Component>
+ struct result<F(Component &, boost::mpl::int_<0>)>
+ {
+ typedef signal<T> & type;
+ };
+
+ template<typename F, typename Component>
+ struct result<F(Component &, boost::mpl::int_<1>)>
+ {
+ typedef function<T> type;
+ };
+
+ template<typename Component>
+ signal<T> &
+ operator()(Component &component, boost::mpl::int_<0>)
+ {
+ return component.get_proxied_producer();
+ }
+
+ template<typename Component>
+ function<T>
+ operator()(Component &component, boost::mpl::int_<1>)
+ {
+ return boost::signals::detail::bind_object<T, Component>()
+ (static_cast<typename boost::signals::detail::slot_type<T, Component>::type>(&Component::operator()), component);
+ }
+ };
+
}
} } // namespace boost::dataflow
Added: sandbox/SOC/2007/signals/boost/dataflow/signals/runtime_support.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/signals/runtime_support.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,31 @@
+// 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)
+
+#ifndef SIGNAL_NETWORK_SIGNAL_RUNTIME_SUPPORT_HPP
+#define SIGNAL_NETWORK_SIGNAL_RUNTIME_SUPPORT_HPP
+
+#include <boost/dataflow/blueprint/connection_t.hpp>
+
+namespace boost { namespace dataflow {
+
+namespace signals {
+
+template<typename PortTraits>
+struct mechanism::runtime_connection<
+ PortTraits,
+ typename enable_if<is_same<mechanism, typename PortTraits::mechanism> >::type >
+{
+ typedef blueprint::connection_t<
+ mechanism,
+ boost::signal<typename PortTraits::signature_type> &,
+ boost::function<typename PortTraits::signature_type>
+ > type;
+};
+
+}
+
+} }
+
+#endif // SIGNAL_NETWORK_SIGNAL_RUNTIME_SUPPORT_HPP
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/boost/dataflow/signals/support.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signals/support.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signals/support.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -15,7 +15,11 @@
namespace signals {
-struct mechanism;
+struct mechanism
+{
+ template<typename PortTraits, typename Enable=void>
+ struct runtime_connection;
+};
template<typename T>
struct producer
@@ -24,10 +28,6 @@
typedef T signature_type;
};
-struct call_consumer
- : public port_traits<mechanism, ports::consumer, concepts::keyed_port>
-{};
-
template<typename T>
struct consumer
: public port_traits<mechanism, ports::consumer, concepts::port>
@@ -35,6 +35,10 @@
typedef T signature_type;
};
+struct call_consumer
+ : public port_traits<mechanism, ports::consumer, concepts::keyed_port>
+{};
+
} // namespace signals
template<typename Signature, typename Combiner, typename Group, typename GroupCompare>
Modified: sandbox/SOC/2007/signals/boost/dataflow/support.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -11,10 +11,7 @@
#include <boost/dataflow/support/binary_operation.hpp>
#include <boost/dataflow/support/keyed_port.hpp>
#include <boost/dataflow/support/unary_operation.hpp>
-#include <boost/dataflow/support/component.hpp>
+#include <boost/dataflow/support/reflective_component.hpp>
#include <boost/dataflow/support/component_operation.hpp>
-
-//#include <boost/dataflow/support/filter.hpp>
-
#endif // BOOST_DATAFLOW_SUPPORT_HPP
Modified: sandbox/SOC/2007/signals/boost/dataflow/support/reflective_component.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/reflective_component.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/reflective_component.hpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -14,6 +14,13 @@
namespace boost { namespace dataflow {
+template<typename Mechanism, typename PortSequence>
+struct reflective_component_traits
+{
+ typedef Mechanism mechanism;
+ typedef PortSequence ports;
+};
+
namespace extension {
template<typename ComponentTraits, typename Enable=void>
@@ -38,10 +45,16 @@
} // namespace extension
template<typename Mechanism, typename T, typename Component>
-typename result_of<
+struct get_component_port_result_type
+{
+ typedef typename result_of<
extension::get_component_port_impl<
typename component_traits_of<Mechanism, Component>::type
- >(Component &, T)>::type
+ >(Component &, T)>::type type;
+};
+
+template<typename Mechanism, typename T, typename Component>
+typename get_component_port_result_type<Mechanism, T, Component>::type
get_component_port(Component &component)
{
return
Modified: sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/signal_network.xcodeproj/project.pbxproj
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/signal_network.xcodeproj/project.pbxproj (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/signal_network.xcodeproj/project.pbxproj 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -84,6 +84,7 @@
08061C2D0CBEE985002DC710 /* binary_operation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = binary_operation.hpp; sourceTree = "<group>"; };
08061C980CBEF0C6002DC710 /* keyed_port.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = keyed_port.hpp; sourceTree = "<group>"; };
08061CC40CBEF3F7002DC710 /* port_map.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = port_map.hpp; sourceTree = "<group>"; };
+ 08256FE60CEBDFEC003EC1B4 /* network.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = network.hpp; sourceTree = "<group>"; };
082761BE0C6037A90030E557 /* invocable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = invocable.hpp; sourceTree = "<group>"; };
083FD3B90C62A4CB00EF3F6B /* concepts.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = concepts.qbk; sourceTree = "<group>"; };
083FD3C10C62A75B00EF3F6B /* concepts.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = concepts.qbk; sourceTree = "<group>"; };
@@ -96,9 +97,15 @@
08668C4F0C19A16300ACB19A /* Jamfile.v2 */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Jamfile.v2; sourceTree = "<group>"; };
08B9D4190CC3D0790050F10B /* test_binary_op.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = test_binary_op.cpp; sourceTree = "<group>"; };
08B9D41E0CC3D0A80050F10B /* my_producer_consumer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = my_producer_consumer.hpp; sourceTree = "<group>"; };
+ 08BD9AFB0CEB9D330069AFE2 /* get_port.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = get_port.hpp; sourceTree = "<group>"; };
+ 08BD9B090CEB9E3D0069AFE2 /* port.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = port.hpp; sourceTree = "<group>"; };
08C3EEA20C625AE30074AB9E /* simple_example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simple_example.cpp; sourceTree = "<group>"; };
08C675970C13A03E00D85379 /* Jamfile.v2 */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Jamfile.v2; sourceTree = "<group>"; };
08DC14FC0C951C4800B96B2E /* Cone.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Cone.cxx; sourceTree = "<group>"; };
+ 08EF04520CEBF0EE002ABBBC /* connection.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = connection.hpp; sourceTree = "<group>"; };
+ 08EF04590CEBF153002ABBBC /* connection_t.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = connection_t.hpp; sourceTree = "<group>"; };
+ 08EF045E0CEBF1AD002ABBBC /* port_t.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = port_t.hpp; sourceTree = "<group>"; };
+ 08EF05850CEBFDB3002ABBBC /* runtime_support.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = runtime_support.hpp; sourceTree = "<group>"; };
08EF9B220C5D506A00D4D206 /* applicator.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = applicator.hpp; sourceTree = "<group>"; };
08EF9B230C5D506A00D4D206 /* chain.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = chain.hpp; sourceTree = "<group>"; };
08EF9B240C5D506A00D4D206 /* conditional.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = conditional.hpp; sourceTree = "<group>"; };
@@ -164,12 +171,15 @@
08F264780CEA9DE800DA01C9 /* distributed_example.qbk */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = distributed_example.qbk; sourceTree = "<group>"; };
08F264790CEA9DE800DA01C9 /* gil_example.qbk */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = gil_example.qbk; sourceTree = "<group>"; };
08F2647A0CEA9DE800DA01C9 /* vtk_example.qbk */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = vtk_example.qbk; sourceTree = "<group>"; };
+ 08F265450CEAC26F00DA01C9 /* component.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = component.hpp; sourceTree = "<group>"; };
08F26C8B0CBF1CBA00EDC3F6 /* test_port.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_port.cpp; sourceTree = "<group>"; };
08F26D630CBF2D4100EDC3F6 /* test_proxy_port.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_proxy_port.cpp; sourceTree = "<group>"; };
08F2C31B0CAD961F00F9100C /* vtk_dataflow_support.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = vtk_dataflow_support.hpp; sourceTree = "<group>"; };
08F2D3A90CCADDE00042A3FF /* underlying_type.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = underlying_type.hpp; sourceTree = "<group>"; };
08F348510C492B4B0096097F /* group.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = group.hpp; sourceTree = "<group>"; };
08F348970CC021E0006D0A67 /* copy_cv.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = copy_cv.hpp; sourceTree = "<group>"; };
+ 08F3592D0CED1EC400E2BBFB /* blueprint.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = blueprint.qbk; sourceTree = "<group>"; };
+ 08F3593B0CED23C100E2BBFB /* blueprint_example.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = blueprint_example.qbk; sourceTree = "<group>"; };
08F36DFB0C41375B00E2F9A1 /* dataflow_table.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = dataflow_table.xml; sourceTree = "<group>"; };
08F37EDF0C57A4A700AC7FB8 /* static_function_call.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = static_function_call.hpp; sourceTree = "<group>"; };
08F3944C0CCEC35E00ED7978 /* binary_operation.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = binary_operation.hpp; sourceTree = "<group>"; };
@@ -218,6 +228,8 @@
08FCEFCE0CB9CEB000BBB599 /* future.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = future.qbk; sourceTree = "<group>"; };
08FD5E4D0C1BA60800F00877 /* Jamfile.v2 */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Jamfile.v2; sourceTree = "<group>"; };
08FD5E4E0C1BA60800F00877 /* dataflow.qbk */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = dataflow.qbk; sourceTree = "<group>"; };
+ 08FFDD6F0CEB70AD009318A8 /* blueprint_example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = blueprint_example.cpp; sourceTree = "<group>"; };
+ 08FFDD740CEB71A2009318A8 /* Jamfile.v2 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Jamfile.v2; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXGroup section */
@@ -260,6 +272,7 @@
08668C4D0C19A16300ACB19A /* example */ = {
isa = PBXGroup;
children = (
+ 08FFDD6E0CEB709A009318A8 /* blueprint */,
08F98B3F0CD018E7009D642B /* signals */,
0800AC2F0C8CA99700994538 /* VTK */,
08668C4F0C19A16300ACB19A /* Jamfile.v2 */,
@@ -299,6 +312,7 @@
08EF9B440C5D506A00D4D206 /* connection.hpp */,
08EF9B450C5D506A00D4D206 /* detail */,
08EF9B480C5D506A00D4D206 /* trait */,
+ 08EF05850CEBFDB3002ABBBC /* runtime_support.hpp */,
);
path = signals;
sourceTree = "<group>";
@@ -457,10 +471,25 @@
08F264780CEA9DE800DA01C9 /* distributed_example.qbk */,
08F264790CEA9DE800DA01C9 /* gil_example.qbk */,
08F2647A0CEA9DE800DA01C9 /* vtk_example.qbk */,
+ 08F3593B0CED23C100E2BBFB /* blueprint_example.qbk */,
);
path = introduction;
sourceTree = "<group>";
};
+ 08F265440CEAC22400DA01C9 /* blueprint */ = {
+ isa = PBXGroup;
+ children = (
+ 08F265450CEAC26F00DA01C9 /* component.hpp */,
+ 08BD9AFB0CEB9D330069AFE2 /* get_port.hpp */,
+ 08BD9B090CEB9E3D0069AFE2 /* port.hpp */,
+ 08256FE60CEBDFEC003EC1B4 /* network.hpp */,
+ 08EF04520CEBF0EE002ABBBC /* connection.hpp */,
+ 08EF04590CEBF153002ABBBC /* connection_t.hpp */,
+ 08EF045E0CEBF1AD002ABBBC /* port_t.hpp */,
+ );
+ path = blueprint;
+ sourceTree = "<group>";
+ };
08F348500C492B320096097F /* operator */ = {
isa = PBXGroup;
children = (
@@ -478,6 +507,14 @@
path = utility;
sourceTree = "<group>";
};
+ 08F3592C0CED1E9F00E2BBFB /* blueprint */ = {
+ isa = PBXGroup;
+ children = (
+ 08F3592D0CED1EC400E2BBFB /* blueprint.qbk */,
+ );
+ path = blueprint;
+ sourceTree = "<group>";
+ };
08F37EDE0C57A49500AC7FB8 /* detail */ = {
isa = PBXGroup;
children = (
@@ -541,6 +578,7 @@
08FC25BA0C45B60E00F59CDD /* dataflow */ = {
isa = PBXGroup;
children = (
+ 08F265440CEAC22400DA01C9 /* blueprint */,
08F348960CC021CE006D0A67 /* utility */,
08F079940CA88EAB001E6E24 /* templates */,
08EF9B200C5D506A00D4D206 /* signals */,
@@ -586,6 +624,7 @@
08FD5DE40C1BA60700F00877 /* doc */ = {
isa = PBXGroup;
children = (
+ 08F3592C0CED1E9F00E2BBFB /* blueprint */,
08F264770CEA9DE800DA01C9 /* introduction */,
08F034B60CCBFA95009A4C8E /* port_concepts.qbk */,
083FD3C00C62A75100EF3F6B /* phoenix */,
@@ -605,6 +644,15 @@
path = ../../doc;
sourceTree = SOURCE_ROOT;
};
+ 08FFDD6E0CEB709A009318A8 /* blueprint */ = {
+ isa = PBXGroup;
+ children = (
+ 08FFDD6F0CEB70AD009318A8 /* blueprint_example.cpp */,
+ 08FFDD740CEB71A2009318A8 /* Jamfile.v2 */,
+ );
+ path = blueprint;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXProject section */
Added: sandbox/SOC/2007/signals/libs/dataflow/doc/blueprint/blueprint.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/blueprint/blueprint.qbk 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,27 @@
+[section:blueprint Dataflow.Blueprint]
+
+The current focus of the Dataflow library are mechanisms in which the
+dataflow network is stored in the individual components - i.e., there
+is no global picture of the network available through the library.
+
+The [DataflowBlueprint] layer addresses this shortcoming by
+providing generic components that provide this "big picture"
+of a dataflow network. A blueprint component corresponds to an actual
+component - but whereas the actual component takes care of the work, the
+blueprint component provides a run-time polymorphic interface which can be
+embedded in a BGL graph. A dataflow network blueprint uses such a graph
+to hold the blueprint components and the connectivity information.
+In addition, blueprint components provide run-time port reflection.
+In the future, the bluprint layer will be expanded to support serialization,
+copying, and other features.
+
+The [DataflowBlueprint] layer is built on top of the Dataflow library
+[concepts]. Hence, it can be used with any mechanism for which a Dataflow
+support layer has been implemented.
+
+[warning The [DataflowBlueprint] layer development has only started, and
+the current implementation is very rough. There is no documentation,
+but the provided [link dataflow.introduction.examples.blueprint example]
+provides some insight into its usability.]
+
+[endsect]
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/concepts.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/concepts.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/concepts.qbk 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -269,6 +269,40 @@
[[Name] [Expression] [Result Type] [Semantics]]
[
[Mechanism]
+ [`PC::ports`]
+ [MPL Sequence of [PortTraitsConcept] types.]
+ [[PortTraitsConcept] of exposed [PortConcept]s.]
+ ]
+]
+
+[heading Header]
+
+```
+ #include <boost/dataflow/support/component.hpp> // or
+ #include <boost/dataflow/support.hpp>
+```
+
+[heading Notes]
+
+[heading Examples]
+
+[endsect][/componenttraits]
+
+[section ReflectiveComponentTraits]
+
+A ['[ReflectiveComponentTraitsConcept]] specifies the traits of a [ReflectiveComponentConcept].
+
+[heading Notation]
+[variablelist
+ [[CT] [A ReflectiveComponentTraits type.]]
+ [[C] [A [ReflectiveComponentConcept] type of traits `CT`.]]
+]
+
+[heading Requirements]
+[table
+ [[Name] [Expression] [Result Type] [Semantics]]
+ [
+ [Mechanism]
[`PC::mechanism`]
[any type]
[[MechanismConcept] type tag.]
@@ -286,8 +320,7 @@
[heading Examples]
-[endsect][/componenttraits]
-
+[endsect][/reflectivecomponenttraits]
[section Component]
Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -50,6 +50,7 @@
[template vtk_example[text] [link dataflow.introduction.examples.new_layer [text]]]
[template how_to_use[text] [link dataflow.introduction.how_to_use [text]]]
[template DataflowSignals[] [link dataflow.signals Dataflow.Signals]]
+[template DataflowBlueprint[] [link dataflow.blueprint Dataflow.Blueprint]]
[template DataflowPhoenix[] [link dataflow.phoenix Dataflow.Phoenix]]
[template producer_group[] [link dataflow.components.producer_group producer_group]]
@@ -131,6 +132,8 @@
[import ../example/VTK/vtk_dataflow_support.hpp]
[import ../example/VTK/Cone.cxx]
+[import ../example/blueprint/blueprint_example.cpp]
+
[include introduction.qbk]
[include concepts.qbk]
@@ -139,6 +142,8 @@
[include signals.qbk]
+[include blueprint/blueprint.qbk]
+
[include phoenix.qbk]
[section Development]
Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/future.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/future.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/future.qbk 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -1,20 +1,7 @@
[section:future Future Directions]
-[section:blueprint The blueprint layer]
+[section:blueprint Expanding the blueprint layer]
-The current focus of the Dataflow library are mechanisms in which the
-dataflow network is stored in the individual components - i.e., there
-is no global picture of the network available through the library.
-
-One way of adressing this shortcoming is a planned /blueprint/ layer, which
-would provide generic components that would provide this "big picture"
-of a dataflow network. A blueprint component corresponds to an actual
-component - but whereas the actual component takes care of the work, the
-blueprint component serves as a factory and serializer of the component.
-Hence, a dataflow network blueprint, made out of blueprint components, could
-be used to serialize or instantiate the underlying dataflow network made out
-of actual components. The blueprint layer is likely to be implemented using
-run-time polymorphic classes and the Boost Graph library.
[endsect]
Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/introduction.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/introduction.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/introduction.qbk 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -232,6 +232,17 @@
[link dataflow.introduction.examples.distributed distributed dataflow application].
* The [DataflowSignals] documentation.
+[heading Dataflow.Blueprint layer]
+
+[DataflowBlueprint] provides run-time reflection and modeling of dataflow
+networks in a BGL graph for any mechanism with implemented Dataflow support.
+
+The development of this layer has only begun. To find out more about it, see:
+
+* The example on [link dataflow.introduction.examples.blueprint run-time
+ reflection and connectivity modeling].
+
+
[/[heading When to use]
While the [link dataflow.introduction.dataflow dataflow] section hopefully
@@ -339,6 +350,7 @@
[include introduction/distributed_example.qbk]
[include introduction/gil_example.qbk]
+[include introduction/blueprint_example.qbk]
[include introduction/vtk_example.qbk]
[endsect][/examples]
@@ -356,6 +368,7 @@
Version 0.8.1 (under construction)
+* started the [DataflowBlueprint] layer.
* expanding the [ComponentConcept] concept.
* making VTK example Jamfile work for more than Darwin and X11.
* provided an example using Boost.GIL.
Added: sandbox/SOC/2007/signals/libs/dataflow/doc/introduction/blueprint_example.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/introduction/blueprint_example.qbk 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,32 @@
+[section:blueprint Run-time reflection and connectivity modeling using Dataflow.Blueprint]
+
+The (recently started) [DataflowBlueprint] layer offers run-time reflection
+of components and modeling of
+a dataflow network through a BGL graph. The following example briefly
+illustrates some of the capabilities:
+
+[blueprint_example]
+
+The output is:
+
+[pre
+source has 2 ports.
+ port 0 is a producer
+ port 1 is a consumer
+
+source port 0 is connectable to sink port 1
+source port 1 is not connectable to sink port 0
+source port 0 is not connectable to sink port 0
+source port 0 is not connectable to sink_float port 1
+
+Blueprint connecting source to sink, source_float to sink_float...
+
+Using BGL to analyze the network... There are 2 independent parts of the network.
+
+Making the connections...
+Invoking the sources...
+sink now has:100
+sink_float now has:100.1
+]
+
+[endsect]
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -5,6 +5,7 @@
build-project VTK ;
build-project signals ;
+build-project blueprint ;
project dataflow/example
: requirements
Added: sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/Jamfile.v2 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,13 @@
+# 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/example/blueprint
+ : requirements
+ <include>../../../..
+ <library>/boost/signals//boost_signals/<link>static
+ <define>BOOST_ALL_NO_LIB=1
+ ;
+
+exe blueprint_example : blueprint_example.cpp ;
Added: sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/blueprint_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/blueprint_example.cpp 2007-11-15 21:10:20 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,98 @@
+//[ blueprint_example
+
+// 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)
+
+#include <boost/dataflow/blueprint/network.hpp>
+#include <boost/dataflow/signals/component/storage.hpp>
+#include <boost/dataflow/signals/runtime_support.hpp>
+
+#include <boost/graph/copy.hpp>
+#include <boost/graph/connected_components.hpp>
+
+#include <iostream>
+
+namespace blueprint=boost::dataflow::blueprint;
+namespace df=boost::dataflow;
+
+using namespace boost;
+
+int main()
+{
+ typedef blueprint::network<df::signals::mechanism> network_type;
+
+ // Start with the network.
+ network_type network;
+
+ // Add the components.
+ network_type::component_type
+ source = network.add_component<signals::storage<void(int)> >(100),
+ sink = network.add_component<signals::storage<void(int)> >(0),
+ source_float = network.add_component<signals::storage<void(float)> >(100.1),
+ sink_float = network.add_component<signals::storage<void(float)> >(0);
+
+ // Print some runtime info
+ std::cout << "source has " << network[source].num_ports() << " ports. " << std::endl;
+ for (int i=0; i<network[source].num_ports(); i++)
+ std::cout << " port " << i << " is a "
+ << (network.get_port(source, i)->category()) << std::endl;
+ std::cout << std::endl;
+
+ std::cout
+ << "source port 0 is "
+ << (network.are_connectable(source, 0, sink, 1) ? "" : "not ")
+ << "connectable to sink port 1" << std::endl;
+
+ std::cout
+ << "source port 1 is "
+ << (network.are_connectable(source, 1, sink, 0) ? "" : "not ")
+ << "connectable to sink port 0" << std::endl;
+
+ std::cout
+ << "source port 0 is "
+ << (network.are_connectable(source, 0, sink, 0) ? "" : "not ")
+ << "connectable to sink port 0" << std::endl;
+
+ std::cout
+ << "source port 0 is "
+ << (network.are_connectable(source, 0, sink_float, 1) ? "" : "not ")
+ << "connectable to sink_float port 1" << std::endl;
+
+ // Make some connections
+ std::cout << std::endl << "Blueprint connecting source to sink, source_float to sink_float..." << std::endl;
+ network.add_connection(source, 0, sink, 1);
+ network.add_connection(source_float, 0, sink_float, 1);
+
+ // Do some analysis on the connectivity graph
+ typedef boost::adjacency_list<
+ boost::vecS, boost::vecS, boost::undirectedS> ugraph_type;
+
+ ugraph_type g;
+ copy_graph(network.graph(), g);
+ std::vector<int> component(num_vertices(g));
+ std::cout << std::endl << "Using BGL to analyze the network... There are "
+ << connected_components(g, &component[0])
+ << " independent parts of the network." << std::endl << std::endl;
+
+ // Connect the underlying components
+ std::cout << "Making the connections..." << std::endl;
+ network.connect();
+
+ // Invoke the sources
+ std::cout << "Invoking the sources..." << std::endl;
+ network[source].invoke();
+ network[source_float].invoke();
+
+ // Output the values at the sinks:
+ std::cout << "sink now has:"
+ << ((blueprint::component_t<df::signals::mechanism, signals::storage<void(int)> > &)
+ network[sink]).get().at<0>() << std::endl;
+ std::cout << "sink_float now has:"
+ << ((blueprint::component_t<df::signals::mechanism, signals::storage<void(float)> > &)
+ network[sink_float]).get().at<0>() << std::endl;
+
+}
+
+//]
\ No newline at end of file
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