|
Boost-Commit : |
From: stipe_at_[hidden]
Date: 2007-10-10 16:28:23
Author: srajko
Date: 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
New Revision: 39908
URL: http://svn.boost.org/trac/boost/changeset/39908
Log:
VTK is now an example
Added:
sandbox/SOC/2007/signals/boost/dataflow/support/disconnect_all_ins.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/support/disconnect_all_outs.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/support/header.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/support/keyed_consumer.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/support/keyed_producer.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/support/only_connectable.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/support/port.hpp (contents, props changed)
sandbox/SOC/2007/signals/boost/dataflow/templates/
sandbox/SOC/2007/signals/boost/dataflow/templates/connect.hpp (contents, props changed)
sandbox/SOC/2007/signals/libs/dataflow/doc/future.qbk (contents, props changed)
sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Cone2.cxx (contents, props changed)
sandbox/SOC/2007/signals/libs/dataflow/example/VTK/operators.hpp (contents, props changed)
sandbox/SOC/2007/signals/libs/dataflow/example/VTK/support.hpp
- copied, changed from r39491, /sandbox/SOC/2007/signals/boost/dataflow/VTK/support.hpp
Removed:
sandbox/SOC/2007/signals/boost/dataflow/VTK/
Text files modified:
sandbox/SOC/2007/signals/boost/dataflow/connection/consumer_map.hpp | 64 +---
sandbox/SOC/2007/signals/boost/dataflow/connection/producer_map.hpp | 58 +--
sandbox/SOC/2007/signals/boost/dataflow/signal/component/filter_base.hpp | 7
sandbox/SOC/2007/signals/boost/dataflow/signal/component/storage.hpp | 20
sandbox/SOC/2007/signals/boost/dataflow/signal/connection/detail/bind_object.hpp | 4
sandbox/SOC/2007/signals/boost/dataflow/signal/connection/slot_selector.hpp | 65 +++
sandbox/SOC/2007/signals/boost/dataflow/signal/support.hpp | 122 +++++---
sandbox/SOC/2007/signals/boost/dataflow/support.hpp | 3
sandbox/SOC/2007/signals/boost/dataflow/support/common.hpp | 7
sandbox/SOC/2007/signals/boost/dataflow/support/connectable.hpp | 93 ++----
sandbox/SOC/2007/signals/boost/dataflow/support/consumer.hpp | 95 +++----
sandbox/SOC/2007/signals/boost/dataflow/support/filter.hpp | 17 +
sandbox/SOC/2007/signals/boost/dataflow/support/invocable.hpp | 6
sandbox/SOC/2007/signals/boost/dataflow/support/producer.hpp | 112 +++----
sandbox/SOC/2007/signals/boost/dataflow/support/proxy_consumer.hpp | 205 ++++++++-------
sandbox/SOC/2007/signals/boost/dataflow/support/proxy_producer.hpp | 218 ++++++++-------
sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/signal_network.xcodeproj/project.pbxproj | 50 +++
sandbox/SOC/2007/signals/libs/dataflow/doc/Jamfile.v2 | 4
sandbox/SOC/2007/signals/libs/dataflow/doc/concepts.qbk | 49 +++
sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk | 41 ++
sandbox/SOC/2007/signals/libs/dataflow/doc/introduction.qbk | 533 ++++++++++++++++++++++++++-------------
sandbox/SOC/2007/signals/libs/dataflow/doc/phoenix.qbk | 13
sandbox/SOC/2007/signals/libs/dataflow/doc/producer_concepts.qbk | 3
sandbox/SOC/2007/signals/libs/dataflow/doc/signals.qbk | 32 ++
sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Cone.cxx | 11
sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Jamfile.v2 | 5
sandbox/SOC/2007/signals/libs/dataflow/example/VTK/support.hpp | 379 ++++++++++++++++++----------
sandbox/SOC/2007/signals/libs/dataflow/test/signals/test_storage.cpp | 3
28 files changed, 1336 insertions(+), 883 deletions(-)
Modified: sandbox/SOC/2007/signals/boost/dataflow/connection/consumer_map.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/connection/consumer_map.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/connection/consumer_map.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -9,6 +9,7 @@
#include <boost/dataflow/support.hpp>
#include <boost/mpl/not.hpp>
+#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/sequence/container/vector.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
@@ -19,10 +20,12 @@
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/result_of.hpp>
+#include <boost/call_traits.hpp>
namespace boost { namespace dataflow {
-struct fusion_map_consumer {};
+struct fusion_map_consumer
+ : public consumer_category<concepts::keyed_consumer> {};
template<class T>
struct consumer_map : public T
@@ -32,15 +35,17 @@
struct dataflow
{
typedef fusion_map_consumer consumer_category;
+/* typedef typename boost::fusion::result_of::value_at_c<T, 0>::type::second_type
+ proxy_producer_for;*/
typedef
typename boost::remove_const<
typename boost::remove_reference<
typename boost::fusion::result_of::front<T>::type
>::type
>::type::second_type proxy_producer_for;
- typedef mutable_proxy_producer proxy_producer_category;
-
- static typename get_proxied_producer_type<Mechanism, proxy_producer_for>::type &get_proxied_producer(const T &t)
+ typedef mutable_proxy_producer<proxy_producer_for> proxy_producer_category;
+
+ static typename get_proxied_producer_result_type<Mechanism, proxy_producer_for>::type get_proxied_producer(const T &t)
{
return boost::dataflow::get_proxied_producer<Mechanism>(boost::fusion::front(t).second);
}
@@ -49,49 +54,24 @@
namespace extension
{
- // component >>= consumer_map
- template<typename Mechanism, typename ProducerTag, typename ConsumerTag>
- struct connect_impl<Mechanism, ProducerTag, ConsumerTag,
- typename boost::enable_if<//boost::mpl::and_<
- //is_producer<ProducerTag>,
- boost::is_base_of<fusion_map_consumer, ConsumerTag>
- /*>*/ >::type >
+ template<typename Mechanism, typename ProducerTag>
+ struct get_keyed_consumer_impl<Mechanism, ProducerTag, fusion_map_consumer>
{
- template<typename Producer, typename Consumer>
+ template<typename Producer, typename KeyedConsumer>
struct apply
{
- static void call(const Producer &producer, const Consumer &consumer)
- {
- connect(
- producer,
- boost::fusion::at_key<
- typename produced_type_of<Mechanism, Producer>::type
- >(consumer));
- }
- static void call(const Producer &producer, Consumer &consumer)
- {
- connect(
- producer,
- boost::fusion::at_key<
- typename produced_type_of<Mechanism, Producer>::type
- >(consumer));
- }
- static void call(Producer &producer, const Consumer &consumer)
+ typedef typename boost::fusion::result_of::at_key<
+ KeyedConsumer,
+ ProducerTag
+ >::type type;
+
+ static type
+ call(Producer &, KeyedConsumer &consumer)
{
- connect(
- producer,
- boost::fusion::at_key<
- typename produced_type_of<Mechanism, Producer>::type
- >(consumer));
+ return boost::fusion::at_key<
+ ProducerTag
+ >(consumer);
}
- static void call(Producer &producer, Consumer &consumer)
- {
- connect(
- producer,
- boost::fusion::at_key<
- typename produced_type_of<Mechanism, Producer>::type
- >(consumer));
- }
};
};
}
Modified: sandbox/SOC/2007/signals/boost/dataflow/connection/producer_map.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/connection/producer_map.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/connection/producer_map.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -9,6 +9,7 @@
#include <boost/dataflow/support.hpp>
#include <boost/mpl/not.hpp>
+#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/sequence/container/vector.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
@@ -23,7 +24,8 @@
namespace boost { namespace dataflow {
-struct fusion_map_producer {};
+struct fusion_map_producer
+ : public producer_category<concepts::keyed_producer> {};
template<class T>
struct producer_map : public T
@@ -33,13 +35,15 @@
struct dataflow
{
typedef fusion_map_producer producer_category;
+/* typedef typename boost::fusion::result_of::value_at_c<T, 0>::type::second_type
+ proxy_consumer_for;*/
typedef
typename boost::remove_const<
typename boost::remove_reference<
typename boost::fusion::result_of::front<T>::type
>::type
>::type::second_type proxy_consumer_for;
- typedef mutable_proxy_consumer proxy_consumer_category;
+ typedef mutable_proxy_consumer<proxy_consumer_for> proxy_consumer_category;
static typename boost::call_traits<typename get_proxied_consumer_type<Mechanism, proxy_consumer_for>::type>::reference get_proxied_consumer(const T &t)
{
@@ -50,48 +54,24 @@
namespace extension
{
- // component >>= coxsumer_map
- template<typename Mechanism, typename ProducerTag, typename ConsumerTag>
- struct connect_impl<Mechanism, ProducerTag, ConsumerTag,
- typename boost::enable_if<
- boost::is_base_of<fusion_map_producer, ProducerTag>
- >::type >
+ template<typename Mechanism, typename ConsumerTag>
+ struct get_keyed_producer_impl<Mechanism, fusion_map_producer, ConsumerTag>
{
- template<typename Producer, typename Consumer>
+ template<typename KeyedProducer, typename Consumer>
struct apply
{
- static void call(const Producer &producer, const Consumer &consumer)
- {
- connect(
- boost::fusion::at_key<
- typename consumed_type_of<Mechanism, Consumer>::type
- >(producer),
- consumer);
- }
- static void call(const Producer &producer, Consumer &consumer)
- {
- connect(
- boost::fusion::at_key<
- typename consumed_type_of<Mechanism, Consumer>::type
- >(producer),
- consumer);
- }
- static void call(Producer &producer, const Consumer &consumer)
+ typedef typename boost::fusion::result_of::at_key<
+ KeyedProducer,
+ ConsumerTag
+ >::type type;
+
+ static type
+ call(KeyedProducer &producer, Consumer &)
{
- connect(
- boost::fusion::at_key<
- typename consumed_type_of<Mechanism, Consumer>::type
- >(producer),
- consumer);
+ return boost::fusion::at_key<
+ ConsumerTag
+ >(producer);
}
- static void call(Producer &producer, Consumer &consumer)
- {
- connect(
- boost::fusion::at_key<
- typename consumed_type_of<Mechanism, Consumer>::type
- >(producer),
- consumer);
- }
};
};
}
Modified: sandbox/SOC/2007/signals/boost/dataflow/signal/component/filter_base.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signal/component/filter_base.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signal/component/filter_base.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -38,12 +38,11 @@
>::type>
{
typedef boost::dataflow::signal_consumer consumer_category;
- typedef boost::dataflow::mutable_proxy_producer proxy_producer_category;
- typedef Signal proxy_producer_for;
+ typedef boost::dataflow::mutable_proxy_producer<Signal> proxy_producer_category;
template<typename T>
- static typename boost::dataflow::get_proxied_producer_type<boost::dataflow::signals_mechanism, Signal>
- ::type &get_proxied_producer(const T &t)
+ static typename boost::dataflow::get_proxied_producer_result_type<boost::dataflow::signals_mechanism, Signal>
+ ::type get_proxied_producer(T &t)
{ return t.get_proxied_producer(); }
};
Modified: sandbox/SOC/2007/signals/boost/dataflow/signal/component/storage.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signal/component/storage.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signal/component/storage.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -148,18 +148,18 @@
return boost::fusion::at_c<N>(base_type::modification.stored);
}
- boost::dataflow::consumer_map<boost::fusion::map<
- boost::fusion::pair<void(), slot_selector<void (), storage> >,
- boost::fusion::pair<void(const boost::fusion::vector<> &),
- slot_selector<void (const boost::fusion::vector<> &), storage> > >
- >
+ typedef boost::fusion::map<
+ boost::fusion::pair<boost::dataflow::signal_producer<void()>, slot_selector<void (), storage> >,
+ boost::fusion::pair<
+ boost::dataflow::signal_producer<void(const boost::fusion::vector<> &)>,
+ slot_selector<void (const boost::fusion::vector<> &), storage>
+ >
+ > send_map;
+
+ boost::dataflow::consumer_map<send_map>
send_slot()
{
- return boost::fusion::map<
- boost::fusion::pair<void(), slot_selector<void (), storage> >,
- boost::fusion::pair<void(const boost::fusion::vector<> &),
- slot_selector<void (const boost::fusion::vector<> &), storage> >
- >
+ return send_map
(make_slot_selector<void ()> (&storage::send, *this),
make_slot_selector<void (const boost::fusion::vector<> &)> (&storage::send, *this));
}
Modified: sandbox/SOC/2007/signals/boost/dataflow/signal/connection/detail/bind_object.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signal/connection/detail/bind_object.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signal/connection/detail/bind_object.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -46,12 +46,12 @@
BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_INC(BOOST_PP_ITERATION()),_));
}
- boost::function<Signature> operator()(typename slot_type<Signature, T>::type mem_fn, const T &object)
+ /*boost::function<Signature> operator()(typename slot_type<Signature, T>::type mem_fn, const T &object)
{
return boost::bind(mem_fn, boost::ref(object)
BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_INC(BOOST_PP_ITERATION()),_));
- }
+ }*/
};
#endif // defined(BOOST_PP_IS_ITERATING)
Modified: sandbox/SOC/2007/signals/boost/dataflow/signal/connection/slot_selector.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signal/connection/slot_selector.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signal/connection/slot_selector.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -16,11 +16,35 @@
namespace boost { namespace signals {
+struct slot_selector_consumer
+ : public boost::dataflow::consumer_category<boost::dataflow::concepts::keyed_consumer> {};
+
+
/** \brief Reference to a class instance and pointer to a class member function.
*/
template<typename Signature, typename T>
-struct slot_selector : public filter_base<T>
+struct slot_selector
{
+ template<typename Mechanism, typename Enable=void>
+ struct dataflow;
+
+ template<typename Mechanism>
+ struct dataflow<
+ Mechanism,
+ typename enable_if<
+ is_same<Mechanism, boost::dataflow::signals_mechanism>
+ >::type>
+ {
+ typedef slot_selector_consumer consumer_category;
+ typedef boost::dataflow::mutable_proxy_producer<T> proxy_producer_category;
+
+ static typename boost::dataflow::get_proxied_producer_result_type<boost::dataflow::signals_mechanism, T>::type
+ get_proxied_producer(const slot_selector<Signature, T> &t)
+ {
+ return boost::dataflow::get_proxied_producer<boost::dataflow::signals_mechanism>(t.object);
+ };
+ };
+
typedef Signature signature_type;
typedef T class_type;
@@ -29,9 +53,6 @@
slot_selector(typename detail::slot_type<Signature, T>::type func, T &object)
: object(object), func(func) {}
-
- typename boost::dataflow::get_proxied_producer_type<boost::dataflow::signals_mechanism, T>::type &get_proxied_producer() const
- { return boost::dataflow::get_proxied_producer<boost::dataflow::signals_mechanism>(object); }
};
/** \brief Allows arbitrary member functions to serve as slots.
@@ -46,8 +67,26 @@
namespace boost { namespace dataflow {
- namespace extension { namespace signals {
-/*
+namespace extension {
+
+ template<typename Signature>
+ struct get_keyed_consumer_impl<signals_mechanism, signal_producer<Signature>,
+ boost::signals::slot_selector_consumer>
+ {
+ template<typename Producer, typename Consumer>
+ struct apply
+ {
+ typedef const boost::function<Signature> type;
+
+ static type call(Producer &, Consumer &consumer)
+ {
+ return boost::signals::detail::bind_object<Signature, typename Consumer::class_type>()
+ (static_cast<typename boost::signals::detail::slot_type<Signature, typename Consumer::class_type>::type>(consumer.func), consumer.object);
+ }
+ };
+ };
+
+ /*
/// Support for slot_selector as an input component (producer).
template<typename Signature, typename T>
struct is_component<slot_selector<Signature, T> >
@@ -55,24 +94,24 @@
*/
/// Support for slot_selector as an input component (producer).
-template<typename Signature, typename T>
+/*template<typename Signature, typename T>
struct get_signal<boost::signals::slot_selector<Signature, T> >
{
typename get_signal_type<T>::type &operator()(const boost::signals::slot_selector<Signature, T> &selector)
{
return selector.object.default_signal();
}
-};
+};*/
/// Support for slot_selector as an input component (producer).
-template<typename Signature, typename T>
+/*template<typename Signature, typename T>
struct get_signal_type<boost::signals::slot_selector<Signature, T> >
{
typedef typename get_signal_type<T>::type type;
-};
+};*/
/// Support for slot_selector as an output component (consumer).
-template<typename Signature, typename T>
+/*template<typename Signature, typename T>
struct get_slot<Signature, boost::signals::slot_selector<Signature, T> >
{
boost::function<Signature> operator()(const boost::signals::slot_selector<Signature, T> &selector)
@@ -80,9 +119,9 @@
return boost::signals::detail::bind_object<Signature, T>()
(static_cast<typename boost::signals::detail::slot_type<Signature, T>::type>(selector.func), selector.object);
}
-};
+};*/
-} }
+}
} } // namespace boost::signals
Modified: sandbox/SOC/2007/signals/boost/dataflow/signal/support.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signal/support.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signal/support.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -30,53 +30,100 @@
};
}
-} } // namespace boost::signals
+} } // namespace boost::signals
namespace boost { namespace dataflow {
-struct signal_producer {};
-struct signal_consumer {};
+template<typename T>
+struct signal_producer
+ : public producer_category<concepts::producer, connections::many>
+{
+ typedef T produced_signature_type;
+};
+
+struct signal_consumer
+ : public consumer_category<concepts::keyed_consumer> {};
+
+template<typename T>
+struct function_consumer
+ : public consumer_category<concepts::consumer>
+{
+ typedef T consumed_signature_type;
+};
+
+//struct signal_keyed_consumer
+// : public consumer_category<concepts::keyed_consumer> {};
+
struct signals_mechanism;
template<typename Signature, typename Combiner, typename Group, typename GroupCompare>
struct producer_category_of<signals_mechanism, boost::signal<Signature, Combiner, Group, GroupCompare> >
{
- typedef signal_producer type;
+ typedef signal_producer<Signature> type;
+};
+
+template<typename Signature>
+struct consumer_category_of<signals_mechanism, boost::function<Signature> >
+{
+ typedef function_consumer<Signature> type;
};
+//template<typename T>
+//struct consumer_category_of<signals_mechanism, T>
+//{
+// typedef signal_consumer type;
+//};
+
namespace extension
{
+ template<typename Signature>
+ struct get_keyed_consumer_impl<signals_mechanism, signal_producer<Signature>,
+ signal_consumer>
+ {
+ template<typename Producer, typename Consumer>
+ struct apply
+ {
+ typedef const boost::function<Signature> type;
+
+ static type call(Producer &, Consumer &consumer)
+ {
+ return boost::signals::detail::bind_object<Signature, Consumer>()
+ (static_cast<typename boost::signals::detail::slot_type<Signature, Consumer>::type>(&Consumer::operator()), consumer);
+ };
+ };
+ };
+
namespace signals
{
- template<class T, typename Enable=void>
+/* template<class T, typename Enable=void>
struct get_signal;
template<typename T, typename Enable=void>
struct get_signal_type;
template<typename Signature, typename T, typename Enable=void>
- struct get_slot;
+ struct get_slot;*/
/** \brief Support for boost::signal.
*/
- template<typename Signature, typename Combiner, typename Group, typename GroupCompare>
+/* template<typename Signature, typename Combiner, typename Group, typename GroupCompare>
struct get_signal<boost::signal<Signature, Combiner, Group, GroupCompare> >
{
boost::signal<Signature, Combiner, Group, GroupCompare> & operator()
(boost::signal<Signature, Combiner, Group, GroupCompare> &s) {return s;}
- };
+ };*/
/** \brief Support for boost::signal.
*/
- template<typename Signature, typename Combiner, typename Group, typename GroupCompare>
+ /*template<typename Signature, typename Combiner, typename Group, typename GroupCompare>
struct get_signal_type<boost::signal<Signature, Combiner, Group, GroupCompare> >
{
typedef boost::signal<Signature, Combiner, Group, GroupCompare> type;
- };
+ };*/
/** \brief Support for function objects that for which boost::result_of is defined.
*/
- template<typename Signature, typename T>
+ /*template<typename Signature, typename T>
struct get_slot<Signature, T, typename boost::enable_if<boost::signals::detail::result_of_defined<
typename boost::signals::detail::replace_return_type<Signature, T>::type > >::type>
{
@@ -90,7 +137,7 @@
return boost::signals::detail::bind_object<Signature, T>()
(static_cast<typename boost::signals::detail::slot_type<Signature, T>::type>(&T::operator()), object);
}
- };
+ };*/
/** \brief Support for function objects that for which boost::result_of is defined.
*/
@@ -102,7 +149,7 @@
};*/
}
- template<typename ProducerTag, typename ConsumerTag>
+ /*template<typename ProducerTag, typename ConsumerTag>
struct connect_impl<signals_mechanism, ProducerTag, ConsumerTag,
typename boost::enable_if<boost::mpl::and_<
boost::is_base_of<signal_producer, ProducerTag>,
@@ -112,29 +159,24 @@
template<typename Producer, typename Consumer>
struct apply
{
- static void call(const Producer &producer, const Consumer &consumer)
- {
- signals::get_signal<Producer>()(producer).connect(
- signals::get_slot<typename dataflow::produced_type_of<
- signals_mechanism, Producer>::type, Consumer>()(consumer));
- }
- static void call(const Producer &producer, Consumer &consumer)
- {
- signals::get_signal<Producer>()(producer).connect(
- signals::get_slot<typename dataflow::produced_type_of<
- signals_mechanism, Producer>::type, Consumer>()(consumer));
- }
- static void call(Producer &producer, const Consumer &consumer)
+ static void call(Producer &producer, Consumer &consumer)
{
signals::get_signal<Producer>()(producer).connect(
signals::get_slot<typename dataflow::produced_type_of<
signals_mechanism, Producer>::type, Consumer>()(consumer));
}
+ };
+ };*/
+
+ template<typename T>
+ struct connect_impl<signals_mechanism, signal_producer<T>, function_consumer<T> >
+ {
+ template<typename Producer, typename Consumer>
+ struct apply
+ {
static void call(Producer &producer, Consumer &consumer)
{
- signals::get_signal<Producer>()(producer).connect(
- signals::get_slot<typename dataflow::produced_type_of<
- signals_mechanism, Producer>::type, Consumer>()(consumer));
+ producer.connect(consumer);
}
};
};
@@ -154,13 +196,13 @@
typedef typename boost::signals::detail::get_signature<typename extension::signals::get_signal_type<T>::type>::type type;
};*/
-template<typename Signature, typename Combiner, typename Group, typename GroupCompare>
+/*template<typename Signature, typename Combiner, typename Group, typename GroupCompare>
struct produced_type_of<
signals_mechanism,
boost::signal<Signature, Combiner, Group, GroupCompare> >
{
typedef Signature type;
-};
+};*/
} } // namespace boost::dataflow
@@ -171,24 +213,6 @@
{
boost::dataflow::connect<boost::dataflow::signals_mechanism>(producer, consumer);
}
-
-template<typename Producer, typename Consumer>
-inline void connect(const Producer &producer, Consumer &consumer)
-{
- boost::dataflow::connect<boost::dataflow::signals_mechanism>(producer, consumer);
-}
-
-template<typename Producer, typename Consumer>
-inline void connect(Producer &producer, const Consumer &consumer)
-{
- boost::dataflow::connect<boost::dataflow::signals_mechanism>(producer, consumer);
-}
-
-template<typename Producer, typename Consumer>
-inline void connect(const Producer &producer, const Consumer &consumer)
-{
- boost::dataflow::connect<boost::dataflow::signals_mechanism>(producer, consumer);
-}
} } // namespace boost::phoenix
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-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -13,5 +13,8 @@
#include <boost/dataflow/support/filter.hpp>
#include <boost/dataflow/support/invocable.hpp>
#include <boost/dataflow/support/connectable.hpp>
+#include <boost/dataflow/support/only_connectable.hpp>
+#include <boost/dataflow/support/disconnect_all_ins.hpp>
+#include <boost/dataflow/support/disconnect_all_outs.hpp>
#endif // BOOST_DATAFLOW_SUPPORT_HPP
Modified: sandbox/SOC/2007/signals/boost/dataflow/support/common.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/common.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/common.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -11,6 +11,13 @@
/// Tag describing that dataflow properties should apply to all mechanisms.
struct all_mechanisms;
+namespace connections
+{
+ struct none;
+ struct one;
+ struct many;
+}
+
} } // namespace boost::dataflow
#endif // BOOST_DATAFLOW_SUPPORT_COMMON_HPP
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/boost/dataflow/support/connectable.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/connectable.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/connectable.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -8,19 +8,15 @@
#include <boost/dataflow/support/proxy_producer.hpp>
#include <boost/dataflow/support/proxy_consumer.hpp>
+#include <boost/dataflow/support/keyed_producer.hpp>
+#include <boost/dataflow/support/keyed_consumer.hpp>
#include <boost/static_assert.hpp>
+#include <boost/type_traits/remove_reference.hpp>
namespace boost { namespace dataflow {
-/*namespace concepts
-{
- struct producer;
- struct single_type_producer;
- struct keyed_producer;
-}*/
-
namespace extension
{
template<typename Mechanism, typename ProducerTag, typename ConsumerTag, typename Enable=void>
@@ -38,11 +34,11 @@
};
};
-/* template<typename Mechanism, typename ProducerTag, typename ConsumerTag,
- typename enable_if<
- boost::is_same<ProducerTag, typename concepts::keyed_producer>
+ template<typename Mechanism, typename ProducerTag, typename ConsumerTag>
+ struct connect_impl<Mechanism, ProducerTag, ConsumerTag,
+ typename enable_if<
+ boost::is_same<typename ProducerTag::producer_concept, concepts::keyed_producer>
>::type >
- struct connect_impl
{
template<typename Producer, typename Consumer>
struct apply
@@ -52,61 +48,42 @@
connect(get_keyed_producer<Mechanism>(producer, consumer), consumer);
}
};
- };*/
+ };
+
+ template<typename Mechanism, typename ProducerTag, typename ConsumerTag>
+ struct connect_impl<Mechanism, ProducerTag, ConsumerTag,
+ typename enable_if<
+ boost::is_same<typename ConsumerTag::consumer_concept, concepts::keyed_consumer>
+ >::type >
+ {
+ template<typename Producer, typename Consumer>
+ struct apply
+ {
+ static void call(Producer &producer, Consumer &consumer)
+ {
+ connect(producer, get_keyed_consumer<Mechanism>(producer, consumer));
+ }
+ };
+ };
}
template<typename Mechanism, typename Producer, typename Consumer>
inline void connect(Producer &producer, Consumer &consumer)
{
+ typedef typename boost::remove_cv<Producer>::type ProducerNoCV;
+ typedef typename boost::remove_cv<Consumer>::type ConsumerNoCV;
+
extension::connect_impl<
Mechanism,
- typename producer_category_of<Mechanism, Producer>::type,
- typename consumer_category_of<Mechanism, Consumer>::type>
- ::template apply<
- typename get_proxied_producer_type<Mechanism, Producer>::type,
- typename get_proxied_consumer_type<Mechanism, Consumer>::type
- >::call(get_proxied_producer<Mechanism>(producer),
- get_proxied_consumer<Mechanism>(consumer));
-}
-
-template<typename Mechanism, typename Producer, typename Consumer>
-inline void connect(const Producer &producer, Consumer &consumer)
-{
- extension::connect_impl<
- Mechanism,
- typename producer_category_of<Mechanism, Producer>::type,
- typename consumer_category_of<Mechanism, Consumer>::type>
- ::template apply<
- typename get_proxied_producer_type<Mechanism, Producer>::type,
- typename get_proxied_consumer_type<Mechanism, Consumer>::type
- >::call(get_proxied_producer<Mechanism>(producer),
- get_proxied_consumer<Mechanism>(consumer));
-}
-
-template<typename Mechanism, typename Producer, typename Consumer>
-inline void connect(Producer &producer, const Consumer &consumer)
-{
- extension::connect_impl<
- Mechanism,
- typename producer_category_of<Mechanism, Producer>::type,
- typename consumer_category_of<Mechanism, Consumer>::type>
- ::template apply<
- typename get_proxied_producer_type<Mechanism, Producer>::type,
- typename get_proxied_consumer_type<Mechanism, Consumer>::type
- >::call(get_proxied_producer<Mechanism>(producer),
- get_proxied_consumer<Mechanism>(consumer));
-}
-
-template<typename Mechanism, typename Producer, typename Consumer>
-inline void connect(const Producer &producer, const Consumer &consumer)
-{
- extension::connect_impl<
- Mechanism,
- typename producer_category_of<Mechanism, Producer>::type,
- typename consumer_category_of<Mechanism, Consumer>::type>
+ typename producer_category_of<Mechanism, ProducerNoCV>::type,
+ typename consumer_category_of<Mechanism, ConsumerNoCV>::type>
::template apply<
- typename get_proxied_producer_type<Mechanism, Producer>::type,
- typename get_proxied_consumer_type<Mechanism, Consumer>::type
+ typename boost::remove_reference<
+ typename get_proxied_producer_result_type<Mechanism, Producer>::type
+ >::type,
+ typename boost::remove_reference<
+ typename get_proxied_consumer_result_type<Mechanism, Consumer>::type
+ >::type
>::call(get_proxied_producer<Mechanism>(producer),
get_proxied_consumer<Mechanism>(consumer));
}
Modified: sandbox/SOC/2007/signals/boost/dataflow/support/consumer.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/consumer.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/consumer.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -15,11 +15,35 @@
namespace boost { namespace dataflow {
+namespace concepts
+{
+ struct consumer;
+}
+
+template<typename ConsumerConcept, typename OutConnectionsStored=connections::none>
+struct consumer_category
+{
+ typedef ConsumerConcept consumer_concept;
+ typedef OutConnectionsStored in_connections_stored;
+};
+
+template<typename ConsumerCategory, typename Enable=void>
+struct is_consumer_category : public boost::false_type
+{};
+
+template<typename ConsumerCategory>
+struct is_consumer_category<ConsumerCategory,
+ typename detail::enable_if_defined<detail::all_of<
+ typename ConsumerCategory::in_connections_stored,
+ typename ConsumerCategory::consumer_concept
+ > >::type>
+ : public boost::mpl::true_
+{};
+
/// Trait giving the consumer category of a type.
template<typename Mechanism, typename T, typename Enable=void>
struct consumer_category_of
-{
-};
+{};
/// Allows intrusive specification of the consumer category.
template<typename Mechanism, typename T>
@@ -29,6 +53,7 @@
>
{
typedef typename T::template dataflow<Mechanism>::consumer_category type;
+ BOOST_MPL_ASSERT(( is_consumer_category<type> ));
};
/// Trait determining whether a type is a Consumer.
@@ -43,22 +68,6 @@
>::type >
: public boost::true_type {};
-/// Trait giving the consumed type of a SingleTypeConsumer.
-template<typename Mechanism, typename T, typename Enable=void>
-struct consumed_type_of
-{
-};
-
-/// Allows intrusive specification of the consumer category.
-template<typename Mechanism, typename T>
-struct consumed_type_of<Mechanism, T,
- typename detail::enable_if_defined<
- typename T::template dataflow<Mechanism>::consumed_type>::type
- >
-{
- typedef typename T::template dataflow<Mechanism>::consumed_type type;
-};
-
template<typename Mechanism, typename ConsumerTag>
struct consumer
{
@@ -84,46 +93,22 @@
};
};
-// Trait determining whether a type is a SingleTypeConsumer.
-template<typename Mechanism, typename T, typename Enable=void>
-struct is_single_type_consumer
- : public boost::false_type {};
-
-template<typename Mechanism, typename T>
-struct is_single_type_consumer<Mechanism, T,
- typename detail::enable_if_defined<detail::all_of<
- typename consumer_category_of<Mechanism, T>::type,
- typename consumed_type_of<Mechanism, T>::type
- > >::type >
- : public boost::true_type {};
+} } // namespace boost::dataflow
-template<typename Mechanism, typename ConsumerTag, typename ConsumedType>
-struct single_type_consumer
-{
- template<typename M, typename Enable=void>
- struct dataflow
- {
- };
-
- template<typename M>
- struct dataflow<M, typename boost::enable_if<is_same<M, Mechanism> >::type>
- {
- typedef ConsumerTag consumer_category;
- typedef ConsumedType consumed_type;
- };
+#define DATAFLOW_CONSUMER_CATEGORY(m,p,pc) \
+template<> \
+struct consumer_category_of<m, p> \
+{ \
+ typedef pc type; \
+ BOOST_MPL_ASSERT(( is_consumer_category<type> )); \
};
-template<typename ConsumerTag, typename ConsumedType>
-struct single_type_consumer<all_mechanisms, ConsumerTag, ConsumedType>
-{
- template<typename M>
- struct dataflow
- {
- typedef ConsumerTag consumer_category;
- typedef ConsumedType consumed_type;
- };
+#define DATAFLOW_CONSUMER_CATEGORY_ENABLE_IF(m,P,Cond,pc) \
+template<typename P> \
+struct consumer_category_of<m, P, typename boost::enable_if< Cond >::type> \
+{ \
+ typedef pc type; \
+ BOOST_MPL_ASSERT(( is_consumer_category<type> )); \
};
-} } // namespace boost::dataflow
-
#endif // BOOST_DATAFLOW_SUPPORT_CONSUMER_HPP
Added: sandbox/SOC/2007/signals/boost/dataflow/support/disconnect_all_ins.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/disconnect_all_ins.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,68 @@
+// 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_DISCONNECT_ALL_INS_HPP
+#define BOOST_DATAFLOW_SUPPORT_DISCONNECT_ALL_INS_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 {
+
+namespace extension
+{
+ template<typename Mechanism, typename ConsumerTag, typename Enable=void>
+ struct disconnect_all_ins_impl
+ {
+ template<typename Consumer>
+ struct apply
+ {
+ struct detail
+ {
+ typedef void disconnect_all_ins_impl_unspecialized;
+ };
+
+ static void call(Consumer &)
+ {
+ // Error: disconnect_all_ins_impl has not been implemented for
+ // ConsumerTag.
+ BOOST_STATIC_ASSERT(sizeof(Consumer)==0);
+ }
+ };
+ };
+}
+
+template<typename Mechanism, typename T, typename Enable=void>
+struct is_in_disconnectable
+ : public boost::true_type {};
+
+template<typename Mechanism, typename Producer>
+struct is_in_disconnectable<
+ Mechanism,
+ Producer,
+ typename detail::enable_if_defined<
+ typename extension::disconnect_all_ins_impl<
+ Mechanism,
+ typename producer_category_of<Mechanism, Producer>::type
+ >::detail::template apply<Producer>::disconnect_all_ins_impl_unspecified
+ >::type
+>
+ : public boost::false_type {};
+
+template<typename Mechanism, typename Producer>
+void disconnect_all_ins(Producer &producer)
+{
+ extension::disconnect_all_ins_impl<
+ Mechanism,
+ typename producer_category_of<Mechanism, Producer>::type
+ >::template apply<Producer>::call(producer);
+}
+
+} } // namespace boost::dataflow
+
+#endif // BOOST_DATAFLOW_SUPPORT_DISCONNECT_ALL_INS_HPP
Added: sandbox/SOC/2007/signals/boost/dataflow/support/disconnect_all_outs.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/disconnect_all_outs.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,68 @@
+// 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_DISCONNECT_ALL_OUTS_HPP
+#define BOOST_DATAFLOW_SUPPORT_DISCONNECT_ALL_OUTS_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 {
+
+namespace extension
+{
+ template<typename Mechanism, typename ProducerTag, typename Enable=void>
+ struct disconnect_all_outs_impl
+ {
+ template<typename Producer>
+ struct apply
+ {
+ struct detail
+ {
+ typedef void disconnect_all_outs_impl_unspecialized;
+ };
+
+ static void call(Producer &)
+ {
+ // Error: disconnect_all_outs_impl has not been implemented for
+ // ProducerTag.
+ BOOST_STATIC_ASSERT(sizeof(Producer)==0);
+ }
+ };
+ };
+}
+
+template<typename Mechanism, typename T, typename Enable=void>
+struct is_out_disconnectable
+ : public boost::true_type {};
+
+template<typename Mechanism, typename Producer>
+struct is_out_disconnectable<
+ Mechanism,
+ Producer,
+ typename detail::enable_if_defined<
+ typename extension::disconnect_all_outs_impl<
+ Mechanism,
+ typename producer_category_of<Mechanism, Producer>::type
+ >::detail::template apply<Producer>::disconnect_all_outs_impl_unspecified
+ >::type
+>
+ : public boost::false_type {};
+
+template<typename Mechanism, typename Producer>
+void disconnect_all_outs(Producer &producer)
+{
+ extension::disconnect_all_outs_impl<
+ Mechanism,
+ typename producer_category_of<Mechanism, Producer>::type
+ >::template apply<Producer>::call(producer);
+}
+
+} } // namespace boost::dataflow
+
+#endif // BOOST_DATAFLOW_SUPPORT_DISCONNECT_ALL_OUTS_HPP
Modified: sandbox/SOC/2007/signals/boost/dataflow/support/filter.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/filter.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/filter.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -42,4 +42,21 @@
} } // namespace boost::dataflow
+#define DATAFLOW_FILTER_CATEGORY(m,p,pc) \
+template<> \
+struct filter_category_of<m, p> \
+{ \
+ typedef pc type; \
+ BOOST_MPL_ASSERT(( is_producer_category<type> )); \
+ BOOST_MPL_ASSERT(( is_consumer_category<type> )); \
+};
+
+#define DATAFLOW_FILTER_CATEGORY_ENABLE_IF(m,P,Cond,pc) \
+template<typename P> \
+struct filter_category_of<m, P, typename boost::enable_if< Cond >::type> \
+{ \
+ typedef pc type; \
+ BOOST_MPL_ASSERT(( mpl::and_<is_producer_category<type>,is_consumer_category<type> > )); \
+};
+
#endif // BOOST_DATAFLOW_SUPPORT_FILTER_HPP
Added: sandbox/SOC/2007/signals/boost/dataflow/support/header.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/header.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,9 @@
+/*
+ * header.hpp
+ * signal_network
+ *
+ * Created by Stjepan Rajko on 10/10/07.
+ * Copyright 2007 __MyCompanyName__. All rights reserved.
+ *
+ */
+
Modified: sandbox/SOC/2007/signals/boost/dataflow/support/invocable.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/invocable.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/invocable.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -63,10 +63,6 @@
{
invocable();
}
- static void call(const Invocable &invocable)
- {
- invocable();
- }
};
};
}
@@ -84,7 +80,7 @@
invoke(const Invocable &invocable)
{
extension::invoke_impl<typename invocable_category_of<Invocable>::type>
- ::template apply<Invocable>::call(invocable);
+ ::template apply<const Invocable>::call(invocable);
}
} } // namespace boost::dataflow
Added: sandbox/SOC/2007/signals/boost/dataflow/support/keyed_consumer.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/keyed_consumer.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,68 @@
+// 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_KEYED_CONSUMER_HPP
+#define BOOST_DATAFLOW_SUPPORT_KEYED_CONSUMER_HPP
+
+#include <boost/dataflow/support/consumer.hpp>
+
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+
+namespace boost { namespace dataflow {
+
+namespace concepts
+{
+ struct keyed_consumer;
+}
+
+namespace extension
+{
+ template<typename Mechanism, typename ProducerTag, typename KeyedConsumerTag>
+ struct get_keyed_consumer_impl
+ {
+ struct not_implemented;
+
+ template<typename Producer, typename KeyedConsumer>
+ struct apply
+ {
+ typedef not_implemented type;
+ static type call(Producer &, KeyedConsumer &)
+ {
+ // Error: get_keyed_producer_impl has not been implemented
+ // for KeyedProducerTag and ConsumerTag.
+ BOOST_STATIC_ASSERT(sizeof(Producer)==0);
+ }
+ };
+ };
+}
+
+template<typename Mechanism, typename T1, typename T2>
+typename extension::get_keyed_consumer_impl<
+ Mechanism,
+ typename producer_category_of<
+ Mechanism, typename boost::remove_cv<T1>::type
+ >::type,
+ typename consumer_category_of<
+ Mechanism, typename boost::remove_cv<T2>::type
+ >::type
+>::template apply<T1, T2>::type
+get_keyed_consumer(T1 &t1, T2 &t2)
+{
+ return extension::get_keyed_consumer_impl<
+ Mechanism,
+ typename producer_category_of<
+ Mechanism, typename boost::remove_cv<T1>::type
+ >::type,
+ typename consumer_category_of<
+ Mechanism, typename boost::remove_cv<T2>::type
+ >::type
+ >::template apply<T1, T2>::call(t1, t2);
+}
+
+} } // namespace boost::dataflow
+
+#endif // BOOST_DATAFLOW_SUPPORT_KEYED_CONSUMER_HPP
Added: sandbox/SOC/2007/signals/boost/dataflow/support/keyed_producer.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/keyed_producer.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,66 @@
+// 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_KEYED_PRODUCER_HPP
+#define BOOST_DATAFLOW_SUPPORT_KEYED_PRODUCER_HPP
+
+#include <boost/dataflow/support/producer.hpp>
+
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+
+namespace boost { namespace dataflow {
+
+namespace concepts
+{
+ struct keyed_producer;
+}
+
+namespace extension
+{
+ template<typename Mechanism, typename KeyedProducerTag, typename ConsumerTag>
+ struct get_keyed_producer_impl
+ {
+ template<typename KeyedProducer, typename Consumer>
+ struct apply
+ {
+ typedef void type;
+ static void call(KeyedProducer &, Consumer &)
+ {
+ // Error: get_keyed_producer_impl has not been implemented
+ // for KeyedProducerTag and ConsumerTag.
+ BOOST_STATIC_ASSERT(sizeof(KeyedProducer)==0);
+ }
+ };
+ };
+}
+
+template<typename Mechanism, typename T1, typename T2>
+typename extension::get_keyed_producer_impl<
+ Mechanism,
+ typename producer_category_of<
+ Mechanism, typename boost::remove_cv<T1>::type
+ >::type,
+ typename consumer_category_of<
+ Mechanism, typename boost::remove_cv<T2>::type
+ >::type
+>::template apply<T1, T2>::type
+get_keyed_producer(T1 &t1, T2 &t2)
+{
+ return extension::get_keyed_producer_impl<
+ Mechanism,
+ typename producer_category_of<
+ Mechanism, typename boost::remove_cv<T1>::type
+ >::type,
+ typename consumer_category_of<
+ Mechanism, typename boost::remove_cv<T2>::type
+ >::type
+ >::template apply<const T1, const T2>::call(t1, t2);
+}
+
+} } // namespace boost::dataflow
+
+#endif // BOOST_DATAFLOW_SUPPORT_KEYED_PRODUCER_HPP
Added: sandbox/SOC/2007/signals/boost/dataflow/support/only_connectable.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/only_connectable.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 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_ONLY_CONNECTABLE_HPP
+#define BOOST_DATAFLOW_SUPPORT_ONLY_CONNECTABLE_HPP
+
+#include <boost/dataflow/support/proxy_producer.hpp>
+#include <boost/dataflow/support/proxy_consumer.hpp>
+#include <boost/dataflow/support/keyed_producer.hpp>
+#include <boost/dataflow/support/keyed_consumer.hpp>
+
+#include <boost/static_assert.hpp>
+
+
+namespace boost { namespace dataflow {
+
+namespace extension
+{
+ template<typename Mechanism, typename ProducerTag, typename ConsumerTag, typename Enable=void>
+ struct connect_only_impl
+ {
+ template<typename Producer, typename Consumer>
+ struct apply
+ {
+ static void call(const Producer &, const Consumer &)
+ {
+ // Error: connect_only_impl has not been implemented for ProducerTag
+ // and ConsumerTag.
+ BOOST_STATIC_ASSERT(sizeof(Producer)==0);
+ }
+ };
+ };
+
+ template<typename Mechanism, typename ProducerTag, typename ConsumerTag>
+ struct connect_only_impl<Mechanism, ProducerTag, ConsumerTag,
+ typename enable_if<
+ boost::is_same<typename ProducerTag::producer_concept, concepts::keyed_producer>
+ >::type >
+ {
+ template<typename Producer, typename Consumer>
+ struct apply
+ {
+ static void call(Producer &producer, Consumer &consumer)
+ {
+ connect_only(get_keyed_producer<Mechanism>(producer, consumer), consumer);
+ }
+ };
+ };
+
+ template<typename Mechanism, typename ProducerTag, typename ConsumerTag>
+ struct connect_only_impl<Mechanism, ProducerTag, ConsumerTag,
+ typename enable_if<
+ boost::is_same<typename ConsumerTag::consumer_concept, concepts::keyed_consumer>
+ >::type >
+ {
+ template<typename Producer, typename Consumer>
+ struct apply
+ {
+ static void call(Producer &producer, Consumer &consumer)
+ {
+ connect_only(producer, get_keyed_consumer<Mechanism>(producer, consumer));
+ }
+ };
+ };
+}
+
+template<typename Mechanism, typename Producer, typename Consumer>
+inline void connect_only(Producer &producer, Consumer &consumer)
+{
+ typedef typename boost::remove_cv<Producer>::type ProducerNoCV;
+ typedef typename boost::remove_cv<Consumer>::type ConsumerNoCV;
+
+ extension::connect_only_impl<
+ Mechanism,
+ typename producer_category_of<Mechanism, ProducerNoCV>::type,
+ typename consumer_category_of<Mechanism, ConsumerNoCV>::type>
+ ::template apply<
+ typename boost::remove_reference<
+ typename get_proxied_producer_result_type<Mechanism, Producer>::type
+ >::type,
+ typename boost::remove_reference<
+ typename get_proxied_consumer_result_type<Mechanism, Consumer>::type
+ >::type
+ >::call(get_proxied_producer<Mechanism>(producer),
+ get_proxied_consumer<Mechanism>(consumer));
+}
+
+} } // namespace boost::dataflow
+
+#endif // BOOST_DATAFLOW_SUPPORT_ONLY_CONNECTABLE_HPP
Added: sandbox/SOC/2007/signals/boost/dataflow/support/port.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/port.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,129 @@
+// 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/dataflow/support/common.hpp>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+
+namespace boost { namespace dataflow {
+
+namespace concepts
+{
+ /// Tag
+ struct producer;
+ struct consumer;
+}
+
+namespace port
+{
+ struct producer;
+ struct consumer;
+}
+
+/*/// Convenience class for ProducerCategory types.
+template<typename ProducerConcept, typename OutConnectionsStored=connections::none>
+struct producer_category
+{
+ typedef ProducerConcept producer_concept;
+ typedef OutConnectionsStored out_connections_stored;
+};*/
+
+/// Trait determining adherence to the ProducerCategory concept.
+template<typename PortCategory, typename Enable=void>
+struct is_port_category : public boost::false_type
+{};
+
+template<typename PortCategory>
+struct is_port_category<PortCategory,
+ typename detail::enable_if_defined<
+ typename ProducerCategory::port_concept
+ >::type>
+ : public boost::mpl::true_
+{};
+
+/// Trait returning the producer category of a type.
+template<typename Mechanism, typename Port, typename T, typename Enable=void>
+struct port_category_of
+{};
+
+/// Allows intrusive specification of the producer category.
+template<typename Mechanism, typename Port, typename T>
+struct port_category_of<Mechanism, T,
+ typename detail::enable_if_defined<
+ typename T::template dataflow<Mechanism>::port<Port>::category >::type
+ >
+{
+ typedef typename T::template dataflow<Mechanism>::port<Port>::category type;
+ BOOST_MPL_ASSERT(( is_port_category<type> ));
+};
+
+/// Trait determining adherence to the Producer concept.
+template<typename Mechanism, typename Port, typename T, typename Enable=void>
+struct is_port
+ : public boost::false_type {};
+
+template<typename Mechanism, typename Port, typename T>
+struct is_producer<Mechanism, Port, T,
+ typename detail::enable_if_defined<
+ typename port_category_of<Mechanism, Port, T>::type
+ >::type >
+ : public boost::true_type {};
+
+/// Convenience class for Producer types for a specific Mechanism.
+template<typename Mechanism, typename ProducerTag>
+struct producer
+{
+ template<typename M, typename Enable=void>
+ struct dataflow
+ {
+ };
+
+ template<typename M>
+ struct dataflow<M, typename boost::enable_if<is_same<M, Mechanism> >::type>
+ {
+ typedef ProducerTag producer_category;
+ };
+};
+
+/// Convenience class for Producer types for all Mechanisms.
+template<typename ProducerTag>
+struct producer<all_mechanisms, ProducerTag>
+{
+ template<typename M>
+ struct dataflow
+ {
+ typedef ProducerTag producer_category;
+ };
+};
+
+} } // namespace boost::dataflow
+
+/// Macro simplifying non-intrusive specification of a type's producer category.
+#define DATAFLOW_PRODUCER_CATEGORY(m,p,pc) \
+template<> \
+struct producer_category_of<m, p> \
+{ \
+ typedef pc type; \
+ BOOST_MPL_ASSERT(( is_producer_category<type> )); \
+};
+
+/// Macro simplifying non-intrusive specification of multiple types'
+/// producer category, using a boost::enable_if condition.
+#define DATAFLOW_PRODUCER_CATEGORY_ENABLE_IF(m,P,Cond,pc) \
+template<typename P> \
+struct producer_category_of<m, P, typename boost::enable_if< Cond >::type> \
+{ \
+ typedef pc type; \
+ BOOST_MPL_ASSERT(( is_producer_category<type> )); \
+};
+
+#endif // BOOST_DATAFLOW_SUPPORT_PRODUCER_HPP
Modified: sandbox/SOC/2007/signals/boost/dataflow/support/producer.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/producer.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/producer.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -9,17 +9,45 @@
#include <boost/dataflow/detail/enable_if_defined.hpp>
#include <boost/dataflow/support/common.hpp>
+#include <boost/mpl/assert.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace dataflow {
-/// Trait giving the producer category of a type.
+namespace concepts
+{
+ /// Tag
+ struct producer;
+}
+
+/// Convenience class for ProducerCategory types.
+template<typename ProducerConcept, typename OutConnectionsStored=connections::none>
+struct producer_category
+{
+ typedef ProducerConcept producer_concept;
+ typedef OutConnectionsStored out_connections_stored;
+};
+
+/// Trait determining adherence to the ProducerCategory concept.
+template<typename ProducerCategory, typename Enable=void>
+struct is_producer_category : public boost::false_type
+{};
+
+template<typename ProducerCategory>
+struct is_producer_category<ProducerCategory,
+ typename detail::enable_if_defined<detail::all_of<
+ typename ProducerCategory::out_connections_stored,
+ typename ProducerCategory::producer_concept
+ > >::type>
+ : public boost::mpl::true_
+{};
+
+/// Trait returning the producer category of a type.
template<typename Mechanism, typename T, typename Enable=void>
struct producer_category_of
-{
-};
+{};
/// Allows intrusive specification of the producer category.
template<typename Mechanism, typename T>
@@ -29,9 +57,10 @@
>
{
typedef typename T::template dataflow<Mechanism>::producer_category type;
+ BOOST_MPL_ASSERT(( is_producer_category<type> ));
};
-/// Trait determining whether a type is a Producer.
+/// Trait determining adherence to the Producer concept.
template<typename Mechanism, typename T, typename Enable=void>
struct is_producer
: public boost::false_type {};
@@ -43,22 +72,7 @@
>::type >
: public boost::true_type {};
-/// Trait giving the produced type of a SingleTypeProducer.
-template<typename Mechanism, typename T, typename Enable=void>
-struct produced_type_of
-{
-};
-
-/// Allows intrusive specification of the producer category.
-template<typename Mechanism, typename T>
-struct produced_type_of<Mechanism, T,
- typename detail::enable_if_defined<
- typename T::template dataflow<Mechanism>::produced_type>::type
- >
-{
- typedef typename T::template dataflow<Mechanism>::produced_type type;
-};
-
+/// Convenience class for Producer types for a specific Mechanism.
template<typename Mechanism, typename ProducerTag>
struct producer
{
@@ -74,6 +88,7 @@
};
};
+/// Convenience class for Producer types for all Mechanisms.
template<typename ProducerTag>
struct producer<all_mechanisms, ProducerTag>
{
@@ -84,46 +99,25 @@
};
};
-// Trait determining whether a type is a SingleTypeProducer.
-template<typename Mechanism, typename T, typename Enable=void>
-struct is_single_type_producer
- : public boost::false_type {};
-
-template<typename Mechanism, typename T>
-struct is_single_type_producer<Mechanism, T,
- typename detail::enable_if_defined<detail::all_of<
- typename producer_category_of<Mechanism, T>::type,
- typename produced_type_of<Mechanism, T>::type
- > >::type >
- : public boost::true_type {};
-
-template<typename Mechanism, typename ProducerTag, typename ProducedType>
-struct single_type_producer
-{
- template<typename M, typename Enable=void>
- struct dataflow
- {
- };
-
- template<typename M>
- struct dataflow<M, typename boost::enable_if<is_same<M, Mechanism> >::type>
- {
- typedef ProducerTag producer_category;
- typedef ProducedType produced_type;
- };
-};
+} } // namespace boost::dataflow
-template<typename ProducerTag, typename ProducedType>
-struct single_type_producer<all_mechanisms, ProducerTag, ProducedType>
-{
- template<typename M>
- struct dataflow
- {
- typedef ProducerTag producer_category;
- typedef ProducedType produced_type;
- };
+/// Macro simplifying non-intrusive specification of a type's producer category.
+#define DATAFLOW_PRODUCER_CATEGORY(m,p,pc) \
+template<> \
+struct producer_category_of<m, p> \
+{ \
+ typedef pc type; \
+ BOOST_MPL_ASSERT(( is_producer_category<type> )); \
+};
+
+/// Macro simplifying non-intrusive specification of multiple types'
+/// producer category, using a boost::enable_if condition.
+#define DATAFLOW_PRODUCER_CATEGORY_ENABLE_IF(m,P,Cond,pc) \
+template<typename P> \
+struct producer_category_of<m, P, typename boost::enable_if< Cond >::type> \
+{ \
+ typedef pc type; \
+ BOOST_MPL_ASSERT(( is_producer_category<type> )); \
};
-} } // namespace boost::dataflow
-
#endif // BOOST_DATAFLOW_SUPPORT_PRODUCER_HPP
Modified: sandbox/SOC/2007/signals/boost/dataflow/support/proxy_consumer.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/proxy_consumer.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/proxy_consumer.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -13,27 +13,34 @@
namespace boost { namespace dataflow {
-template<typename Mechanism, typename T, typename Enable=void>
-struct proxied_consumer_of
+template<typename ProxiedConsumer>
+struct proxy_consumer_category
{
+ typedef ProxiedConsumer proxied_consumer;
};
-template<typename Mechanism, typename T>
-struct proxied_consumer_of<Mechanism, T,
+template<typename T, typename Enable=void>
+struct is_proxy_consumer_category : public boost::false_type
+{};
+
+template<typename T>
+struct is_proxy_consumer_category<T,
typename detail::enable_if_defined<
- typename T::template dataflow<Mechanism>::proxy_consumer_for >::type >
-{
- typedef typename T::template dataflow<Mechanism>::proxy_consumer_for type;
-};
+ typename T::proxied_consumer
+ >::type >
+ : public boost::true_type
+{};
-struct default_proxy_consumer;
-struct mutable_proxy_consumer;
+template<typename T>
+struct default_proxy_consumer : public proxy_consumer_category<T>
+{};
+
+template<typename T>
+struct mutable_proxy_consumer : public proxy_consumer_category<T>
+{};
template<typename Mechanism, typename T, typename Enable=void>
-struct proxy_consumer_category_of
-{
- typedef default_proxy_consumer type;
-};
+struct proxy_consumer_category_of;
template<typename Mechanism, typename T>
struct proxy_consumer_category_of<Mechanism, T,
@@ -52,10 +59,7 @@
template<typename Mechanism, typename T>
struct is_proxy_consumer<Mechanism, T,
typename detail::enable_if_defined<
- detail::all_of<
- typename proxied_consumer_of<Mechanism, T>::type,
- typename proxy_consumer_category_of<Mechanism, T>::type
- >
+ typename proxy_consumer_category_of<Mechanism, T>::type
>::type >
: public boost::true_type {};
@@ -72,120 +76,122 @@
typedef
typename get_proxied_consumer_type<
Mechanism,
- typename proxied_consumer_of<Mechanism, T>::type
+ typename proxy_consumer_category_of<Mechanism, T>::type::proxied_consumer
>::type type;
};
+template<typename Mechanism, typename T, typename Enable=void>
+struct get_proxied_consumer_result_type;
+
+template<typename Mechanism, typename T>
+typename boost::disable_if<
+ is_proxy_consumer<Mechanism, T>,
+ T &
+>::type
+get_proxied_consumer(T &t)
+{
+ return t;
+}
+
namespace extension
{
- template<typename Mechanism, typename ProxyProducerTag>
+ template<typename Mechanism, typename ProxyConsumerTag>
struct get_proxied_consumer_impl
{
- template<typename ProxyProducer>
+ template<typename ProxyConsumer>
struct apply
{
- static void call(const ProxyProducer &)
+ static void call(const ProxyConsumer &)
{
// Error: get_proxied_consumer_impl has not been implemented
- // for ProxyProducerTag.
- BOOST_STATIC_ASSERT(sizeof(ProxyProducer)==0);
+ // for ProxyConsumerTag.
+ BOOST_STATIC_ASSERT(sizeof(ProxyConsumer)==0);
}
};
};
-
- template<typename Mechanism>
- struct get_proxied_consumer_impl<Mechanism, default_proxy_consumer>
+
+ template<typename Mechanism, typename ProxiedConsumer>
+ struct get_proxied_consumer_impl<Mechanism, default_proxy_consumer<ProxiedConsumer> >
{
- template<typename ProxyProducer>
- struct result
+ template<typename ProxyConsumer>
+ struct apply
{
typedef typename
- boost::dataflow::get_proxied_consumer_type<
+ get_proxied_consumer_result_type<
Mechanism,
- ProxyProducer
- >::type & type;
+ ProxiedConsumer
+ >::type type;
+
+ static type call(ProxyConsumer &t)
+ {
+ return get_proxied_consumer<Mechanism>(
+ ProxyConsumer::template dataflow<Mechanism>
+ ::get_proxied_consumer(t));
+ }
};
-
- template<typename ProxyProducer>
- struct result<const ProxyProducer>
+ template<typename ProxyConsumer>
+ struct apply<const ProxyConsumer>
{
typedef const typename
- boost::dataflow::get_proxied_consumer_type<
- Mechanism,
- ProxyProducer
- >::type & type;
- };
-
- template<typename ProxyProducer>
- struct apply
- {
- static typename
- boost::dataflow::get_proxied_consumer_type<Mechanism, ProxyProducer>::type &
- call(ProxyProducer &t)
- {
- return t.get_proxied_consumer();
- }
- static
- const typename boost::dataflow::get_proxied_consumer_type<Mechanism, ProxyProducer>::type &
- call(const ProxyProducer &t)
+ get_proxied_consumer_result_type<
+ Mechanism,
+ ProxiedConsumer
+ >::type type;
+
+ static type call(const ProxyConsumer &t)
{
- return t.get_proxied_consumer();
+ return get_proxied_consumer<Mechanism>(
+ ProxyConsumer::template dataflow<Mechanism>
+ ::get_proxied_consumer(t));
}
};
};
- template<typename Mechanism>
- struct get_proxied_consumer_impl<Mechanism, mutable_proxy_consumer>
+ template<typename Mechanism, typename ProxiedConsumer>
+ struct get_proxied_consumer_impl<Mechanism, mutable_proxy_consumer<ProxiedConsumer> >
{
- template<typename ProxyProducer>
- struct result
+ template<typename ProxyConsumer>
+ struct apply
{
typedef typename
- boost::dataflow::get_proxied_consumer_type<
+ get_proxied_consumer_result_type<
Mechanism,
- ProxyProducer
- >::type & type;
- };
-
- template<typename ProxyProducer>
- struct apply
- {
- static
- typename boost::dataflow::get_proxied_consumer_type<Mechanism, ProxyProducer>::type &
- call(const ProxyProducer &t)
+ ProxiedConsumer
+ >::type type;
+
+ static type call(const ProxyConsumer &t)
{
- return t.get_proxied_consumer();
+ return get_proxied_consumer<Mechanism>(
+ ProxyConsumer::template dataflow<Mechanism>
+ ::get_proxied_consumer(t));
}
};
};
-
}
template<typename Mechanism, typename T>
-typename boost::disable_if<
- is_proxy_consumer<Mechanism, T>,
- const T &
->::type
-get_proxied_consumer(const T &t)
+struct get_proxied_consumer_result_type<Mechanism, T,
+ typename boost::disable_if<is_proxy_consumer<Mechanism, T> >::type>
{
- return t;
-}
+ typedef T & type;
+};
template<typename Mechanism, typename T>
-typename boost::disable_if<
- is_proxy_consumer<Mechanism, T>,
- T &
->::type
-get_proxied_consumer(T &t)
+struct get_proxied_consumer_result_type<Mechanism, T,
+ typename boost::enable_if<is_proxy_consumer<Mechanism, T> >::type>
{
- return t;
-}
+ typedef
+ typename extension::get_proxied_consumer_impl<
+ Mechanism,
+ typename proxy_consumer_category_of<Mechanism, T>::type
+ >::template apply<T>::type type;
+};
template<typename Mechanism, typename T>
typename boost::lazy_enable_if<
is_proxy_consumer<Mechanism, T>,
typename extension::get_proxied_consumer_impl<Mechanism,
- typename proxy_consumer_category_of<Mechanism, T>::type>::template result<T>
+ typename proxy_consumer_category_of<Mechanism, T>::type>::template apply<T>
>::type
get_proxied_consumer(T &t)
{
@@ -198,13 +204,13 @@
is_proxy_consumer<Mechanism, T>,
typename extension::get_proxied_consumer_impl<
Mechanism,
- typename proxy_consumer_category_of<Mechanism, T>::type>::template result<const T>
+ typename proxy_consumer_category_of<Mechanism, T>::type>::template apply<const T>
>::type
get_proxied_consumer(const T &t)
{
return extension::get_proxied_consumer_impl<
Mechanism,
- typename proxy_consumer_category_of<Mechanism, T>::type>::template apply<T>::call(t);
+ typename proxy_consumer_category_of<Mechanism, T>::type>::template apply<const T>::call(t);
}
template<typename Mechanism, typename T>
@@ -218,16 +224,21 @@
>::type type;
};
-template<typename Mechanism, typename T>
-struct consumed_type_of<Mechanism, T, typename boost::enable_if<is_proxy_consumer<Mechanism, T> >::type>
-{
- typedef
- typename consumed_type_of<
- Mechanism,
- typename get_proxied_consumer_type<Mechanism, T>::type
- >::type type;
+} } // namespace boost::dataflow
+
+#define DATAFLOW_PROXY_CONSUMER_CATEGORY(m,p,pc) \
+template<> \
+struct proxy_consumer_category_of<m, p> \
+{ \
+ typedef pc type; \
};
-} } // namespace boost::dataflow
+#define DATAFLOW_PROXY_CONSUMER_CATEGORY_ENABLE_IF(m,P,Cond,pc) \
+template<typename P> \
+struct proxy_consumer_category_of<m, P, \
+ typename boost::enable_if< Cond >::type> \
+{ \
+ typedef pc type; \
+};
#endif // BOOST_DATAFLOW_SUPPORT_CONSUMER_HPP
Modified: sandbox/SOC/2007/signals/boost/dataflow/support/proxy_producer.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/proxy_producer.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/proxy_producer.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -11,32 +11,39 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/static_assert.hpp>
+#include <boost/type_traits/remove_cv.hpp>
namespace boost { namespace dataflow {
-
-template<typename Mechanism, typename T, typename Enable=void>
-struct proxied_producer_of
+template<typename ProxiedProducer>
+struct proxy_producer_category
{
+ typedef ProxiedProducer proxied_producer;
};
-template<typename Mechanism, typename T>
-struct proxied_producer_of<Mechanism, T,
+template<typename T, typename Enable=void>
+struct is_proxy_producer_category : public boost::false_type
+{};
+
+template<typename T>
+struct is_proxy_producer_category<T,
typename detail::enable_if_defined<
- typename T::template dataflow<Mechanism>::proxy_producer_for >::type >
-{
- typedef typename T::template dataflow<Mechanism>::proxy_producer_for type;
-};
+ typename T::proxied_producer
+ >::type >
+ : public boost::true_type
+{};
-struct default_proxy_producer;
-struct mutable_proxy_producer;
+template<typename T>
+struct default_proxy_producer : public proxy_producer_category<T>
+{};
+
+template<typename T>
+struct mutable_proxy_producer : public proxy_producer_category<T>
+{};
template<typename Mechanism, typename T, typename Enable=void>
-struct proxy_producer_category_of
-{
- typedef default_proxy_producer type;
-};
+struct proxy_producer_category_of;
template<typename Mechanism, typename T>
struct proxy_producer_category_of<Mechanism, T,
@@ -55,10 +62,10 @@
template<typename Mechanism, typename T>
struct is_proxy_producer<Mechanism, T,
typename detail::enable_if_defined<
- detail::all_of<
- typename proxied_producer_of<Mechanism, T>::type,
- typename proxy_producer_category_of<Mechanism, T>::type
- >
+ typename proxy_producer_category_of<
+ Mechanism,
+ typename boost::remove_cv<T>::type
+ >::type
>::type >
: public boost::true_type {};
@@ -75,10 +82,24 @@
typedef
typename get_proxied_producer_type<
Mechanism,
- typename proxied_producer_of<Mechanism, T>::type
+ typename proxy_producer_category_of<Mechanism, T>::type::proxied_producer
>::type type;
};
+template<typename Mechanism, typename T, typename Enable=void>
+struct get_proxied_producer_result_type;
+
+
+template<typename Mechanism, typename T>
+typename boost::disable_if<
+ is_proxy_producer<Mechanism, T>,
+ T &
+>::type
+get_proxied_producer(T &t)
+{
+ return t;
+}
+
namespace extension
{
template<typename Mechanism, typename ProxyProducerTag>
@@ -87,7 +108,7 @@
template<typename ProxyProducer>
struct apply
{
- static void call(const ProxyProducer &)
+ static void call(ProxyProducer &p)
{
// Error: get_proxied_producer_impl has not been implemented
// for ProxyProducerTag.
@@ -95,119 +116,101 @@
}
};
};
-
- template<typename Mechanism>
- struct get_proxied_producer_impl<Mechanism, default_proxy_producer>
+
+ template<typename Mechanism, typename ProxiedProducer>
+ struct get_proxied_producer_impl<Mechanism, default_proxy_producer<ProxiedProducer> >
{
template<typename ProxyProducer>
- struct result
+ struct apply
{
typedef typename
- boost::dataflow::get_proxied_producer_type<
+ get_proxied_producer_result_type<
Mechanism,
- ProxyProducer
- >::type & type;
+ ProxiedProducer
+ >::type type;
+
+ static type call(ProxyProducer &t)
+ {
+ return get_proxied_producer<Mechanism>(
+ ProxyProducer::template dataflow<Mechanism>
+ ::get_proxied_producer(t));
+ }
};
-
template<typename ProxyProducer>
- struct result<const ProxyProducer>
+ struct apply<const ProxyProducer>
{
typedef const typename
- boost::dataflow::get_proxied_producer_type<
- Mechanism,
- ProxyProducer
- >::type & type;
- };
-
- template<typename ProxyProducer>
- struct apply
- {
- static typename
- boost::dataflow::get_proxied_producer_type<Mechanism, ProxyProducer>::type &
- call(ProxyProducer &t)
- {
- return t.get_proxied_producer();
- }
- static
- const typename boost::dataflow::get_proxied_producer_type<Mechanism, ProxyProducer>::type &
- call(const ProxyProducer &t)
+ get_proxied_producer_result_type<
+ Mechanism,
+ ProxiedProducer
+ >::type type;
+
+ static type call(const ProxyProducer &t)
{
- return ProxyProducer::template dataflow<Mechanism>::get_proxied_producer(t);
+ return get_proxied_producer<Mechanism>(
+ ProxyProducer::template dataflow<Mechanism>
+ ::get_proxied_producer(t));
}
};
};
- template<typename Mechanism>
- struct get_proxied_producer_impl<Mechanism, mutable_proxy_producer>
+ template<typename Mechanism, typename ProxiedProducer>
+ struct get_proxied_producer_impl<Mechanism, mutable_proxy_producer<ProxiedProducer> >
{
template<typename ProxyProducer>
- struct result
+ struct apply
{
typedef typename
- boost::dataflow::get_proxied_producer_type<
+ get_proxied_producer_result_type<
Mechanism,
- ProxyProducer
- >::type & type;
- };
-
- template<typename ProxyProducer>
- struct apply
- {
- static
- typename boost::dataflow::get_proxied_producer_type<Mechanism, ProxyProducer>::type &
- call(const ProxyProducer &t)
+ ProxiedProducer
+ >::type type;
+
+ static type call(const ProxyProducer &t)
{
- return ProxyProducer::template dataflow<Mechanism>::get_proxied_producer(t);
+ return get_proxied_producer<Mechanism>(
+ ProxyProducer::template dataflow<Mechanism>
+ ::get_proxied_producer(t));
}
};
};
-
}
template<typename Mechanism, typename T>
-typename boost::disable_if<
- is_proxy_producer<Mechanism, T>,
- const T &
->::type
-get_proxied_producer(const T &t)
+struct get_proxied_producer_result_type<Mechanism, T,
+ typename boost::disable_if<is_proxy_producer<Mechanism, T> >::type>
{
- return t;
-}
+ typedef T & type;
+};
template<typename Mechanism, typename T>
-typename boost::disable_if<
- is_proxy_producer<Mechanism, T>,
- T &
->::type
-get_proxied_producer(T &t)
+struct get_proxied_producer_result_type<Mechanism, T,
+ typename boost::enable_if<is_proxy_producer<Mechanism, T> >::type>
{
- return t;
-}
+ typedef
+ typename extension::get_proxied_producer_impl<
+ Mechanism,
+ typename proxy_producer_category_of<Mechanism, T>::type
+ >::template apply<T>::type type;
+};
template<typename Mechanism, typename T>
typename boost::lazy_enable_if<
is_proxy_producer<Mechanism, T>,
typename extension::get_proxied_producer_impl<Mechanism,
- typename proxy_producer_category_of<Mechanism, T>::type>::template result<T>
+ typename proxy_producer_category_of<
+ Mechanism,
+ typename boost::remove_cv<T>::type
+ >::type
+ >::template apply<T>
>::type
get_proxied_producer(T &t)
{
- return extension::get_proxied_producer_impl<Mechanism,
- typename proxy_producer_category_of<Mechanism, T>::type>::template apply<T>::call(t);
-}
-
-template<typename Mechanism, typename T>
-typename boost::lazy_enable_if<
- is_proxy_producer<Mechanism, T>,
- typename extension::get_proxied_producer_impl<
- Mechanism,
- typename proxy_producer_category_of<Mechanism, T>::type>::template result<const T>
->::type
-get_proxied_producer(const T &t)
-{
- return extension::get_proxied_producer_impl<
- Mechanism,
- typename proxy_producer_category_of<Mechanism, T>::type>::template apply<T>::call(t);
+ return
+ extension::get_proxied_producer_impl<
+ Mechanism,
+ typename proxy_producer_category_of<Mechanism, T>::type
+ >::template apply<T>::call(t);
}
template<typename Mechanism, typename T>
@@ -221,16 +224,21 @@
>::type type;
};
-template<typename Mechanism, typename T>
-struct produced_type_of<Mechanism, T, typename boost::enable_if<is_proxy_producer<Mechanism, T> >::type>
-{
- typedef
- typename produced_type_of<
- Mechanism,
- typename get_proxied_producer_type<Mechanism, T>::type
- >::type type;
+} } // namespace boost::dataflow
+
+#define DATAFLOW_PROXY_PRODUCER_CATEGORY(m,p,pc) \
+template<> \
+struct proxy_producer_category_of<m, p> \
+{ \
+ typedef pc type; \
};
-} } // namespace boost::dataflow
+#define DATAFLOW_PROXY_PRODUCER_CATEGORY_ENABLE_IF(m,P,Cond,pc) \
+template<typename P> \
+struct proxy_producer_category_of<m, P, \
+ typename boost::enable_if< Cond >::type> \
+{ \
+ typedef pc type; \
+};
#endif // BOOST_DATAFLOW_SUPPORT_PROXY_PRODUCER_HPP
Added: sandbox/SOC/2007/signals/boost/dataflow/templates/connect.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/templates/connect.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,22 @@
+// 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)
+
+// DO NOT INCLUDE THIS FILE DIRECTLY
+
+#ifndef DATAFLOW_TEMPLATE_MECHANISM
+#error DATAFLOW_TEMPLATE_MECHANISM undefined. Do not include this file directly.
+#endif
+
+template<typename Producer, typename Consumer>
+inline void connect(Producer &producer, Consumer &consumer)
+{
+ boost::dataflow::connect< DATAFLOW_TEMPLATE_MECHANISM >(producer, consumer);
+}
+
+template<typename Producer, typename Consumer>
+inline void connect_only(Producer &producer, Consumer &consumer)
+{
+ boost::dataflow::connect_only< DATAFLOW_TEMPLATE_MECHANISM >(producer, consumer);
+}
\ No newline at end of file
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-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -133,9 +133,11 @@
08F022C70C47565600C0ED27 /* operators.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = operators.hpp; sourceTree = "<group>"; };
08F076F80C63C78C003D448D /* consumer_map.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = consumer_map.hpp; sourceTree = "<group>"; };
08F077830C63F736003D448D /* components.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = components.qbk; sourceTree = "<group>"; };
+ 08F079950CA88EBF001E6E24 /* connect.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = connect.hpp; sourceTree = "<group>"; };
08F082020C1D591000687E1B /* introduction.qbk */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = introduction.qbk; sourceTree = "<group>"; };
08F082570C1DD53400687E1B /* components.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = components.qbk; sourceTree = "<group>"; };
08F0825A0C1DD58500687E1B /* connections.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = connections.qbk; sourceTree = "<group>"; };
+ 08F14AE60CA8A72700C8296E /* disconnect_all_outs.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = disconnect_all_outs.hpp; sourceTree = "<group>"; };
08F20FB60C95AD97005D01D4 /* filter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = filter.hpp; sourceTree = "<group>"; };
08F22ECE0C4BF6130027D364 /* make_ref.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = make_ref.hpp; sourceTree = "<group>"; };
08F22ED60C4BF78B0027D364 /* sequence_environment.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = sequence_environment.hpp; sourceTree = "<group>"; };
@@ -144,12 +146,24 @@
08F22FD70C4C87C50027D364 /* static_value.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = static_value.hpp; sourceTree = "<group>"; };
08F230020C4C894E0027D364 /* advance.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = advance.hpp; sourceTree = "<group>"; };
08F230430C4C8D810027D364 /* static_function.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = static_function.hpp; sourceTree = "<group>"; };
+ 08F2464B0CA86D85001C3D41 /* Cone2.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Cone2.cxx; sourceTree = "<group>"; };
+ 08F2464C0CA86D85001C3D41 /* Cone3.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Cone3.cxx; sourceTree = "<group>"; };
+ 08F2464D0CA86D85001C3D41 /* Cone4.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Cone4.cxx; sourceTree = "<group>"; };
+ 08F2464E0CA86D85001C3D41 /* Cone5.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Cone5.cxx; sourceTree = "<group>"; };
+ 08F2464F0CA86D85001C3D41 /* Cone6.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Cone6.cxx; sourceTree = "<group>"; };
+ 08F2C31A0CAD961F00F9100C /* operators.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = operators.hpp; sourceTree = "<group>"; };
+ 08F2C31B0CAD961F00F9100C /* support.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = support.hpp; sourceTree = "<group>"; };
+ 08F308790CA6E54200652D11 /* keyed_producer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = keyed_producer.hpp; sourceTree = "<group>"; };
+ 08F343460CAAEF92004F6DA7 /* disconnect_all_ins.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = disconnect_all_ins.hpp; sourceTree = "<group>"; };
08F348510C492B4B0096097F /* group.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = group.hpp; 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>"; };
08F3FE0C0CA0975100F0E144 /* common.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = common.hpp; sourceTree = "<group>"; };
+ 08F404190CAA055C00E80B8C /* keyed_consumer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = keyed_consumer.hpp; sourceTree = "<group>"; };
+ 08F404420CAA0C5200E80B8C /* only_connectable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = only_connectable.hpp; sourceTree = "<group>"; };
+ 08F418060CBD69DC007E7F7A /* header.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = header.hpp; sourceTree = "<group>"; };
+ 08F418080CBD69FE007E7F7A /* port.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = port.hpp; sourceTree = "<group>"; };
08F4533A0C92259D00877528 /* proxy_producer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = proxy_producer.hpp; sourceTree = "<group>"; };
- 08F496DA0C9A15EC00C37AC0 /* support.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = support.hpp; sourceTree = "<group>"; };
08F4FBB80C56AFDF00EB271A /* producer_wrapper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = producer_wrapper.hpp; sourceTree = "<group>"; };
08F4FC170C56C96300EB271A /* producer_container.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = producer_container.hpp; sourceTree = "<group>"; };
08F585BE0C5A7ED70086F4F4 /* concepts.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = concepts.qbk; sourceTree = "<group>"; };
@@ -184,22 +198,22 @@
08FC25DF0C45D18700F59CDD /* consumer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = consumer.hpp; sourceTree = "<group>"; };
08FC25FC0C45E77B00F59CDD /* producer_accumulator.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = producer_accumulator.hpp; sourceTree = "<group>"; };
08FC26060C46049400F59CDD /* edit_distance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = edit_distance.cpp; sourceTree = "<group>"; };
+ 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>"; };
/* End PBXFileReference section */
/* Begin PBXGroup section */
- 0800AC2E0C8CA86400994538 /* VTK */ = {
- isa = PBXGroup;
- children = (
- 08F496DA0C9A15EC00C37AC0 /* support.hpp */,
- );
- path = VTK;
- sourceTree = "<group>";
- };
0800AC2F0C8CA99700994538 /* VTK */ = {
isa = PBXGroup;
children = (
+ 08F2C31A0CAD961F00F9100C /* operators.hpp */,
+ 08F2C31B0CAD961F00F9100C /* support.hpp */,
+ 08F2464B0CA86D85001C3D41 /* Cone2.cxx */,
+ 08F2464C0CA86D85001C3D41 /* Cone3.cxx */,
+ 08F2464D0CA86D85001C3D41 /* Cone4.cxx */,
+ 08F2464E0CA86D85001C3D41 /* Cone5.cxx */,
+ 08F2464F0CA86D85001C3D41 /* Cone6.cxx */,
08DC14FC0C951C4800B96B2E /* Cone.cxx */,
0800AC300C8CA99700994538 /* Jamfile.v2 */,
);
@@ -350,6 +364,13 @@
089A9A090C931A1800C6C5F1 /* proxy_consumer.hpp */,
08F20FB60C95AD97005D01D4 /* filter.hpp */,
08F3FE0C0CA0975100F0E144 /* common.hpp */,
+ 08F308790CA6E54200652D11 /* keyed_producer.hpp */,
+ 08F14AE60CA8A72700C8296E /* disconnect_all_outs.hpp */,
+ 08F404190CAA055C00E80B8C /* keyed_consumer.hpp */,
+ 08F404420CAA0C5200E80B8C /* only_connectable.hpp */,
+ 08F343460CAAEF92004F6DA7 /* disconnect_all_ins.hpp */,
+ 08F418060CBD69DC007E7F7A /* header.hpp */,
+ 08F418080CBD69FE007E7F7A /* port.hpp */,
);
path = support;
sourceTree = "<group>";
@@ -375,6 +396,14 @@
path = connection;
sourceTree = "<group>";
};
+ 08F079940CA88EAB001E6E24 /* templates */ = {
+ isa = PBXGroup;
+ children = (
+ 08F079950CA88EBF001E6E24 /* connect.hpp */,
+ );
+ path = templates;
+ sourceTree = "<group>";
+ };
08F22F1B0C4C1CC70027D364 /* connection */ = {
isa = PBXGroup;
children = (
@@ -439,7 +468,7 @@
08FC25BA0C45B60E00F59CDD /* dataflow */ = {
isa = PBXGroup;
children = (
- 0800AC2E0C8CA86400994538 /* VTK */,
+ 08F079940CA88EAB001E6E24 /* templates */,
08EF9B200C5D506A00D4D206 /* signal */,
08F022C10C47556200C0ED27 /* connection */,
08F0216A0C473AE000C0ED27 /* detail */,
@@ -496,6 +525,7 @@
08F077830C63F736003D448D /* components.qbk */,
08F71D320CA3538E0010099E /* producer_concepts.qbk */,
08F71D390CA353F40010099E /* consumer_concepts.qbk */,
+ 08FCEFCE0CB9CEB000BBB599 /* future.qbk */,
);
name = doc;
path = ../../doc;
Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/Jamfile.v2 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -54,4 +54,6 @@
<xsl:param>toc.section.depth=4
<xsl:param>toc.max.depth=3
<xsl:param>generate.section.toc.level=4
- ;
\ No newline at end of file
+ ;
+
+install png : [ glob *.png ] : <location>html ;
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-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -126,6 +126,9 @@
the invoked consumer to invoke the producer.]
+[section Mechanism]
+
+[endsect][/mechanism]
[include producer_concepts.qbk]
@@ -220,4 +223,50 @@
[endsect][/connectable]
+[section OnlyConnectable]
+
+A [ProducerConcept] `P` and [ConsumerConcept] `C` are /connectable/ if they
+can be connected via the `connect` function. Typically, this means that
+they use the same underlying data transport mechanism, and produce / consume
+the same data type.
+
+[heading Notation]
+The following expressions are used in this document:
+
+[variablelist
+ [[P] [A [ProducerConcept] type.]]
+ [[C] [A [ConsumerConcept] type.
+ [footnote `P` and `C` are [ConnectableConcept]]
+ [[p] [An object of type P.]]
+ [[c] [An object of type C.]]
+]
+
+[heading Requirements]
+[table
+ [[Name] [Expression] [Result Type] [Description]]
+ [
+ [Connect]
+ [`connect(p,c)`]
+ [Any type]
+ [
+ *Semantics:* Creates a permanent connection between the producer
+ and consumer.
+ [footnote: This does not (yet) specify what happens to other
+ existing connections out of `p` of into `c`. They may or may
+ not get modified of erased.].
+ ]
+ ]
+[/ [
+ [Compatible]
+ [`mpl::has_key<consumed_types_of<C>::type, produced_type_of<P>::type>`]
+ [`mpl::true_`]
+ [
+ *Semantics:* In order for two components to be connectable,
+ the produced type must be an element of the consumed types.
+ ]
+ ] ]
+]
+
+[endsect][/onlyconnectable]
+
[endsect][/concepts]
\ No newline at end of file
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-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -12,22 +12,26 @@
]
]
+[template concepts[] [link dataflow.concepts concepts]]
+[template MechanismConcept[] [link dataflow.concepts.mechanism [^Mechanism]]]
+[template FilterConcept[] [link dataflow.concepts.filter [^Filter]]]
[template ProducerCategoryConcept[] [link dataflow.concepts.producercategory [^ProducerCategory]]]
[template ProducerConcept[] [link dataflow.concepts.producer [^Producer]]]
+[template ProducerMapConcept[] [link dataflow.concepts.producermapconcept [^ProducerMap]]]
+[template ProxyProducerConcept[] [link dataflow.concepts.proxyproducer [^ProxyProducer]]]
[template ConsumerConcept[] [link dataflow.concepts.consumer [^Consumer]]]
-[template SingleTypeProducer[] [link dataflow.concepts.singletypeproducer [^SingleTypeProducer]]]
-[template SingleTypeConsumer[] [link dataflow.concepts.singletypeconsumer [^SingleTypeConsumer]]]
+[template ConsumerMapConcept[] [link dataflow.concepts.consumermapconcept [^ConsumerMap]]]
[template InvocableConcept[] [link dataflow.concepts.invocable [^Invocable]]]
[template ConnectableConcept[] [link dataflow.concepts.connectable [^Connectable]]]
-[template ProxyProducerConcept[] [link dataflow.concepts.proxyproducer [^ProxyProducer]]]
+[template OnlyConnectableConcept[] [link dataflow.concepts.onlyconnectable [^OnlyConnectable]]]
[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 how_to_use[text] [link dataflow.introduction.how_to_use [text]]]
+[template DataflowSignals[] [link dataflow.signals Dataflow.Signals]]
+[template DataflowPhoenix[] [link dataflow.phoenix Dataflow.Phoenix]]
[template producer_group[] [link dataflow.components.producer_group producer_group]]
[template consumer_group[] [link dataflow.components.consumer_group consumer_group]]
@@ -60,8 +64,16 @@
[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]]
+[template BoostAsio[] [@http://asio.sourceforge.net/boost_asio_0_3_8/libs/asio/doc/html/index.html Boost.Asio]]
+[template BoostSerialization[] [@http://www.boost.org/libs/serialization/doc/index.html Boost.Serialization]]
+[template WikiDataflow[] [@http://en.wikipedia.org/wiki/Dataflow_programming dataflow]]
[template VTK[] [@http://www.vtk.org/ VTK]]
+[template vtkAlgorithm[] [@http://www.vtk.org/doc/nightly/html/classvtkAlgorithm.html ['vtkAlgorithm]]]
+[template vtkAlgorithmOutput[] [@http://www.vtk.org/doc/nightly/html/classvtkAlgorithmOutput.html ['vtkAlgorithmOutput]]]
+[template vtkMapper[] [@http://www.vtk.org/doc/nightly/html/classvtkMapper.html ['vtkMapper]]]
+[template vtkActor[] [@http://www.vtk.org/doc/nightly/html/classvtkActor.html ['vtkActor]]]
+[template vtkRenderer[] [@http://www.vtk.org/doc/nightly/html/classvtkAlgorithm.html ['vtkRenderer]]]
+
[import ../test/signals/test_connect.cpp]
@@ -83,19 +95,20 @@
[import ../test/signals/test_junction.cpp]
[import ../test/signals/test_mutex.cpp]
-
[import ../example/fibonacci.cpp]
[import ../example/simple_example.cpp]
+[import ../example/VTK/support.hpp]
+
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
+transport mechanisms. It also has layers of 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
+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.
@@ -203,7 +216,7 @@
[endsect]
-[xinclude dataflow_doxygen.xml]
+[include future.qbk]
[section:acknowledgements Acknowledgements]
@@ -223,4 +236,6 @@
[@http://www.boost.org/LICENSE_1_0.txt])
-[endsect]
\ No newline at end of file
+[endsect]
+
+[xinclude dataflow_doxygen.xml]
Added: sandbox/SOC/2007/signals/libs/dataflow/doc/future.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/future.qbk 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,72 @@
+[section:future Future Directions]
+
+There is also a planned /blueprint/ layer (not implemented yet), which
+would provide generic components that are used to provide a "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
+virtual-based polymorphism and the Boost Graph library.
+
+[section:pin Comparison with a pin-based approach, proposed by Tobias Schwinger]
+
+In the early stages of the design of the then called Signal Network
+library, Tobias Schwinger discussed with me his ideas of an alternative
+implementation of a dataflow library. In his approach, there would be
+a separation between the processing components, and components whose purpose
+was to transport data. The processing components would have one or more /pins/,
+and connecting the pins of two processing components together would mean
+pointing them to the same data transport component.
+
+There was a lot of envisioned configurability of the connections made this way
+- the pins at each processing component could be in, out, or in/out, and links
+created by connecting two pins could be categorized as push, pull, push/pull,
+and would also have support for update tracking and trigger modes. The
+framework would provide support for the data transport components and link/pin
+management, and would also be in charge of invoking the components (which
+could be done in an optimized way, depending on what parts of the network
+need to be updated).
+
+While the pin-based approach is substantially different than the signal-based
+approach I was concentrating on at the time, it was clear that both of these
+approaches had their own advantages, and that each could be a useful dataflow
+framework in its own regard. Hence, during the development of the Signal
+Network library, I tried to isolate the common properties of dataflow
+frameworks, in hopes that the signal-based approach could live under the
+same roof as something like the pin-based approach.
+Eventually, I started implementing the [DataflowPhoenix] module,
+partly because I wanted something that contrasted the signal-based approach so
+that I could isolate the truly mechanism-independent dataflow concepts, and
+partly because the underlying pointer based connections in [DataflowPhoenix]
+were a step closer to Tobias' ideas of the pin-based frameworks.
+
+With the Dataflow library in place, which came after merging the Signal Network
+library with the new generic-oriented [DataflowPhoenix], it is now
+a little clearer how the pin-based approach that Tobias proposed could
+be adapted into the generic Dataflow framework.
+Instead of a direct
+connection from a data-producing component to a data-consuming component,
+as is now typically done in both of the Dataflow modules,
+there would be a connection from a data-producing component's pin
+to a data transport component, and again a connection from the data transport
+component to to the pin of the data-consuming component.
+The processing components would be [InvocableConcept], while each data transport
+component would be both a [ProducerConcept] and a [ConsumerConcept].
+
+There are, of course, a lot of other issues to solve, and a lot of ways in
+which the Dataflow generic support layer might need to grow to accomodate
+the pin-based implementation, but perhaps in the end it will show that the
+signal-based approach and the pin-based approach are not too different, and
+perhaps even compatible or convertible between each other.
+
+[/In the pin-based approach, the situation is reversed. There is a "big picture" of what the complete
+network looks like, and the network control mechanism uses this information to decide when a component
+should be invoked and to manage the data shared between the components via pins. Global
+knowledge of the network can be used for better optimization, serialization, etc. However, it may
+come at the price of some intrusiveness to the computation components.]
+
+[endsect]
+
+[endsect][/future]
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-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -141,32 +141,106 @@
If you are interested in exploring the dataflow concept further using
the Dataflow library, see
-* Dataflow library [organization] for a high level overview of the library.
-* The [signals_quickstart] section of the [DataflowSignals] module, for
- further usage examples.
+* [how_to_use How to use this library and the documentation].
[endsect][/dataflow]
-[section:organization Organization and namespace use]
+[section:how_to_use How to use this library and the documentation]
-The Dataflow library (originally called Signal Network) started as a way to
-facilitate dataflow programming by providing components and connections which
-allow large-scale use of Boost.Signals as a mechanism to
-model the transfer of data between processing components.
-However, during the planning, design and development
-of the library, it became apparent that:
-
-* There are a lot of good ways to move data around, [BoostSignals] being one of
- them.
-* There are generic properties of dataflow programs which do not depend on the
- data transport mechanism,
- and can be exploited to develop mechanism-independent dataflow code.
-
-Hence, the Signal Network library has been redesigned into a generic Dataflow
-library, and offers individual mechanism-specific modules - [DataflowSignals]
-and [DataflowPhoenix].
+The Dataflow library currently has two useful parts:
-[heading Dataflow library organization]
+* A layer providing generic dataflow support, adaptable to various dataflow
+ mechanisms.
+* The [DataflowSignals] layer, with a number of implemented components that
+ facilitate implementation of dataflow networks using [BoostSignals] as
+ a data transport mechanism.
+
+There is also a (currently very experimental) [DataflowPhoenix] layer,
+which uses object pointers with support for
+[BoostPhoenix] actors specifying how the data is processed.
+
+[heading Generic dataflow layer]
+
+There are generic properties of dataflow programs which do not depend on the
+data transport mechanism,
+and can be exploited to develop mechanism-independent dataflow code.
+The generic dataflow layer captures some of these properties, and
+has been sucessfully adapted to three
+different data transport mechanisms ([BoostSignals], pointers in conjunction
+with [BoostPhoenix2], and [VTK] pipelines).
+
+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
+favorite data transport mechanism will be more beneficial.
+
+See the [link dataflow.future future directions] of the Dataflow library
+for an idea of what might become available in the future for data transport
+mechanisms with Dataflow library support.
+
+* If you would like to implement Dataflow support for the data transport
+mechanism you are working with, see the
+[link dataflow.introduction.examples.new_layer example] showing
+how the [VTK] support layer was developed.
+* If you are interested in developing generic code on top of the dataflow
+layer, see the [concepts] documentation.
+
+[heading Dataflow.Signals layer]
+
+This part of the Dataflow library provides components
+and connection-making capabilty which facilitates large-scale use of
+Boost.Signals as a mechanism to transfer data between processing components.
+
+For examples of how the [DataflowSignals] layer can be used, see:
+
+
+* The example on developing distributed
+ [link dataflow.introduction.examples.new_layer example] application
+* The [DataflowSignals] documentation.
+
+[/[heading When to use]
+
+While the [link dataflow.introduction.dataflow dataflow] section hopefully
+convinced you that there are circumstances in which a dataflow approach is
+useful, please keep in mind that there are many circumstances in which this
+is not the case.
+
+First, a dataflow approach really only makes sense when the underlying task is
+really about the flow of data through the components that process it.
+If you can't sketch a concise data flow diagram which truly represents
+the application, the dataflow approach might not be the best option.
+For example, if you are implementing a complicated algorithm which is really
+about the sequence of instructions that need to be executed on the data
+(rather than the data going through well-defined and self-contained
+processing components), you probably should't use the Dataflow library.
+If you are working on an audio or video processing application,
+maybe you should.
+
+Second, the data transport mechanism you choose should reflect the needs of
+the applications closely. Most of the functionality that the library supports
+at this moment is regarding run-time configurable connections. If you don't
+need that functionality, you might be wasting resources ([DataflowPhoenix]
+offers some functionality related to compile-time connectability in its
+iterator_relative connections, but that is yet to trickle out into the library
+as a whole).
+
+When using signals as the data transport mechanism, remember that every signal
+sent results in a function call, and if the processing
+components are so minute that the cost of the function
+calls overtakes the cost of the processing,
+using [DataflowSignals] will cause a significant performance hit. A similar
+situation occurs with [DataflowPhoenix], where each consumer must be invoked.
+
+To sum up, consider using the Dataflow library when:
+
+* The application can be modeled well through the flow of data; and
+* The cost of the processing shadows the cost of the function calls, and any
+ unnecessary overhead caused by any connections that need to be stored.
+]
+
+
+[/[heading Dataflow library organization]
The design of the Dataflow library looks like this:
@@ -183,15 +257,6 @@
/invoke/, which can be used to manipulate generic and mechanism-specific
components that the library supports. /Operators/ are based on /connect/.
-There is also a planned /blueprint/ layer (not implemented yet), which
-would provide generic components that are used to provide a "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
-virtual-based polymorphism and the Boost Graph library.
The library also offers a few generic components, which can be used
to group other components together: [producer_group], [consumer_group],
@@ -233,167 +298,279 @@
[note Since there are multiple namespaces used, the documentation will
explicitly state the namespace of documented elements wherever it is
convenient.]
+]
-[endsect][/organization]
+[endsect][/how_to_use]
-[section:mechanisms Implemented data transport mechanisms]
+[section Examples]
+[section:new_layer Implementing support for a new mechanism]
-There are two modules of the Dataflow library which implement different
-data transport mechanisms. [DataflowSignals] uses [BoostSignals],
-and [DataflowPhoenix] uses object pointers, with support for
-[BoostPhoenix] actors specifying how the data is processed.
+This example shows how to implement support for a particular mechanism.
+Our victim is [VTK], a 3D visualization toolkit, which uses a data pipeline
+to move data from a source to the display (with possible transformations,
+scene construction etc. on the way). For example, here is an excerpt from
+a VTK tutorial that sets up a whole source->render window pipeline:
-[section:signals Dataflow.Signals - based on Boost.Signals]
+```
+ // allocate components
+ vtkConeSource *cone = vtkConeSource::New();
+ vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
+ vtkActor *coneActor = vtkActor::New();
+ vtkRenderer *ren1= vtkRenderer::New();
+ vtkRenderWindow *renWin = vtkRenderWindow::New();
-[/The Signal Network library relies on moving the data via function parameters and return values.
-Here, the Boost.Signals library is used to model these individual data channels which couple
-the data transfer and the computational component invocation. This is one possible dataflow-oriented
-approach.
-
-Each of these approaches has different properties. In the signal-based approach, the knowledge of the
-network is local - each component knows about where its signals are going, but it knows nothing
-of where the signals arriving at its own slots are coming from. Unless we record how the network was
-constructed, there is no "big picture" of what the complete network looks like. Similarly,
-the network is executed autonomously - the components invoke one another when appropriate, and
-no external control mechanism is required.]
-
-
-[BoostSignals] is an excellent building block for dataflow networks,
-as it provides support for all of the essential elements -
-data transport through parameters and return values, combining
-return values from multiple signal calls, component invocation,
-and reconfigurability through connection and disconnection.
-
-The [DataflowSignals] module uses [BoostSignals] as
-the data transport mechanism in dataflow networks.
-In addition, it provides two major contributions that facilitate the
-building of large signals-based dataflow networks:
-
-* Support for a number of types of components (functors, filters,
- member function slot selection), which can be used with
- the generic Dataflow functionality - such as the [connect] function and its
- associated operators which can be
- used to easily connect different kinds of components.
-* A number of generic and specific components which can be extended
- and customized for use in particular dataflow networks.
-
-[endsect]
-
-[section:phoenix Dataflow.Phoenix - based on pointers and Boost.Phoenix2]
-
-The [DataflowPhoenix] module uses ordinary object pointers to establish
-a flow of data. It has been named after the Phoenix library because
-it is convenient to describe the operations on the data using Phoenix
-actors.
-
-This module is in early experimental stages, and has little documentation.
-If you are interested, take a look at the fibonacci.cpp example, which
-implements various extravagant versions of a Fibonacci sequence generator:
-
-[example_fibonacci]
-
-[endsect]
-
-[endsect][/mechanisms]
-
-[section:pin Comparison with a pin-based approach, proposed by Tobias Schwinger]
-
-In the early stages of the design of the then called Signal Network
-library, Tobias Schwinger discussed with me his ideas of an alternative
-implementation of a dataflow library. In his approach, there would be
-a separation between the processing components, and components whose purpose
-was to transport data. The processing components would have one or more /pins/,
-and connecting the pins of two processing components together would mean
-pointing them to the same data transport component.
-
-There was a lot of envisioned configurability of the connections made this way
-- the pins at each processing component could be in, out, or in/out, and links
-created by connecting two pins could be categorized as push, pull, push/pull,
-and would also have support for update tracking and trigger modes. The
-framework would provide support for the data transport components and link/pin
-management, and would also be in charge of invoking the components (which
-could be done in an optimized way, depending on what parts of the network
-need to be updated).
-
-While the pin-based approach is substantially different than the signal-based
-approach I was concentrating on at the time, it was clear that both of these
-approaches had their own advantages, and that each could be a useful dataflow
-framework in its own regard. Hence, during the development of the Signal
-Network library, I tried to isolate the common properties of dataflow
-frameworks, in hopes that the signal-based approach could live under the
-same roof as something like the pin-based approach.
-Eventually, I started implementing the [DataflowPhoenix] module,
-partly because I wanted something that contrasted the signal-based approach so
-that I could isolate the truly mechanism-independent dataflow concepts, and
-partly because the underlying pointer based connections in [DataflowPhoenix]
-were a step closer to Tobias' ideas of the pin-based frameworks.
-
-With the Dataflow library in place, which came after merging the Signal Network
-library with the new generic-oriented [DataflowPhoenix], it is now
-a little clearer how the pin-based approach that Tobias proposed could
-be adapted into the generic Dataflow framework.
-Instead of a direct
-connection from a data-producing component to a data-consuming component,
-as is now typically done in both of the Dataflow modules,
-there would be a connection from a data-producing component's pin
-to a data transport component, and again a connection from the data transport
-component to to the pin of the data-consuming component.
-The processing components would be [InvocableConcept], while each data transport
-component would be both a [ProducerConcept] and a [ConsumerConcept].
-
-There are, of course, a lot of other issues to solve, and a lot of ways in
-which the Dataflow generic support layer might need to grow to accomodate
-the pin-based implementation, but perhaps in the end it will show that the
-signal-based approach and the pin-based approach are not too different, and
-perhaps even compatible or convertible between each other.
-
-[/In the pin-based approach, the situation is reversed. There is a "big picture" of what the complete
-network looks like, and the network control mechanism uses this information to decide when a component
-should be invoked and to manage the data shared between the components via pins. Global
-knowledge of the network can be used for better optimization, serialization, etc. However, it may
-come at the price of some intrusiveness to the computation components.]
+ // make the connections
+ coneMapper->SetInputConnection( cone->GetOutputPort() );
+ coneActor->SetMapper( coneMapper );
+ ren1->AddActor( coneActor );
+ renWin->AddRenderer( ren1 );
+```
-[endsect]
+Our goal will be to simplify the connection-making code by providing
+Dataflow support for VTK. With that in place, we will be able to use the
+following connection code:
-[section:use When to use]
+```
+ // make the connections
+ connect(cone, coneMapper);
+ connect(coneMapper, coneActor);
+ connect(coneActor, ren1);
+ connect(ren1, renWin);
+```
-While the [link dataflow.introduction.dataflow dataflow] section hopefully
-convinced you that there are circumstances in which a dataflow approach is
-useful, please keep in mind that there are many circumstances in which this
-is not the case.
+or even more concisely and clearly,
-First, a dataflow approach really only makes sense when the underlying task is
-really about the flow of data through the components that process it.
-If you can't sketch a concise data flow diagram which truly represents
-the application, the dataflow approach might not be the best option.
-For example, if you are implementing a complicated algorithm which is really
-about the sequence of instructions that need to be executed on the data
-(rather than the data going through well-defined and self-contained
-processing components), you probably should't use the Dataflow library.
-If you are working on an audio or video processing application,
-maybe you should.
+```
+ // make the connections
+ // C++ rules prevent us from removing all of the pointer dereferencing here
+ *cone >>= *coneMapper >>= *coneActor >>= *ren1 >>= *renWin;
+```
-Second, the data transport mechanism you choose should reflect the needs of
-the applications closely. Most of the functionality that the library supports
-at this moment is regarding run-time configurable connections. If you don't
-need that functionality, you might be wasting resources ([DataflowPhoenix]
-offers some functionality related to compile-time connectability in its
-iterator_relative connections, but that is yet to trickle out into the library
-as a whole).
+[heading Next]
+[link dataflow.introduction.examples.new_layer.mechanism
+ Setting up the Mechanism]
-When using signals as the data transport mechanism, remember that every signal
-sent results in a function call, and if the processing
-components are so minute that the cost of the function
-calls overtakes the cost of the processing,
-using [DataflowSignals] will cause a significant performance hit. A similar
-situation occurs with [DataflowPhoenix], where each consumer must be invoked.
+[section:mechanism Setting up the Mechanism]
-To sum up, consider using the Dataflow library when:
+The first thing we'll do is create a tag for the VTK [MechanismConcept], in
+namespace `boost::dataflow::vtk`. Since there are currently no requirements
+for a [MechanismConcept], this is as simple as declaring a new type to be used
+as the mechanism tag:
-* The application can be modeled well through the flow of data; and
-* The cost of the processing shadows the cost of the function calls, and any
- unnecessary overhead caused by any connections that need to be stored.
+[vtk_mechanism]
+
+We will now use this tag in reference to the [VTK] dataflow mechanism.
+
+[heading Next]
+[link dataflow.introduction.examples.new_layer.producerconsumer
+ Setting up a Producer and Consumer]
+[endsect][/mechanism]
+
+[section:producerconsumer Setting up a Producer and Consumer]
+
+Now that we have the mechanism, let's cover the basic data pipeline,
+which is implemented using the
+[vtkAlgorithm] class. This class provides input and output ports. Output ports
+are accessible via `GetOuptutPort` member functions, which return a proxy
+object ([vtkAlgorithmOutput] `*`) for an actual output port.
+
+In Dataflow concepts, [vtkAlgorithmOutput] can be made a [ProducerConcept]
+- it corresponds to a single data output point. We support it as such by
+creating a [ProducerCategoryConcept], and associating [vtkAlgorithmOutput]
+with the producer category:
+
+[vtk_algorithm_output_producer]
+
+Now that we have a [ProducerConcept], we need a [ConsumerConcept].
+[vtkAlgorithm] can accept incoming connections using the `AddInputConnection`
+and `SetInputConnection` member functions. The code below provides support
+for [vtkAlgorithm] accepting connections on its default input port:
+
+[vtk_algorithm_consumer]
+
+[heading Next]
+
+[link dataflow.introduction.examples.new_layer.connectable
+ Making things Connectable]
+
+[endsect][/producerconsumer]
+
+[section:connectable Making things Connectable]
+
+With the pair of [ProducerConcept] and [ConsumerConcept] registered, we
+can make them [ConnectableConcept] and/or [OnlyConnectableConcept].
+All we need to do is specialize the implementation for the appropriate
+categories:
+
+[vtk_connect_impl_algorithm]
+
+To make connections, the Dataflow library has a `connect`
+function in its namespace, but it
+has to be called with a mechanism template parameter. To make connecting
+easier, we'll add a forwarding
+connect function in the global namespace (where vtk classes live) specific
+to the vtk mechanism:
+
+[vtk_specialize_connect]
+
+[heading What we can do with what we have so far]
+
+```
+ connect(*cone->GetOutputPort(), *coneMapper);
+```
+
+[heading Next]
+[link dataflow.introduction.examples.new_layer.proxyproducer
+ Setting up a ProxyProducer]
+
+[endsect][/connectable]
+
+[section:proxyproducer Setting up a ProxyProducer]
+
+In the VTK example above, both `vtkConeSource` and `vtkPolyDataMapper`
+inherit [vtkAlgorithm].
+With the [vtkAlgorithmOutput] [ProducerConcept] and
+[vtkAlgorithm] [ConsumerConcept] we've set up,
+we can do things like `connect(cone->GetOutputPort(), *coneMapper);`.
+However, we would like to do `connect(*cone, *coneMapper)`.
+
+To do that,
+we need to make [vtkAlgorithm] a [ProducerConcept]. Since [vtkAlgorithm]
+forms its output connections using [vtkAlgorithmOutput] objects
+returned through the `GetOutputPort` member functions, and we've already
+configured [vtkAlgorithmOutput] as a [ProducerConcept], we can make use
+of the [ProxyProducerConcept] concept provided by the dataflow library.
+In effect, we will make [vtkAlgorithm] delegate it's [ProducerConcept]
+functionality to [vtkAlgorithmOutput]:
+
+[vtk_algorithm_proxy_producer]
+
+Now, [vtkAlgorithm] is a [ProducerConcept].
+
+[heading What we can do with what we have so far]
+
+```
+ connect(*cone, *coneMapper)
+```
+
+[heading Next]
+[link dataflow.introduction.examples.new_layer.filter
+ Setting up a Filter (Producer+Consumer)]
+
+[endsect][/proxyproducer]
+
+[section:filter Setting up a Filter (Producer+Consumer)]
+
+In a VTK pipeline, a [vtkActor] consumes data from a [vtkMapper], and produces
+data for a [vtkRenderer]. In this case, we can provide Dataflow support
+for a [vtkActor] as both a [ProducerConcept] and a [ConsumerConcept] in one
+fell swoop:
+
+[vtk_actor_filter]
+
+[heading Next]
+[link dataflow.introduction.examples.new_layer.producermap
+ Setting up a ProducerMap]
+
+[endsect][/filter]
+
+[section:producermap Setting up a ProducerMap]
+
+Sometimes, components can produce (or consume) multiple types of data.
+For example, [vtkMapper] objects can produce data for [vtkActor] objects,
+or (since [vtkMapper] inherits [vtkAlgorithm]) for other [vtkAlgorithm]
+objects. Correspondingly, connecting a [vtkMapper] to a [vtkActor] is not
+the same as connecting a [vtkMapper] to another [vtkAlgorithm].
+
+To accomodate such situations, the Dataflow library provides
+[ProducerMapConcept]s, which are similar to [ProxyProducer]s but
+the [ProducerConcept] they delegate to is keyed on the category of
+[ConsumerConcept] they are being connected to.
+
+[vtk_mapper_producer]
+
+[heading Next]
+[link dataflow.introduction.examples.new_layer.remaining
+ Setting up the remaining components (more of the same)]
+
+[endsect][/producermap]
+
+[section:remaining Setting up the remaining components (more of the same)]
+
+[vtk_setup_rest]
+
+[heading Next]
+[link dataflow.introduction.examples.new_layer.pointers
+ Supporting pointers]
+
+[endsect][/remaining]
+
+[section:pointers Supporting pointers]
+
+All of the concepts we adapted so far have been adapted for class types such
+as [vtkAlgorithm] and [vtkAlgorithmOutput]. But [VTK] seems to exclusively
+use pointers to class types rather than class types themselves. So, with what
+we have done so far, we can do `connect(*cone, *coneMapper)` but not
+`connect(cone, coneMapper)`. To provide support for pointers, we
+simply make them adhere to the [ProxyProducerConcept] and,
+[ProxyConsumerConcept], and delegate the functionality to the object they
+point to.
+
+[vtk_support_pointer]
+
+[endsect][/pointers]
+
+
+
+[endsect][/new_layer]
+
+[section:distributed Implementing distributed dataflow applications using
+ Dataflow.Signals and Boost.Asio]
+
+This example shows how you can take advantage of dataflow programming
+to create distributed applications. It works as long as the data
+passed in the signal is serializable using [BoostSerialization].
+
+[DataflowSignals] provides two components
+which can be used to create a producer-consumer connection between two
+computers: [socket_sender] and [socket_receiver]. As long as we have
+a network socket set up between two computers, we can do the following to
+set up a connection between a [SignalProducerConcept] on one computer with a
+[SignalConsumerConcept] on another:
+
+* On the [SignalProducerConcept]'s computer, construct a [socket_sender] of
+the appropriate `Signature` with the given socket.
+[connect] the [SignalProducerConcept] to the [socket_sender].
+* On the [SignalConsumerConcept]'s computer, construct a [socket_receiver] of
+the appropriate `Signature` with the given socket.
+[connect] the [socket_receiver] to the [SignalConsumerConcept].
+
+That's it. Now, every signal sent out of the [SignalProducerConcept] should
+be received by the [SignalConsumerConcept].
+
+The following is a modification of the example from the
+[link dataflow.introduction.dataflow motivation section] to a dataflow
+network that straddles a network socket:
+
+[*insert example....]
+
+
+
+
+[endsect][/distributed]
+
+[endsect][/examples]
+
+[section:linking How to link]
+
+The generic Dataflow support layer is header-only, and relies only on a few
+Boost header-only libraries (MPL, enable_if, and small parts of fusion).
+
+The [DataflowSignals] layer is dependent on the [BoostSignals] library,
+which must be built and linked. A few of the components ([socket_sender]
+and [socket_receiver]) are also dependent on [BoostAsio], which depends on
+the System library which must also be built and linked.
-[endsect]
+[endsect][/linking]
[endsect][/introduction]
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-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -1,5 +1,16 @@
-[section Dataflow.Phoenix]
+[section:phoenix Dataflow.Phoenix]
[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
+it is convenient to describe the operations on the data using Phoenix
+actors.
+
+This module is in early experimental stages, and has little documentation.
+If you are interested, take a look at the fibonacci.cpp example, which
+implements various extravagant versions of a Fibonacci sequence generator:
+
+[example_fibonacci]
+
[endsect]
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/producer_concepts.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/producer_concepts.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/producer_concepts.qbk 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -223,4 +223,7 @@
[heading Examples]
+[endsect][/proxyproducer]
+
+[section ProducerMap]
[endsect][/proxyproducer]
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/signals.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/signals.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/signals.qbk 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -8,4 +8,36 @@
[include signals/components.qbk]
+[/The Signal Network library relies on moving the data via function parameters and return values.
+Here, the Boost.Signals library is used to model these individual data channels which couple
+the data transfer and the computational component invocation. This is one possible dataflow-oriented
+approach.
+
+Each of these approaches has different properties. In the signal-based approach, the knowledge of the
+network is local - each component knows about where its signals are going, but it knows nothing
+of where the signals arriving at its own slots are coming from. Unless we record how the network was
+constructed, there is no "big picture" of what the complete network looks like. Similarly,
+the network is executed autonomously - the components invoke one another when appropriate, and
+no external control mechanism is required.]
+
+
+[BoostSignals] is an excellent building block for dataflow networks,
+as it provides support for all of the essential elements -
+data transport through parameters and return values, combining
+return values from multiple signal calls, component invocation,
+and reconfigurability through connection and disconnection.
+
+The [DataflowSignals] module uses [BoostSignals] as
+the data transport mechanism in dataflow networks.
+In addition, it provides two major contributions that facilitate the
+building of large signals-based dataflow networks:
+
+* Support for a number of types of components (functors, filters,
+ member function slot selection), which can be used with
+ the generic Dataflow functionality - such as the [connect] function and its
+ associated operators which can be
+ used to easily connect different kinds of components.
+* A number of generic and specific components which can be extended
+ and customized for use in particular dataflow networks.
+
[endsect]
Modified: sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Cone.cxx
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Cone.cxx (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Cone.cxx 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -21,8 +21,9 @@
// First include the required header files for the VTK classes we are using.
-#include <boost/dataflow/vtk/support.hpp>
+#include "operators.hpp"
+#include "vtkAlgorithmOutput.h"
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
@@ -87,14 +88,10 @@
//
vtkRenderWindow *renWin = vtkRenderWindow::New();
// renWin->AddRenderer( ren1 );
- //connect (*ren1, *renWin);
+ connect (ren1, renWin);
renWin->SetSize( 300, 300 );
- connect(*cone, *coneMapper);
- connect(*coneMapper, *coneActor);
- connect(*coneActor, *ren1);
- connect(*ren1, *renWin);
- //*cone >>= *coneMapper >>= *coneActor >>= *ren1 >>= *renWin;
+ *cone >>= *coneMapper >>= *coneActor >>= *ren1 >>= *renWin;
//
// Now we loop over 360 degreeees and render the cone each time.
Added: sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Cone2.cxx
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Cone2.cxx 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,109 @@
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: $RCSfile: Cone2.cxx,v $
+
+ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
+ All rights reserved.
+ See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notice for more information.
+
+=========================================================================*/
+//
+// This example shows how to add an observer to a C++ program. It extends
+// the Step1/Cxx/Cone.cxx C++ example (see that example for information on
+// the basic setup).
+//
+// VTK uses a command/observer design pattern. That is, observers watch for
+// particular events that any vtkObject (or subclass) may invoke on
+// itself. For example, the vtkRenderer invokes a "StartEvent" as it begins
+// to render. Here we add an observer that invokes a command when this event
+// is observed.
+//
+
+#include "operators.hpp"
+
+// first include the required header files for the vtk classes we are using
+#include "vtkConeSource.h"
+#include "vtkPolyDataMapper.h"
+#include "vtkRenderWindow.h"
+#include "vtkCommand.h"
+#include "vtkCamera.h"
+#include "vtkActor.h"
+#include "vtkRenderer.h"
+
+// Callback for the interaction
+class vtkMyCallback : public vtkCommand
+{
+public:
+ static vtkMyCallback *New()
+ { return new vtkMyCallback; }
+ virtual void Execute(vtkObject *caller, unsigned long, void*)
+ {
+ vtkRenderer *renderer = reinterpret_cast<vtkRenderer*>(caller);
+ cout << renderer->GetActiveCamera()->GetPosition()[0] << " "
+ << renderer->GetActiveCamera()->GetPosition()[1] << " "
+ << renderer->GetActiveCamera()->GetPosition()[2] << "\n";
+ }
+};
+
+int main()
+{
+ //
+ // The pipeline creation is documented in Step1
+ //
+ vtkConeSource *cone = vtkConeSource::New();
+ cone->SetHeight( 3.0 );
+ cone->SetRadius( 1.0 );
+ cone->SetResolution( 10 );
+
+ vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
+ //coneMapper->SetInputConnection( cone->GetOutputPort() );
+ vtkActor *coneActor = vtkActor::New();
+ //coneActor->SetMapper( coneMapper );
+
+ vtkRenderer *ren1= vtkRenderer::New();
+ //ren1->AddActor( coneActor );
+ ren1->SetBackground( 0.1, 0.2, 0.4 );
+ ren1->ResetCamera();
+
+ vtkRenderWindow *renWin = vtkRenderWindow::New();
+ //renWin->AddRenderer( ren1 );
+ renWin->SetSize( 300, 300 );
+
+ *cone >>= *coneMapper >>= *coneActor >>= *ren1 >>= *renWin;
+
+ // Here is where we setup the observer, we do a new and ren1 will
+ // eventually free the observer
+ vtkMyCallback *mo1 = vtkMyCallback::New();
+ ren1->AddObserver(vtkCommand::StartEvent,mo1);
+ mo1->Delete();
+
+ //
+ // now we loop over 360 degrees and render the cone each time
+ //
+ int i;
+ for (i = 0; i < 360; ++i)
+ {
+ // render the image
+ renWin->Render();
+ // rotate the active camera by one degree
+ ren1->GetActiveCamera()->Azimuth( 1 );
+ }
+
+ //
+ // Free up any objects we created
+ //
+ cone->Delete();
+ coneMapper->Delete();
+ coneActor->Delete();
+ ren1->Delete();
+ renWin->Delete();
+
+ return 0;
+}
+
+
Modified: sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/VTK/Jamfile.v2 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -31,4 +31,9 @@
;
exe Cone : Cone.cxx X11 Xt vtkCommon vtkRendering vtkFiltering vtkGraphics GL ;
+exe Cone2 : Cone2.cxx X11 Xt vtkCommon vtkRendering vtkFiltering vtkGraphics GL ;
+exe Cone3 : Cone3.cxx X11 Xt vtkCommon vtkRendering vtkFiltering vtkGraphics GL ;
+exe Cone4 : Cone4.cxx X11 Xt vtkCommon vtkRendering vtkFiltering vtkGraphics GL ;
+exe Cone5 : Cone5.cxx X11 Xt vtkCommon vtkRendering vtkFiltering vtkGraphics GL ;
+exe Cone6 : Cone6.cxx X11 Xt vtkCommon vtkRendering vtkFiltering vtkGraphics vtkWidgets GL ;
Added: sandbox/SOC/2007/signals/libs/dataflow/example/VTK/operators.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/VTK/operators.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -0,0 +1,61 @@
+// 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_VTK_CONNECTION_OPERATORS_HPP
+#define BOOST_DATAFLOW_VTK_CONNECTION_OPERATORS_HPP
+
+#include "support.hpp"
+
+#include <boost/mpl/and.hpp>
+
+
+/// Connects two components (typically as a part of a chain of components).
+/** This operator is identical to signals::operator| (it connects the
+left component to the right component, and returns a reference to the left component),
+except it is evaluated right to left. This makes it semantics more suitable for
+connecting a chain of components.
+*/
+template<typename Input, typename Output>
+typename boost::enable_if<
+ boost::mpl::and_<
+ boost::dataflow::is_producer<boost::dataflow::vtk::mechanism, Input>,
+ boost::dataflow::is_consumer<boost::dataflow::vtk::mechanism, Output>
+ >,
+ Input &
+>::type
+operator >>= (Input &input, Output &output)
+{ connect(input, output); return input;}
+
+/// Connects two components (typically as a part of a chain of components).
+template<typename Input, typename Output>
+typename boost::enable_if<
+ boost::mpl::and_<
+ boost::dataflow::is_producer<boost::dataflow::vtk::mechanism, Input>,
+ boost::dataflow::is_consumer<boost::dataflow::vtk::mechanism, Output>
+ >,
+ Input &
+>::type
+operator ^= (Input &input, Output &output)
+{ connect_only(input, output); return input;}
+
+/// Connects two components (typically as a part of branching from a single component).
+/** This operator is identical to signals::operator>>=, (it connects the
+left component to the right component, and returns a reference to the left component)
+except it is evaluated left to right. This makes its semantics more suitable for
+branching connections.
+*/
+template<typename Input, typename Output>
+typename boost::enable_if<
+ boost::mpl::and_<
+ boost::dataflow::is_producer<boost::dataflow::vtk::mechanism, Input>,
+ boost::dataflow::is_consumer<boost::dataflow::vtk::mechanism, Output>
+ >,
+ Input &
+>::type
+operator | (Input &input, Output &output)
+{ connect(input, output); return input;}
+
+#endif // BOOST_DATAFLOW_VTK_CONNECTION_OPERATORS_HPP
+
Copied: sandbox/SOC/2007/signals/libs/dataflow/example/VTK/support.hpp (from r39491, /sandbox/SOC/2007/signals/boost/dataflow/VTK/support.hpp)
==============================================================================
--- /sandbox/SOC/2007/signals/boost/dataflow/VTK/support.hpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/VTK/support.hpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -6,6 +6,7 @@
#ifndef BOOST_DATAFLOW_VTK_SUPPORT_HPP
#define BOOST_DATAFLOW_VTK_SUPPORT_HPP
+#include "vtkAlgorithmOutput.h"
#include "vtkActor.h"
#include "vtkAlgorithm.h"
#include "vtkRenderWindow.h"
@@ -13,132 +14,197 @@
#include <boost/dataflow/support.hpp>
#include <boost/dataflow/connection/producer_map.hpp>
+#include <boost/assert.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/not.hpp>
#include <boost/fusion/sequence/container/map.hpp>
#include <boost/type_traits/is_base_of.hpp>
+//[ vtk_mechanism
+
namespace boost { namespace dataflow {
-struct vtk;
+namespace vtk {
-struct vtk_algorithm_output_producer;
-struct vtk_algorithm_consumer;
-struct vtk_algorithm_proxy_producer;
-struct vtk_algorithm_mapper_producer;
-struct vtk_prop_producer;
-struct vtk_mapper_consumer;
-struct vtk_renderer_filter;
-struct vtk_rendererwindow_consumer;
+// The vtk mechanism tag
+struct mechanism;
-struct vtk_algorithm_data;
-struct vtk_mapper_data;
+} // namespace boost::dataflow::vtk
-template<>
-struct producer_category_of<vtk, vtkAlgorithmOutput *>
-{
- typedef vtk_algorithm_output_producer type;
-};
+//]
-template<typename T>
-struct proxy_producer_category_of<
- vtk, T,
- typename boost::enable_if<boost::is_base_of<vtkAlgorithm,T> >::type
->
-{
- typedef vtk_algorithm_proxy_producer type;
-};
+//[ vtk_algorithm_output_producer
+// Tag for vtkAlgorithmOutput objects, which serve as proxies for
+// vtkAlgorithm ouput ports.
+namespace vtk {
-template<>
-struct producer_category_of<vtk, vtkMapper *>
-{
- typedef vtk_algorithm_mapper_producer type;
-};
+struct vtk_algorithm_output_producer
+ : public producer_category<concepts::producer, connections::none> {};
+
+} // namespace boost::dataflow::vtk
-template<typename T>
-struct proxied_producer_of<
- vtk, T,
- typename boost::enable_if<boost::is_base_of<vtkAlgorithm,T> >::type
->
-{
- typedef boost::dataflow::producer_map<
- boost::fusion::map<
- boost::fusion::pair<vtk_algorithm_data, vtkAlgorithmOutput *>,
- boost::fusion::pair<vtk_mapper_data, vtkMapper *>
- > > type;
-};
+DATAFLOW_PRODUCER_CATEGORY(vtk::mechanism, vtkAlgorithmOutput, vtk::vtk_algorithm_output_producer)
+
+//]
+
+
+//[ vtk_algorithm_consumer
+namespace vtk {
+
+struct vtk_algorithm_consumer
+ : public consumer_category<concepts::consumer> {};
+
+} // namespace boost::dataflow::vtk
+
+DATAFLOW_CONSUMER_CATEGORY_ENABLE_IF(vtk::mechanism, T,
+ boost::is_base_of<vtkAlgorithm BOOST_PP_COMMA() T>,
+ vtk::vtk_algorithm_consumer)
+
+//]
+
+//[ vtk_connect_impl_algorithm
+namespace extension {
-namespace extension
-{
template<>
- struct get_proxied_producer_impl<vtk, vtk_algorithm_proxy_producer>
+ struct connect_impl<vtk::mechanism, vtk::vtk_algorithm_output_producer, vtk::vtk_algorithm_consumer>
{
- template<typename ProxyProducer>
- struct result
+ template<typename Producer, typename Consumer>
+ struct apply
{
- typedef boost::dataflow::producer_map<
- boost::fusion::map<
- boost::fusion::pair<vtk_algorithm_data, vtkAlgorithmOutput *>,
- boost::fusion::pair<vtk_mapper_data, vtkMapper *>
- > > type;
+ static void call(Producer &producer, Consumer &consumer)
+ {
+ consumer.AddInputConnection(&producer);
+ }
};
-
+ };
+
+ template<>
+ struct connect_only_impl<vtk::mechanism, vtk::vtk_algorithm_output_producer, vtk::vtk_algorithm_consumer>
+ {
+ template<typename Producer, typename Consumer>
+ struct apply
+ {
+ static void call(Producer &producer, Consumer &consumer)
+ {
+ consumer.SetInputConnection(&producer);
+ }
+ };
+ };
+
+}
+
+//]
+
+
+//[ vtk_algorithm_proxy_producer
+
+namespace vtk {
+
+struct vtk_algorithm_proxy_producer
+ : public proxy_producer_category<vtkAlgorithmOutput> {};
+
+} // namespace boost::dataflow::vtk
+
+DATAFLOW_PROXY_PRODUCER_CATEGORY_ENABLE_IF(vtk::mechanism, T,
+ mpl::and_<
+ typename boost::is_base_of<vtkAlgorithm BOOST_PP_COMMA() T> BOOST_PP_COMMA()
+ mpl::not_<boost::is_base_of<vtkMapper BOOST_PP_COMMA() T> >
+ >,
+ vtk::vtk_algorithm_proxy_producer)
+
+namespace extension {
+
+ template<>
+ struct get_proxied_producer_impl<vtk::mechanism, vtk::vtk_algorithm_proxy_producer>
+ {
template<typename ProxyProducer>
struct apply
{
- static typename result<ProxyProducer>::type
- call(ProxyProducer &t)
+ typedef vtkAlgorithmOutput &type;
+
+ static type call(ProxyProducer &t)
{
- return boost::fusion::map<
- boost::fusion::pair<vtk_algorithm_data,vtkAlgorithmOutput *>,
- boost::fusion::pair<vtk_mapper_data, vtkMapper *>
- > (t.GetNumberOfOutputPorts() ? t.GetOutputPort() : (vtkAlgorithmOutput *)NULL, (vtkMapper *)&t);
+ return *t.GetOutputPort();
}
};
};
+}
+
+//]
+
+//[ vtk_actor_filter
+
+namespace vtk {
+
+struct vtk_actor_filter
+ : public producer_category<concepts::producer>
+ , public consumer_category<concepts::consumer>
+{};
}
-template<typename T>
-struct consumer_category_of<
- vtk, T,
- typename boost::enable_if<boost::is_base_of<vtkAlgorithm,T> >::type
->
-{
- typedef vtk_algorithm_consumer type;
-};
+DATAFLOW_FILTER_CATEGORY_ENABLE_IF(vtk::mechanism, T,
+ boost::is_base_of<vtkActor BOOST_PP_COMMA() T>,
+ vtk::vtk_actor_filter)
+
+//]
-template<typename T>
-struct consumed_type_of<
- vtk, T,
- typename boost::enable_if<boost::is_base_of<vtkAlgorithm,T> >::type
->
+//[ vtk_mapper_producer
+
+namespace vtk {
+
+struct vtk_mapper_producer
+ : public producer_category<concepts::producer> {};
+
+struct vtk_mapper_proxy : public producer<mechanism, vtk_mapper_producer>
{
- typedef vtk_algorithm_data type;
+ vtkMapper *ptr;
+ vtk_mapper_proxy(vtkMapper *mapper) : ptr(mapper) {}
+ operator vtkMapper * () const {return ptr;}
};
+typedef boost::fusion::map<
+ boost::fusion::pair<vtk::vtk_algorithm_consumer, vtkAlgorithmOutput &>,
+ boost::fusion::pair<vtk::vtk_actor_filter, vtk_mapper_proxy>
+ > vtk_mapper_map;
+struct vtk_mapper_proxy_producer
+ : public proxy_producer_category<
+ producer_map<vtk_mapper_map>
+ > {};
+
+}
+
+DATAFLOW_PROXY_PRODUCER_CATEGORY_ENABLE_IF(vtk::mechanism, T,
+ boost::is_base_of<vtkMapper BOOST_PP_COMMA() T>,
+ vtk::vtk_mapper_proxy_producer)
+
+namespace extension {
-namespace extension
-{
template<>
- struct connect_impl<vtk, vtk_algorithm_output_producer, vtk_algorithm_consumer>
+ struct get_proxied_producer_impl<vtk::mechanism, vtk::vtk_mapper_proxy_producer>
{
- template<typename Producer, typename Consumer>
+ template<typename ProxyProducer>
struct apply
{
- static void call(const Producer &producer, Consumer &consumer)
+ typedef const producer_map<vtk::vtk_mapper_map> type;
+
+ static type call(ProxyProducer &t)
{
- consumer.AddInputConnection(producer);
+ return vtk::vtk_mapper_map(t.GetNumberOfOutputPorts() ?
+ *t.GetOutputPort() : *(vtkAlgorithmOutput *)NULL,
+ vtk::vtk_mapper_proxy(&t));
}
};
};
template<>
- struct connect_impl<vtk, vtk_algorithm_mapper_producer, vtk_mapper_consumer>
+ struct connect_only_impl<vtk::mechanism, vtk::vtk_mapper_producer, vtk::vtk_actor_filter>
{
template<typename Producer, typename Consumer>
struct apply
{
- static void call(const Producer &producer, Consumer &consumer)
+ static void call(Producer &producer, Consumer &consumer)
{
consumer.SetMapper(producer);
}
@@ -146,7 +212,52 @@
};
template<>
- struct connect_impl<vtk, vtk_prop_producer, vtk_renderer_filter>
+ struct connect_impl<vtk::mechanism, vtk::vtk_mapper_producer, vtk::vtk_actor_filter>
+ {
+ template<typename Producer, typename Consumer>
+ struct apply
+ {
+ static void call(Producer &producer, Consumer &consumer)
+ {
+ BOOST_ASSERT(!consumer.GetMapper());
+ consumer.SetMapper(producer);
+ }
+ };
+ };
+
+}
+
+//]
+
+//[ vtk_setup_rest
+
+namespace vtk {
+
+struct vtk_renderer_filter
+ : public producer_category<concepts::producer>
+ , public consumer_category<concepts::consumer>
+{};
+
+struct vtk_rendererwindow_consumer
+ : public consumer_category<concepts::consumer>
+{};
+
+}
+
+DATAFLOW_FILTER_CATEGORY_ENABLE_IF(vtk::mechanism, T,
+ boost::is_base_of<vtkRenderer BOOST_PP_COMMA() T>,
+ vtk::vtk_renderer_filter)
+
+DATAFLOW_CONSUMER_CATEGORY_ENABLE_IF(vtk::mechanism, T,
+ boost::is_base_of<vtkRenderWindow BOOST_PP_COMMA() T>,
+ vtk::vtk_rendererwindow_consumer)
+
+
+
+namespace extension {
+
+ template<>
+ struct connect_impl<vtk::mechanism, vtk::vtk_actor_filter, vtk::vtk_renderer_filter>
{
template<typename Producer, typename Consumer>
struct apply
@@ -157,9 +268,9 @@
}
};
};
-
+
template<>
- struct connect_impl<vtk, vtk_renderer_filter, vtk_rendererwindow_consumer>
+ struct connect_impl<vtk::mechanism, vtk::vtk_renderer_filter, vtk::vtk_rendererwindow_consumer>
{
template<typename Producer, typename Consumer>
struct apply
@@ -172,75 +283,73 @@
};
}
-template<typename T>
-struct producer_category_of<
- vtk, T,
- typename boost::enable_if<boost::is_base_of<vtkActor,T> >::type
->
-{
- typedef vtk_prop_producer type;
-};
+//]
+
+//[ vtk_support_pointer
+
+namespace vtk {
template<typename T>
-struct consumer_category_of<
- vtk, T,
- typename boost::enable_if<boost::is_base_of<vtkActor,T> >::type
->
-{
- typedef vtk_mapper_consumer type;
-};
+struct pointer_proxy_producer : public proxy_producer_category<T> {};
template<typename T>
-struct consumed_type_of<
- vtk, T,
- typename boost::enable_if<boost::is_base_of<vtkActor,T> >::type
->
-{
- typedef vtk_mapper_data type;
-};
+struct pointer_proxy_consumer : public proxy_consumer_category<T> {};
+
+}
template<typename T>
-struct filter_category_of<
- vtk, T,
- typename boost::enable_if<boost::is_base_of<vtkRenderer,T> >::type
->
+struct proxy_producer_category_of<vtk::mechanism, T *>
{
- typedef vtk_renderer_filter type;
+ typedef vtk::pointer_proxy_producer<T> type;
};
template<typename T>
-struct consumer_category_of<
- vtk, T,
- typename boost::enable_if<boost::is_base_of<vtkRenderWindow,T> >::type
->
+struct proxy_consumer_category_of<vtk::mechanism, T *>
{
- typedef vtk_rendererwindow_consumer type;
+ typedef vtk::pointer_proxy_consumer<T> type;
};
-} }
+namespace extension {
-template<typename Producer, typename Consumer>
-inline void connect(Producer &producer, Consumer &consumer)
-{
- boost::dataflow::connect<boost::dataflow::vtk>(producer, consumer);
-}
+ template<typename T>
+ struct get_proxied_producer_impl<vtk::mechanism, vtk::pointer_proxy_producer<T> >
+ {
+ template<typename ProxyProducer>
+ struct apply
+ {
+ typedef T & type;
+
+ static type call(ProxyProducer &t)
+ {
+ return *t;
+ }
+ };
+ };
-template<typename Producer, typename Consumer>
-inline void connect(const Producer &producer, Consumer &consumer)
-{
- boost::dataflow::connect<boost::dataflow::vtk>(producer, consumer);
+ template<typename T>
+ struct get_proxied_consumer_impl<vtk::mechanism, vtk::pointer_proxy_consumer<T> >
+ {
+ template<typename ProxyConsumer>
+ struct apply
+ {
+ typedef T & type;
+
+ static type call(ProxyConsumer &t)
+ {
+ return *t;
+ }
+ };
+ };
+
}
-template<typename Producer, typename Consumer>
-inline void connect(Producer &producer, const Consumer &consumer)
-{
- boost::dataflow::connect<boost::dataflow::vtk>(producer, consumer);
-}
+//]
-template<typename Producer, typename Consumer>
-inline void connect(const Producer &producer, const Consumer &consumer)
-{
- boost::dataflow::connect<boost::dataflow::vtk>(producer, consumer);
-}
+} }
+//[ vtk_specialize_connect
+#define DATAFLOW_TEMPLATE_MECHANISM boost::dataflow::vtk::mechanism
+#include <boost/dataflow/templates/connect.hpp>
+#undef DATAFLOW_TEMPLATE_MECHANISM
+//]
#endif // BOOST_DATAFLOW_VTK_SUPPORT_HPP
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/libs/dataflow/test/signals/test_storage.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/test/signals/test_storage.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/signals/test_storage.cpp 2007-10-10 16:28:19 EDT (Wed, 10 Oct 2007)
@@ -19,6 +19,9 @@
signals::storage<void (float), signals::unfused> floater(2.5f);
signals::storage<void (float), signals::unfused> collector(0.0f);
+ signals::slot_selector<void(), signals::storage<void (float), signals::unfused> >
+ ::dataflow<dataflow::signals_mechanism>::get_proxied_producer(fusion::front(floater.send_slot()).second);
+
// create the network (banger to floater.send, floater to collector)
banger >>= floater.send_slot() >>= collector;
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