|
Boost-Commit : |
From: stipe_at_[hidden]
Date: 2007-08-03 19:20:41
Author: srajko
Date: 2007-08-03 19:20:40 EDT (Fri, 03 Aug 2007)
New Revision: 38430
URL: http://svn.boost.org/trac/boost/changeset/38430
Log:
refactor signal_network to use generic dataflow layer (complete)
Added:
sandbox/SOC/2007/signals/boost/dataflow/support/connectable.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/support/consumer.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/support/invocable.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/support/producer.hpp (contents, props changed)
sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk (contents, props changed)
- copied, changed from r7551, /sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network.qbk
Text files modified:
sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk | 140 +++++++++++++++++++++++++--------------
1 files changed, 89 insertions(+), 51 deletions(-)
Added: sandbox/SOC/2007/signals/boost/dataflow/support/connectable.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/connectable.hpp 2007-08-03 19:20:40 EDT (Fri, 03 Aug 2007)
@@ -0,0 +1,74 @@
+// 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)
+
+#ifndef BOOST_DATAFLOW_SUPPORT_CONNECTABLE_HPP
+#define BOOST_DATAFLOW_SUPPORT_CONNECTABLE_HPP
+
+#include <boost/static_assert.hpp>
+
+
+namespace boost { namespace dataflow {
+
+namespace extension
+{
+ template<typename ProducerTag, typename ConsumerTag, typename Enable=void>
+ struct connect_impl
+ {
+ template<typename Producer, typename Consumer>
+ struct apply
+ {
+ static void call(const Producer &, const Consumer &)
+ {
+ // Error: connect_impl has not been implemented for ProducerTag
+ // and ConsumerTag.
+ BOOST_STATIC_ASSERT(sizeof(Producer)==0);
+ }
+ };
+ };
+}
+
+template<typename Producer, typename Consumer>
+inline void connect(Producer &producer, Consumer &consumer)
+{
+ extension::connect_impl<
+ typename producer_category_of<Producer>::type,
+ typename consumer_category_of<Consumer>::type>
+ ::template apply<Producer,Consumer>
+ ::call(producer,consumer);
+}
+
+template<typename Producer, typename Consumer>
+inline void connect(const Producer &producer, Consumer &consumer)
+{
+ extension::connect_impl<
+ typename producer_category_of<Producer>::type,
+ typename consumer_category_of<Consumer>::type>
+ ::template apply<Producer,Consumer>
+ ::call(producer,consumer);
+}
+
+template<typename Producer, typename Consumer>
+inline void connect(Producer &producer, const Consumer &consumer)
+{
+ extension::connect_impl<
+ typename producer_category_of<Producer>::type,
+ typename consumer_category_of<Consumer>::type>
+ ::template apply<Producer,Consumer>
+ ::call(producer,consumer);
+}
+
+template<typename Producer, typename Consumer>
+inline void connect(const Producer &producer, const Consumer &consumer)
+{
+ extension::connect_impl<
+ typename producer_category_of<Producer>::type,
+ typename consumer_category_of<Consumer>::type>
+ ::template apply<Producer,Consumer>
+ ::call(producer,consumer);
+}
+
+} } // namespace boost::dataflow
+
+#endif // BOOST_DATAFLOW_SUPPORT_CONNECTABLE_HPP
Added: sandbox/SOC/2007/signals/boost/dataflow/support/consumer.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/consumer.hpp 2007-08-03 19:20:40 EDT (Fri, 03 Aug 2007)
@@ -0,0 +1,39 @@
+// 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)
+
+#ifndef BOOST_DATAFLOW_SUPPORT_CONSUMER_HPP
+#define BOOST_DATAFLOW_SUPPORT_CONSUMER_HPP
+
+#include <boost/dataflow/detail/enable_if_defined.hpp>
+
+#include <boost/type_traits/integral_constant.hpp>
+
+
+namespace boost { namespace dataflow {
+
+// trait giving the consumer category of a type.
+template<typename T, typename Enable=void>
+struct consumer_category_of;
+
+template<typename T>
+struct consumer_category_of<T,
+typename detail::enable_if_defined<typename T::consumer_category>::type >
+{
+ typedef typename T::consumer_category type;
+};
+
+// trait determining whether a type is a consumer.
+template<typename T, typename Enable=void>
+struct is_consumer
+ : public boost::false_type {};
+
+template<typename T>
+struct is_consumer<T,
+ typename detail::enable_if_defined<typename consumer_category_of<T>::type>::type >
+ : public boost::true_type {};
+
+} } // namespace boost::dataflow
+
+#endif // BOOST_DATAFLOW_SUPPORT_CONSUMER_HPP
Added: sandbox/SOC/2007/signals/boost/dataflow/support/invocable.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/invocable.hpp 2007-08-03 19:20:40 EDT (Fri, 03 Aug 2007)
@@ -0,0 +1,92 @@
+// 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)
+
+#ifndef BOOST_DATAFLOW_SUPPORT_INVOCABLE_HPP
+#define BOOST_DATAFLOW_SUPPORT_INVOCABLE_HPP
+
+#include <boost/dataflow/detail/enable_if_defined.hpp>
+
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+
+
+namespace boost { namespace dataflow {
+
+struct functor_invocable;
+
+template<typename T, typename Enable=void>
+struct is_invocable
+ : public boost::false_type {};
+
+template<typename T, typename Enable=void>
+struct invocable_category_of;
+
+template<typename T>
+struct invocable_category_of<
+ T,
+ typename detail::enable_if_defined<typename T::invocable_category>::type >
+{
+ typedef typename T::invocable_category type;
+};
+
+template<typename T>
+struct is_invocable<
+ T,
+ typename detail::enable_if_defined<invocable_category_of<T> >::type >
+: public boost::true_type {};
+
+namespace extension
+{
+ template<typename InvocableTag, typename Enable=void>
+ struct invoke_impl
+ {
+ template<typename Invocable>
+ struct apply
+ {
+ static void call(Invocable &)
+ {
+ // Error: invoke_impl has not been implemented for InvocableTag.
+ BOOST_STATIC_ASSERT(sizeof(Invocable)==0);
+ }
+ };
+ };
+
+ template<>
+ struct invoke_impl<boost::dataflow::functor_invocable>
+ {
+ template<typename Invocable>
+ struct apply
+ {
+ static void call(Invocable &invocable)
+ {
+ invocable();
+ }
+ static void call(const Invocable &invocable)
+ {
+ invocable();
+ }
+ };
+ };
+}
+
+template<typename Invocable>
+typename boost::enable_if<is_invocable<Invocable> >::type
+invoke(Invocable &invocable)
+{
+ extension::invoke_impl<typename invocable_category_of<Invocable>::type>
+ ::template apply<Invocable>::call(invocable);
+}
+
+template<typename Invocable>
+typename boost::enable_if<is_invocable<Invocable> >::type
+invoke(const Invocable &invocable)
+{
+ extension::invoke_impl<typename invocable_category_of<Invocable>::type>
+ ::template apply<Invocable>::call(invocable);
+}
+
+} } // namespace boost::dataflow
+
+#endif // BOOST_DATAFLOW_SUPPORT_INVOCABLE_HPP
Added: sandbox/SOC/2007/signals/boost/dataflow/support/producer.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/producer.hpp 2007-08-03 19:20:40 EDT (Fri, 03 Aug 2007)
@@ -0,0 +1,60 @@
+// 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)
+
+#ifndef BOOST_DATAFLOW_SUPPORT_PRODUCER_HPP
+#define BOOST_DATAFLOW_SUPPORT_PRODUCER_HPP
+
+#include <boost/dataflow/detail/enable_if_defined.hpp>
+
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+
+
+namespace boost { namespace dataflow {
+
+// trait giving the producer category of a type.
+template<typename T, typename Enable=void>
+struct producer_category_of
+{
+ // Error: attempting to use T as a producer, but producer_category_of<T>
+ // has not been specialized!
+ BOOST_STATIC_ASSERT(sizeof(T)==0);
+};
+
+template<typename T>
+struct producer_category_of<T,
+typename detail::enable_if_defined<typename T::producer_category >::type >
+{
+ typedef typename T::producer_category type;
+};
+
+// trait determining whether a type is a producer.
+template<typename T, typename Enable=void>
+struct is_producer
+ : public boost::false_type {};
+
+template<typename T>
+struct is_producer<T,
+ typename detail::enable_if_defined<typename producer_category_of<T>::type >::type >
+ : public boost::true_type {};
+
+template<typename T, typename Enable=void>
+struct produced_type_of
+{
+ // Error: attempting to use T as a producer, but produced_type_of<T>
+ // has not been specialized!
+ BOOST_STATIC_ASSERT(sizeof(T)==0);
+};
+
+template<typename T>
+struct produced_type_of<T,
+typename detail::enable_if_defined<typename T::produced_type>::type >
+{
+ typedef typename T::produced_type type;
+};
+
+} } // namespace boost::dataflow
+
+#endif // BOOST_DATAFLOW_SUPPORT_PRODUCER_HPP
Copied: sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk (from r7551, /sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network.qbk)
==============================================================================
--- /sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk 2007-08-03 19:20:40 EDT (Fri, 03 Aug 2007)
@@ -1,4 +1,4 @@
-[library Signal Network
+[article Dataflow
[quickbook 1.4]
[version 0.1]
[authors [Rajko, Stjepan]]
@@ -11,27 +11,46 @@
]
]
-[def __connect__ [link signal_network.connections.connect connect]]
-[def __components__ [link signal_network.components components]]
-[def __operators__ [link signal_network.connections.operators operators]]
-
-[def __slot_selector__ [link signal_network.connections.classes.slot_selector slot_selector]]
-
-[def __filter__ [link signal_network.components.generic.filter filter]]
-[def __applicator__ [link signal_network.components.generic.applicator applicator]]
-[def __conditional__ [link signal_network.components.generic.conditional conditional]]
-[def __instantiator__ [link signal_network.components.generic.instantiator instantiator]]
-[def __modifier__ [link signal_network.components.generic.modifier modifier]]
-[def __storage__ [link signal_network.components.properties.storage storage]]
-[def __counter__ [link signal_network.components.properties.counter counter]]
-[def __junction__ [link signal_network.components.flow.junction junction]]
-[def __mutex__ [link signal_network.components.flow.mutex mutex]]
-[def __function__ [link signal_network.components.adapters.function function]]
-[def __socket_sender__ [link signal_network.components.network.socket_sender socket_sender]]
-[def __socket_receiver__ [link signal_network.components.network.socket_receiver socket_receiver]]
-[def __chain__ [link signal_network.components.topologies.chain chain]]
-
-[def __fusion__ [@http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/index.html Boost.Fusion]]
+[template ProducerConcept[] [link dataflow.concepts.producer [^Producer]]]
+[template ConsumerConcept[] [link dataflow.concepts.consumer [^Consumer]]]
+[template InvocableConcept[] [link dataflow.concepts.invocable [^Invocable]]]
+[template ConnectableConcept[] [link dataflow.concepts.connectable [^Connectable]]]
+[template SignalProducerConcept[] [link dataflow.signals.concepts.signalproducer [^SignalProducer]]]
+[template SignalConsumerConcept[] [link dataflow.signals.concepts.signalconsumer [^SignalConsumer]]]
+[template PhoenixProducerConcept[] [link dataflow.concepts.phoenix.phoenixproducer [^PhoenixProducer]]]
+[template PhoenixConsumerConcept[] [link dataflow.concepts.phoenix.phoenixproducer [^PhoenixConsumer]]]
+
+[template organization[] [link dataflow.introduction.organization organization]]
+[template DataflowSignals[] [link dataflow.introduction.mechanisms.signals Dataflow.Signals]]
+[template DataflowPhoenix[] [link dataflow.introduction.mechanisms.phoenix Dataflow.Phoenix]]
+
+[template signals_quickstart[] [link dataflow.signals.introduction.quick_start quick start]]
+[template connect[] [link dataflow.signals.connections.connect connect]]
+[template components[] [link dataflow.signals.components components]]
+[template operators[] [link dataflow.signals.connections.operators operators]]
+
+[template slot_selector[] [link dataflow.signals.connections.classes.slot_selector slot_selector]]
+
+[template filter[] [link dataflow.signals.components.generic.filter filter]]
+[template applicator[] [link dataflow.signals.components.generic.applicator applicator]]
+[template conditional[] [link dataflow.signals.components.generic.conditional conditional]]
+[template instantiator[] [link dataflow.signals.components.generic.instantiator instantiator]]
+[template modifier[] [link dataflow.signals.components.generic.modifier modifier]]
+[template storage[] [link dataflow.signals.components.properties.storage storage]]
+[template counter[] [link dataflow.signals.components.properties.counter counter]]
+[template junction[] [link dataflow.signals.components.flow.junction junction]]
+[template mutex[] [link dataflow.signals.components.flow.mutex mutex]]
+[template function[] [link dataflow.signals.components.adapters.function function]]
+[template socket_sender[] [link dataflow.signals.components.network.socket_sender socket_sender]]
+[template socket_receiver[] [link dataflow.signals.components.network.socket_receiver socket_receiver]]
+[template chain[] [link dataflow.signals.components.topologies.chain chain]]
+
+[template fusion[] [@http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/index.html Boost.Fusion]]
+[template BoostFusion[] [@http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/index.html Boost.Fusion]]
+[template BoostSignals[] [@http://www.boost.org/doc/html/signals.html Boost.Signals]]
+[template BoostPhoenix2[] [@http://spirit.sourceforge.net/ Boost.Phoenix2]]
+[template BoostPhoenix[] [@http://spirit.sourceforge.net/ Boost.Phoenix]]
+[template WikiDataflow[] [@http://en.wikipedia.org/wiki/Dataflow_language dataflow]]
[import ../test/test_connect.cpp]
[import ../test/test_branching.cpp]
@@ -48,26 +67,51 @@
[import ../test/test_chain.cpp]
[import ../test/test_socket.cpp]
-The Signal Network library aims to facilitate the
-implementation and interconnection of objects into signal networks using Boost.Signals.
-To see the rationale behind the Signal Network library, please visit the associated
-[@http://svn.boost.org/trac/boost/wiki/soc/2007/SignalNetwork GSoC page].
-
-[warning Signal Network is not a part of the Boost libraries. It is being developed
-as a part of Google Summer of Code program.]
+[import ../example/fibonacci.cpp]
+[import ../example/simple_example.cpp]
-* If you would like some more information about why one would want to connect objects into a signal-based
- network, read my exploration of [link signal_network.introduction.dataflow Dataflow-oriented programming approaches in C++].
+Dataflow is a generic library for [WikiDataflow] programming using various data
+transport mechanisms. The Dataflow library
+comes with support for two data transport mechanisms - one is based on
+[BoostSignals], and the other (experimental) is based connections made through
+simple object pointers, with support for using [BoostPhoenix2]
+actors for data processing.
+
+The two data transport mechanisms are implemented in the [DataflowSignals]
+and [DataflowPhoenix] modules. 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].]
+
+* If you would like some more information about why one would want to connect
+ objects into a signal-based network, read about
+ [link dataflow.introduction.dataflow Dataflow programming in C++].
* If you'd like to try out the library
* keep in mind that the interface is highly unstable at this point
- * see the [link signal_network.introduction.start Quick Start] section.
+ * see the [link dataflow.introduction.start Quick Start] section.
* If you are interested in the progress of the implementation, see
- * News section of the [@http://svn.boost.org/trac/boost/wiki/soc/2007/SignalNetwork Signal Network GSoC page]
- * [link signal_network.discussion Discussion on Boost Community Feedback]
- * [link signal_network.download Download and Changelog]
+ * News section of the
+ [@http://svn.boost.org/trac/boost/wiki/soc/2007/SignalNetwork Dataflow GSoC page]
+ * [link dataflow.discussion Discussion on Boost Community Feedback]
+ * [link dataflow.download Download and Changelog]
[include introduction.qbk]
+[include concepts.qbk]
+
+[include signals.qbk]
+
+[include phoenix.qbk]
+
+[section Development]
+
+[include rationale.qbk]
+
[section:discussion Discussion on Boost Community Feedback]
The following summarizes some of the suggestions / comments given by the Boost community, and
@@ -75,7 +119,7 @@
[* Tobias Schwinger indicated that the library could be used for pulling rather than pushing data.]
-* [link signal_network.connections.pull An example] which illustrates this has been addded.
+* [link dataflow.connections.pull An example] which illustrates this has been addded.
[* James Jones suggested that a ||-like operator could be used for branching, and >> for chaining.]
@@ -87,13 +131,13 @@
[* Paolo Coletta suggested a "video_generator >>= ( effect1 && effect2 ) >>= image_sum" - like syntax that
would allow parallel processing of signals (identified as the "join" pattern by Yigong Liu)]
-* I have started to implement thread-related components in __timed_generator__ and __mutex__.
+* I have started to implement thread-related components in [timed_generator] and [mutex].
More sophisticated threading components, control and syntax to follow.
[* Yigong Liu suggested enhanced support for common network topologies, such as mesh. ]
* I have implemented a prototype
-__chain__ topology
+[chain] topology
to get a start on this concept.
[* Braddock Gaskill pointed out the relationship with the "pipes and filters" pattern, and suggested
@@ -104,10 +148,10 @@
* In light of the possible connection with the "pipes and filters" pattern, the base
object for signal network components which receive a signal and send a signal has
- been changed to __filter__.
+ been changed to [filter].
I was not successful in finding a formal definition
of what "pipes and filters" semantics should be, so I am not sure whether this is appropriate.
-* __function__
+* [function]
now offers the proposed functionality of converting functions into filters.
* Threading and scheduling of the invoked functions is something I plan to address.
* Providing a call graph would be a great feature, but I am not sure what the best
@@ -143,23 +187,17 @@
[endsect]
-[include support.qbk]
-
-[include connections.qbk]
-
-[include components.qbk]
-
-[include rationale.qbk]
+[endsect]
-[xinclude signal_network_doxygen.xml]
+[xinclude dataflow_doxygen.xml]
[section:acknowledgements Acknowledgements]
* Thanks to Douglas Gregor for making himself available as a mentor for this project, and for his support, suggestions and feedback.
* Thanks to all the members of the Boost community who have expressed an interest in this library
- and contributed [link signal_network.discussion valuable feedback].
-* Thanks to Tobias Schwinger for a most valuable discussion on various [link signal_network.introduction.generic_dataflow
- dataflow-oriented approaches and ideas].
+ and contributed [link dataflow.discussion valuable feedback].
+* Thanks to Tobias Schwinger for a most valuable discussion on various
+ dataflow-oriented approaches and ideas.
[endsect]
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