|
Boost-Commit : |
From: stipe_at_[hidden]
Date: 2007-11-17 22:15:41
Author: srajko
Date: 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
New Revision: 41189
URL: http://svn.boost.org/trac/boost/changeset/41189
Log:
reimplement blueprint::get_port using the Switch lib, expand example, make port_traits a data struct, add to docs
Added:
sandbox/SOC/2007/signals/boost/switch.hpp (contents, props changed)
Text files modified:
sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp | 16 ++-
sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection.hpp | 1
sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection_t.hpp | 4
sandbox/SOC/2007/signals/boost/dataflow/blueprint/get_port.hpp | 71 ++++++--------
sandbox/SOC/2007/signals/boost/dataflow/blueprint/network.hpp | 43 ++++++++
sandbox/SOC/2007/signals/boost/dataflow/blueprint/port.hpp | 39 +++++++-
sandbox/SOC/2007/signals/boost/dataflow/blueprint/port_t.hpp | 16 +-
sandbox/SOC/2007/signals/boost/dataflow/signals/component/filter.hpp | 2
sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/signal_network.xcodeproj/project.pbxproj | 2
sandbox/SOC/2007/signals/libs/dataflow/doc/blueprint/blueprint.qbk | 5
sandbox/SOC/2007/signals/libs/dataflow/doc/concepts.qbk | 17 ++-
sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk | 2
sandbox/SOC/2007/signals/libs/dataflow/doc/future.qbk | 15 +++
sandbox/SOC/2007/signals/libs/dataflow/doc/introduction.qbk | 25 ++--
sandbox/SOC/2007/signals/libs/dataflow/doc/introduction/blueprint_example.qbk | 76 +++++++++++++--
sandbox/SOC/2007/signals/libs/dataflow/doc/phoenix.qbk | 2
sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/blueprint_example.cpp | 182 +++++++++++++++++++++++++--------------
17 files changed, 353 insertions(+), 165 deletions(-)
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 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -24,6 +24,8 @@
virtual void invoke()=0;
virtual int num_ports() const=0;
virtual std::auto_ptr<port> get_port(int port_num)=0;
+
+ virtual std::auto_ptr<component> copy() const=0;
virtual ~component() {};
};
@@ -33,11 +35,11 @@
public:
component_t() {}
template<typename T0>
- component_t(const T0 &t0) : component(t0) {}
+ component_t(const T0 &t0) : c(t0) {}
void invoke()
{
- component_operation<operations::invoke, Mechanism>(component);
+ component_operation<operations::invoke, Mechanism>(c);
}
int num_ports() const
{
@@ -45,11 +47,15 @@
}
std::auto_ptr<port> get_port(int port_num)
{
- return blueprint::get_port<Mechanism, Component>(component, port_num);
+ return blueprint::get_port<Mechanism, Component>(c, port_num);
+ }
+ virtual std::auto_ptr<component> copy() const
+ {
+ return std::auto_ptr<component>(new component_t<Mechanism,Component>(*this));
}
- Component &get() {return component;}
+ Component &get() {return c;}
private:
- Component component;
+ Component c;
};
} } } // namespace boost::dataflow::blueprint
Modified: sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection.hpp 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -15,6 +15,7 @@
{
public:
virtual void connect(port &producer, port &consumer)=0;
+ virtual std::auto_ptr<connection> copy() const=0;
virtual ~connection() {};
};
Modified: sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection_t.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection_t.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/connection_t.hpp 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -23,6 +23,10 @@
*(typename remove_reference<ProducerPort>::type *) producer.get(),
*(typename remove_reference<ConsumerPort>::type *) consumer.get());
}
+ virtual std::auto_ptr<connection> copy() const
+ {
+ return std::auto_ptr<connection>(new connection_t(*this));
+ }
};
} } } // namespace boost::dataflow::blueprint
Modified: sandbox/SOC/2007/signals/boost/dataflow/blueprint/get_port.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/blueprint/get_port.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/get_port.hpp 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -9,51 +9,38 @@
#include <boost/dataflow/blueprint/port_t.hpp>
#include <boost/dataflow/support/reflective_component.hpp>
+#include <boost/mpl/range_c.hpp>
+#include <boost/switch.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>
+struct get_port_case
{
- std::auto_ptr<port> operator()(Component &c, int port_num)
+ typedef void result_type;
+ template<class Case>
+ void operator()(Case) const
{
- 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;
+ ret.reset(new port_t<
+ typename mpl::at_c<
+ typename component_traits_of<Mechanism, Component>::type::ports,
+ Case::value
+ >::type,
+ typename get_component_port_result_type<
+ Mechanism,
+ mpl::int_<Case::value>,
+ Component
+ >::type
+ >(get_component_port<Mechanism, mpl::int_<Case::value>, Component >(c))); \
}
+ get_port_case(Component& c, std::auto_ptr<port> &ret) : c(c), ret(ret)
+ {}
+ Component &c;
+ std::auto_ptr<port> &ret;
};
} // namespace detail
@@ -61,11 +48,15 @@
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);
+ std::auto_ptr<port> ret;
+ typedef mpl::range_c<
+ int,
+ 0,
+ mpl::size<
+ typename component_traits_of<Mechanism, Component>::type::ports>
+ ::value> range;
+ boost::switch_<range>(port_num, detail::get_port_case<Mechanism, Component>(c, ret));
+ return ret;
}
} } } // namespace boost::dataflow::blueprint
Modified: sandbox/SOC/2007/signals/boost/dataflow/blueprint/network.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/blueprint/network.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/network.hpp 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -10,6 +10,7 @@
#include <boost/dataflow/blueprint/connection_t.hpp>
#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/copy.hpp>
#include <exception>
#include <iostream>
@@ -32,9 +33,42 @@
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;
-
+ typedef typename graph_type::edge_descriptor connection_type;
+private:
+ struct vc
+ {
+ vc(const graph_type &g_src, graph_type &g_dst)
+ : g_src(g_src), g_dst(g_dst)
+ {}
+ void operator()(component_type src, component_type &dst)
+ {
+ g_dst[dst].ptr = g_src[src].ptr->copy();
+ }
+ const graph_type &g_src;
+ graph_type &g_dst;
+ };
+ struct ec
+ {
+ ec(const graph_type &g_src, graph_type &g_dst)
+ : g_src(g_src), g_dst(g_dst)
+ {}
+ void operator()(connection_type src, connection_type &dst)
+ {
+ g_dst[dst].ptr = g_src[src].ptr->copy();
+ g_dst[dst].producer_port = g_src[src].producer_port;
+ g_dst[dst].consumer_port = g_src[src].consumer_port;
+ }
+ const graph_type &g_src;
+ graph_type &g_dst;
+ };
+public:
+ network() {}
+ network(const network &n)
+ {
+ copy_graph(n.g, g, vertex_copy(vc(n.g, g)).edge_copy(ec(n.g, g)));
+ }
+
template<typename Component>
component_type add_component()
{
@@ -66,8 +100,8 @@
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));
+ && (get_port(p, p_port)->traits().category().uuid() == 0)
+ && (get_port(c, c_port)->traits().category().uuid() == 1));
}
void connect()
{
@@ -89,6 +123,7 @@
{
return g;
}
+
private:
void add_connection_(component_type p, int p_port, component_type c, int c_port,
boost::shared_ptr<connection>)
Modified: sandbox/SOC/2007/signals/boost/dataflow/blueprint/port.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/blueprint/port.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/port.hpp 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -7,24 +7,53 @@
#define BOOST_DATAFLOW_BLUEPRINT_PORT_HPP
#include <boost/shared_ptr.hpp>
+#include <string>
namespace boost { namespace dataflow { namespace blueprint {
class connection;
+class port_category
+{
+public:
+ port_category(const std::string &name, int uuid)
+ : name_(name), uuid_(uuid)
+ {}
+
+ const char *name() const
+ { return name_.c_str(); }
+ int uuid() const
+ { return uuid_; }
+private:
+ std::string name_;
+ int uuid_;
+};
+
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() {};
+ port_traits(const port_category &category) : category_(category)
+ {}
+ const port_category &category() const
+ { return category_;
+ }
+private:
+ port_category category_;
};
-class port : public port_traits
+class port
{
public:
+ port(const port_category &category) : traits_(category)
+ {}
+ const port_traits &traits() const
+ { return traits_; }
+
virtual void *get()=0;
+ virtual shared_ptr<connection> connector()=0;
+ virtual ~port() {};
+private:
+ port_traits traits_;
};
} } } // namespace boost::dataflow::blueprint
Modified: sandbox/SOC/2007/signals/boost/dataflow/blueprint/port_t.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/blueprint/port_t.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/port_t.hpp 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -59,16 +59,14 @@
{
typedef typename PortTraits::mechanism::template runtime_connection<PortTraits>::type connection_type;
public:
- port_t(Port p) : p(p), c(new connection_type()){}
+ port_t(Port p)
+ : port(port_category(
+ runtime::property<typename PortTraits::category, const char *>()(),
+ runtime::property<typename PortTraits::category, int>()()))
+ , 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;
Modified: sandbox/SOC/2007/signals/boost/dataflow/signals/component/filter.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signals/component/filter.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signals/component/filter.hpp 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -94,6 +94,8 @@
typedef filter<Signature, unfused, Combiner, Group, GroupCompare> base_type;
public:
filter() : fused_out(base_type::out) {}
+ filter(const filter &) : fused_out(base_type::out){}
+ const filter &operator = (const filter &) {return *this;}
typedef typename base_type::signature_type signature_type;
typedef typename base_type::signal_type signal_type;
Added: sandbox/SOC/2007/signals/boost/switch.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/switch.hpp 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -0,0 +1,129 @@
+// switch.hpp
+//
+// Copyright (c) 2006-2007
+// Steven Watanabe
+//
+// Distriuted 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)
+
+#ifndef BOOST_SWITCH_HPP_INCLUDED
+#define BOOST_SWITCH_HPP_INCLUDED
+
+#include <stdexcept>
+#include <string>
+#include <boost/config.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/preprocessor/config/limits.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/iteration/local.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/at.hpp>
+
+#ifndef BOOST_SWITCH_LIMIT
+ #define BOOST_SWITCH_LIMIT 50
+#endif
+
+#if BOOST_SWITCH_LIMIT > BOOST_PP_LIMIT_REPEAT
+ #error BOOST_SWITCH_LIMIT exceeds Boost.Preprocessor limit
+#endif
+#if BOOST_SWITCH_LIMIT > BOOST_PP_LIMIT_ITERATION
+ #error BOOST_SWITCH_LIMIT exceeds Boost.Preprocessor limit
+#endif
+
+namespace boost {
+
+class bad_switch : public std::runtime_error {
+public:
+ template<class Int>
+ explicit bad_switch(Int v) :
+ std::runtime_error(
+ "boost::switch_ default case called -- none provided. value is: " +
+ boost::lexical_cast<std::string>(v)) {}
+};
+
+namespace switch_detail {
+
+// Avoid the need to create all the specializations of switch_impl
+// twice. Just pass this to switch_impl<N>::apply(...) when no
+// default is supplied.
+
+template<class R>
+R forced_return(R* r = 0) {
+ return(*r);
+}
+
+// Thanks to Stjepan Rajko for catching this.
+template<>
+void forced_return<void>(void*) {}
+
+template<class R>
+struct throw_exception {
+ template<class Int>
+ R operator()(Int i) const {
+ boost::throw_exception(bad_switch(i));
+ return(switch_detail::forced_return<R>());
+ }
+};
+
+// N is the number of cases not including the default
+template<int N>
+struct switch_impl;
+
+// specialize for 0 separately to avoid warnings
+template<>
+struct switch_impl<0> {
+ template<class V, class Int, class F, class Default>
+ static typename F::result_type
+ apply(Int i, F, Default d BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(V)) {
+ return(d(i));
+ }
+};
+
+#define BOOST_SWITCH_CASE(z, n, data) \
+ case boost::mpl::at_c<data, n>::type::value: { \
+ typename boost::mpl::at_c<data, n>::type arg; \
+ return(f(arg)); \
+ }
+
+#define BOOST_SWITCH_IMPL(z, n, data) \
+ template<> \
+ struct switch_impl<n> { \
+ template<class V, class I, class F, class D> \
+ static typename F::result_type \
+ apply(I i, F f, D d BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(V)) { \
+ switch(i) { \
+ BOOST_PP_REPEAT_##z(n, BOOST_SWITCH_CASE, V) \
+ default: return(d(i)); \
+ } \
+ } \
+ };
+
+#define BOOST_PP_LOCAL_LIMITS (1, BOOST_SWITCH_LIMIT)
+#define BOOST_PP_LOCAL_MACRO(n) BOOST_SWITCH_IMPL(1, n, ~)
+#include BOOST_PP_LOCAL_ITERATE()
+
+#undef BOOST_SWITCH_IMPL
+#undef BOOST_SWITCH_CASE
+
+}
+
+template<class V, class N, class F>
+inline typename F::result_type
+switch_(N n, F f BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(V)) {
+ typedef switch_detail::switch_impl<boost::mpl::size<V>::value> impl;
+ switch_detail::throw_exception<typename F::result_type> default_;
+ return(impl::template apply<V>(n, f, default_));
+}
+
+template<class V, class N, class F, class D>
+inline typename F::result_type
+switch_(N n, F f, D d BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(V)) {
+ typedef switch_detail::switch_impl<boost::mpl::size<V>::value> impl;
+ return(impl::template apply<V>(n, f, d));
+}
+
+}
+
+#endif
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-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -482,10 +482,10 @@
08F265450CEAC26F00DA01C9 /* component.hpp */,
08BD9AFB0CEB9D330069AFE2 /* get_port.hpp */,
08BD9B090CEB9E3D0069AFE2 /* port.hpp */,
+ 08EF045E0CEBF1AD002ABBBC /* port_t.hpp */,
08256FE60CEBDFEC003EC1B4 /* network.hpp */,
08EF04520CEBF0EE002ABBBC /* connection.hpp */,
08EF04590CEBF153002ABBBC /* connection_t.hpp */,
- 08EF045E0CEBF1AD002ABBBC /* port_t.hpp */,
);
path = blueprint;
sourceTree = "<group>";
Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/blueprint/blueprint.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/blueprint/blueprint.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/blueprint/blueprint.qbk 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -12,8 +12,9 @@
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.
+In the future, the bluprint layer will be expanded to support serialization
+and other features. More details are in the [link dataflow.future.blueprint
+future work section].
The [DataflowBlueprint] layer is built on top of the Dataflow library
[concepts]. Hence, it can be used with any mechanism for which a Dataflow
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-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -85,7 +85,7 @@
Operations between two ports such as /connect/, /connect_only/, /disconnect/,
and /extract/ are captured by the [BinaryOperable] concept. Operations
-on a single port such as /disconnect_all/ are covered by the [UnaryOperable]
+on a single port such as /disconnect_all/ are covered by the [UnaryOperableConcept]
concept.
[/
@@ -292,6 +292,10 @@
A ['[ReflectiveComponentTraitsConcept]] specifies the traits of a [ReflectiveComponentConcept].
+[heading Refinement of]
+
+* [ComponentTraitsConcept]
+
[heading Notation]
[variablelist
[[CT] [A ReflectiveComponentTraits type.]]
@@ -303,16 +307,19 @@
[[Name] [Expression] [Result Type] [Semantics]]
[
[Mechanism]
- [`PC::mechanism`]
- [any type]
- [[MechanismConcept] type tag.]
+ [`PC::ports`]
+ [MPL Sequence of [PortTraitsConcept] types]
+ [
+ An enumeration of the [PortTraitsConcept] of the exposed
+ [PortConcept]s.
+ ]
]
]
[heading Header]
```
- #include <boost/dataflow/support/component.hpp> // or
+ #include <boost/dataflow/support/reflective_component.hpp> // or
#include <boost/dataflow/support.hpp>
```
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-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -25,7 +25,7 @@
[template ComponentTraitsConcept[] [link dataflow.concepts.componenttraits [^ComponentTraits]]]
[template ComponentConcept[] [link dataflow.concepts.component [^Component]]]
-[template ReflectiveComponentTraitsConcept[] [link dataflow.concepts.reflecivecomponenttraits [^ReflectiveComponentTraits]]]
+[template ReflectiveComponentTraitsConcept[] [link dataflow.concepts.reflectivecomponenttraits [^ReflectiveComponentTraits]]]
[template ReflectiveComponentConcept[] [link dataflow.concepts.reflectivecomponent [^ReflectiveComponent]]]
[template BinaryOperableConcept[] [link dataflow.concepts.binaryoperable [^BinaryOperable]]]
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-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -2,6 +2,19 @@
[section:blueprint Expanding the blueprint layer]
+The [DataflowBlueprint] layer now offers some limited dataflow network modeling
+via a BGL graph, and some basic runtime reflections for classes that model
+the [ReflectiveComponentConcept] concept.
+
+The following features are planned for the future:
+
+* *Serialization* - It should be possible to serialize and deserialize a
+ network blueprint. This could be used to store datafow programs, or to send
+ them over the network.
+
+* *Component banks* - Banks of components which can be accessed at runtime.
+
+* *Documentation* - non-existant at this point...
[endsect]
@@ -16,7 +29,7 @@
based on the [@http://vcreatelogic.com/oss/gcf/index.html Generic
Component Framework] and is released under the GNU GPL license.
-Once the [blueprint] layer is built, it might be possible to integrate
+Once the [DataflowBlueprint] layer is completed, it might be possible to integrate
it with the Generic Component Framework to get a visual programming
environment for the Dataflow library.
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-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -1,5 +1,11 @@
[section:introduction Introduction]
+[warning Dataflow is not a part of the Boost libraries. It was developed
+as a part of the Google Summer of Code program. The original proposal (for
+the Signal Network library, which became the Dataflow library)
+as well as some GSoC status updates can be found on the
+[@http://svn.boost.org/trac/boost/wiki/soc/2007/SignalNetwork GSoC page].]
+
Dataflow is a generic library for [WikiDataflow] programming using various data
transport mechanisms. It also has layers of support for
two data transport mechanisms - one is based on
@@ -11,13 +17,8 @@
The two data transport mechanisms are implemented in the [DataflowSignals]
and [DataflowPhoenix] layers. The idea behind providing a generic dataflow
library is that other data transport mechanisms can be easily adapted for
-use with the library.
-
-[warning Dataflow is not a part of the Boost libraries. It is being developed
-as a part of the Google Summer of Code program. The original proposal (for
-the Signal Network library, which became the Dataflow library)
-as well as some status updates can be found on the
-[@http://svn.boost.org/trac/boost/wiki/soc/2007/SignalNetwork GSoC page].]
+use with the library, and benefit from layers built on top of it
+(such as the recently started [DataflowBlueprint] layer).
* If you would like some more information about why one would want to connect
objects into a dataflow network, read about
@@ -25,7 +26,6 @@
* If you'd like to try out the library
* keep in mind that the interface is subject to change
* Read [how_to_use how to use this library and the documentation].
-
[section:dataflow Dataflow programming in C++ - motivation and advantages]
@@ -206,7 +206,8 @@
Currently, the most useful functionality gained by developing a Dataflow
support layer is the ability to connect components in a clean, readable
manner. As more generic code is developed on top of
-the generic dataflow layer, providing a Dataflow support layer for your
+the generic dataflow layer (such as the recently started [DataflowBlueprint]),
+providing a Dataflow support layer for your
favorite data transport mechanism will be more beneficial.
See the [link dataflow.future future directions] of the Dataflow library
@@ -368,9 +369,9 @@
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.
+* started the [DataflowBlueprint] layer (simple runtime reflection and network modeling).
+* expanding the [ComponentConcept] concept (compile-time reflection of ports).
+* VTK example Jamfile now works work with Windows (not just Darwin+X11 VTK).
* provided an example using Boost.GIL.
Version 0.8.0 -
Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/introduction/blueprint_example.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/introduction/blueprint_example.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/introduction/blueprint_example.qbk 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -2,31 +2,81 @@
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:
+a dataflow network through a BGL graph. Here is the output of a small example
+which 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
+Printing runtime info about all of the components:
+
+ source has 2 ports.
+ port 0 is a producer
+ port 1 is a consumer
+
+ sink has 2 ports.
+ port 0 is a producer
+ port 1 is a consumer
+
+ source_float has 2 ports.
+ port 0 is a producer
+ port 1 is a consumer
+
+ sink_float 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...
+Making blueprint connections: 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
+Making a copy of the blueprint.
+
+Testing the original network...
+
+ Values at components:
+ value at source:100
+ value at sink:0
+ value at source_float:100.1
+ value at sink_float:0
+
+ Connecting the underlying components in the network...
+ Invoking the sources...
+
+ Values at components:
+ value at source:100
+ value at sink:100
+ value at source_float:100.1
+ value at sink_float:100.1
+
+Testing the network copy...
+
+ Values at components:
+ value at source:100
+ value at sink:0
+ value at source_float:100.1
+ value at sink_float:0
+
+ Connecting the underlying components in the network...
+ Invoking the sources...
+
+ Values at components:
+ value at source:100
+ value at sink:100
+ value at source_float:100.1
+ value at sink_float:100.1
+
+
+blueprint_example release has exited with status 0.
]
+The source is:
+
+[blueprint_example]
+
+
[endsect]
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/phoenix.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/phoenix.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/phoenix.qbk 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -1,6 +1,6 @@
[section:phoenix Dataflow.Phoenix]
-[include phoenix/concepts.qbk]
+[/[include phoenix/concepts.qbk]]
The [DataflowPhoenix] module uses ordinary object pointers to establish
a flow of data. It has been named after the Phoenix library because
Modified: sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/blueprint_example.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/blueprint_example.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/blueprint/blueprint_example.cpp 2007-11-17 22:15:39 EST (Sat, 17 Nov 2007)
@@ -9,7 +9,6 @@
#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>
@@ -19,80 +18,131 @@
using namespace boost;
-int main()
+class blueprint_example
{
typedef blueprint::network<df::signals::mechanism> network_type;
-
- // Start with the network.
+
+ // The network.
network_type network;
- // Add the components.
- network_type::component_type
+ // The components (graph indices).
+ network_type::component_type source, sink, source_float, sink_float;
+
+public:
+ blueprint_example()
+ {
+ // Add the components to the network.
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.1f),
sink_float = network.add_component<signals::storage<void(float)> >(0.0f);
-
- // 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;
+ }
+ void run()
+ {
+ // Print some runtime port info
+ std::cout << "Printing runtime info about all of the components:" << std::endl << std::endl;
+ print_port_info("source", source);
+ print_port_info("sink", sink);
+ print_port_info("source_float", source_float);
+ print_port_info("sink_float", sink_float);
+
+ // Print some runtime connectability info
+ print_connectability_info("source", source, 0, "sink", sink, 1);
+ print_connectability_info("source", source, 1, "sink", sink, 0);
+ print_connectability_info("source", source, 0, "sink", sink, 0);
+ print_connectability_info("source", source, 0, "sink_float", sink_float, 1);
+ std::cout << std::endl;
+
+ // Make some connections
+ std::cout << "Making blueprint connections: 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;
+
+ // Copy the network
+ std::cout << "Making a copy of the blueprint." << std::endl << std::endl;
+ network_type network_copy(network);
+
+ std::cout << "Testing the original network..." << std::endl << std::endl;
+ test_network(network);
+ std::cout << "Testing the network copy..." << std::endl << std::endl;
+ test_network(network_copy);
+ }
+ void print_port_info(const char *c_name, network_type::component_type c)
+ {
+ std::cout << "\t" << c_name << " has " << network[c].num_ports() << " ports. " << std::endl;
+ for (int i=0; i<network[c].num_ports(); i++)
+ std::cout << "\t\tport " << i << " is a "
+ << (network.get_port(c, i)->traits().category().name()) << std::endl;
+ std::cout << std::endl;
+ }
+ void print_connectability_info(
+ const char *src_name, network_type::component_type src, size_t src_port,
+ const char *dst_name, network_type::component_type dst, size_t dst_port)
+ {
+ std::cout
+ << src_name << " port " << src_port << " is "
+ << (network.are_connectable(src, src_port, dst, dst_port) ? "" : "not ")
+ << "connectable to " << dst_name << " port " << dst_port << std::endl;
+ }
+
+ template<typename T>
+ void output_component_value(
+ network_type &network, const char *c_name, typename network_type::component_type c)
+ {
+ typedef blueprint::component_t<df::signals::mechanism, signals::storage<void(T)> > & c_type;
+
+ std::cout << "\t\tvalue at " << c_name << ":"
+ << static_cast<c_type>(network[c]).get()
+ .template at<0>()
+ << std::endl;
+ }
+ void output_component_values(network_type &network)
+ {
+ std::cout << "\tValues at components:" << std::endl;
+ output_component_value<int>(network, "source", source);
+ output_component_value<int>(network, "sink", sink);
+ output_component_value<float>(network, "source_float", source_float);
+ output_component_value<float>(network, "sink_float", sink_float);
+ std::cout << std::endl;
+ }
+
+ void test_network(network_type &network)
+ {
+ // Output the values at the components:
+ output_component_values(network);
+
+ // Connect the underlying components
+ std::cout << "\tConnecting the underlying components in the network..." << std::endl;
+ network.connect();
+
+ // Invoke the sources
+ std::cout << "\tInvoking the sources..." << std::endl;
+ network[source].invoke();
+ network[source_float].invoke();
+ std::cout << std::endl;
+
+ // Output the values at the sinks:
+ output_component_values(network);
+ }
+};
+int main()
+{
+ blueprint_example example;
+ example.run();
+
+ return 0;
}
//]
\ 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