|
Boost-Commit : |
From: srajko_at_[hidden]
Date: 2007-06-03 13:50:26
Author: srajko
Date: 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
New Revision: 4423
URL: http://svn.boost.org/trac/boost/changeset/4423
Log:
convert components to use fusion
Added:
sandbox/SOC/2007/signals/boost/signal_network/counter.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/serialize_fusion_vector.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/unfused_inherited.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/unfused_typed_class.hpp
sandbox/SOC/2007/signals/libs/signal_network/test/test_chain.cpp
sandbox/SOC/2007/signals/libs/signal_network/test/test_counter.cpp
sandbox/SOC/2007/signals/libs/signal_network/test/test_function.cpp
sandbox/SOC/2007/signals/libs/signal_network/test/test_junction.cpp
sandbox/SOC/2007/signals/libs/signal_network/test/test_mutex.cpp
sandbox/SOC/2007/signals/libs/signal_network/test/test_socket.cpp
sandbox/SOC/2007/signals/libs/signal_network/test/test_storage.cpp
Removed:
sandbox/SOC/2007/signals/boost/signal_network/collector.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/chain_template.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/function_template.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/junction_template.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/mutex_template.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/selector_template.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/socket_receiver_template.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/socket_sender_template.hpp
sandbox/SOC/2007/signals/boost/signal_network/detail/storage_template.hpp
sandbox/SOC/2007/signals/libs/signal_network/test/test.cpp
Text files modified:
sandbox/SOC/2007/signals/boost/signal_network/chain.hpp | 65 +++++++++++++++++++-
sandbox/SOC/2007/signals/boost/signal_network/detail/connect_template.hpp | 2
sandbox/SOC/2007/signals/boost/signal_network/filter.hpp | 15 ++++
sandbox/SOC/2007/signals/boost/signal_network/function.hpp | 36 ++++++++++-
sandbox/SOC/2007/signals/boost/signal_network/junction.hpp | 42 +++++++++++-
sandbox/SOC/2007/signals/boost/signal_network/mutex.hpp | 33 +++++++++
sandbox/SOC/2007/signals/boost/signal_network/selector.hpp | 40 ++++++++----
sandbox/SOC/2007/signals/boost/signal_network/socket_receiver.hpp | 38 ++++++++++-
sandbox/SOC/2007/signals/boost/signal_network/socket_sender.hpp | 53 +++++++++++++++-
sandbox/SOC/2007/signals/boost/signal_network/storage.hpp | 111 +++++++++++++++++++++++------------
sandbox/SOC/2007/signals/boost/signal_network/timed_generator.hpp | 2
sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/build.vcproj | 32 +--------
sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/example.vcproj | 4
sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/test.vcproj | 28 ++++++++
sandbox/SOC/2007/signals/libs/signal_network/example/example.cpp | 126 ++++++++++++++++++++++-----------------
sandbox/SOC/2007/signals/libs/signal_network/test/Jamfile.v2 | 17 ++--
16 files changed, 475 insertions(+), 169 deletions(-)
Modified: sandbox/SOC/2007/signals/boost/signal_network/chain.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/chain.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/chain.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -1,11 +1,68 @@
+// Copyright Stjepan Rajko 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
#ifndef SIGNAL_NETWORK_CHAIN_HPP
#define SIGNAL_NETWORK_CHAIN_HPP
#include <boost/signal_network/filter.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/fusion/sequence/adapted/mpl.hpp>
+#include <boost/signal_network/detail/unfused_inherited.hpp>
+
+SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
+
+template<typename T, typename Signature>
+class chain : public filter_base
+{
+public:
+ typedef boost::function_types::parameter_types<Signature> parameter_types;
+ typedef typename boost::fusion::result_of::as_vector<parameter_types >::type parameter_vector;
-#define SIGNAL_NETWORK_TEMPLATE_CLASS chain
-#define SIGNAL_NETWORK_TEMPLATE_BASE filter_base
-#define SIGNAL_NETWORK_TEMPLATE_TYPENAME_T
-#include <boost/signal_network/detail/loader.hpp>
+ typedef boost::fusion::unfused_inherited<chain<T, Signature>,
+ typename mpl::vector<size_t, T *>::type,
+ typename boost::function_types::parameter_types<Signature> > unfused;
+ chain(size_t copies, T *component=NULL)
+ {
+ initialize(copies, component);
+ }
+ ~chain()
+ {
+ delete[] components;
+ }
+ template <class Seq>
+ struct result
+ {
+ typedef typename boost::function_traits<Signature>::result_type type;
+ };
+ typename boost::function_traits<Signature>::result_type
+ operator()(const parameter_vector &vec_par)
+ {
+ return boost::fusion::fused<T &>(components[0])(vec_par);
+ }
+ boost::signal<Signature> &default_signal()
+ {
+ return components[size-1].default_signal();
+ }
+private:
+ void initialize(size_t copies, T *component=NULL)
+ {
+ size = copies;
+ components = new T[copies];
+ for (size_t i=0; i<copies-1; i++)
+ {
+ if (component) components[i] = *component;
+ components[i] >>= components[i+1];
+ }
+ if (component) components[size-1] = *component;
+ }
+ T *components;
+ size_t size;
+
+};
+
+SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
+
#endif // SIGNAL_NETWORK_CHAIN_HPP
Deleted: sandbox/SOC/2007/signals/boost/signal_network/collector.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/collector.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
+++ (empty file)
@@ -1,44 +0,0 @@
-#ifndef SIGNAL_NETWORK_COLLECTOR_HPP
-#define SIGNAL_NETWORK_COLLECTOR_HPP
-
-#include <boost/type_traits.hpp>
-#include <boost/call_traits.hpp>
-#include <boost/signal_network/detail/defines.hpp>
-
-SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
-
-/// Stores data received via a signal so that it can be retrieved.
-/** \param Signature Signature of the signal that collector can receive.
- \todo Currently collector only supports signatures of type void (type).
-
- Example:
- \dontinclude example.cpp
- \skip simple_test
- \until end void simple_test
-*/
-template<typename Signature>
-class collector
-{
-public:
- /// Type of the stored value
- typedef typename boost::remove_reference<typename boost::function_traits<Signature>::arg1_type>::type arg1_value_type;
-
- /// The default constructor will not initialize the stored value.
- collector(){}
- /// This constructor will initialize the stored value to what is provided.
- collector(typename boost::call_traits<arg1_value_type>::param_type init) : arg1_value(init) {}
- /// Stores the value in the signal.
- void operator()(typename boost::function_traits<Signature>::arg1_type arg1)
- {
- arg1_value = arg1;
- }
- /// Returns the last stored value.
- typename call_traits<arg1_value_type>::const_reference operator()() {return arg1_value;}
-private:
- /// Stored value.
- typename arg1_value_type arg1_value;
-};
-
-SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
-
-#endif // SIGNAL_NETWORK_COLLECTOR_HPP
\ No newline at end of file
Added: sandbox/SOC/2007/signals/boost/signal_network/counter.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/signal_network/counter.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,45 @@
+// Copyright Stjepan Rajko 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef SIGNAL_NETWORK_COUNTER_HPP
+#define SIGNAL_NETWORK_COUNTER_HPP
+
+#include <boost/signal_network/detail/defines.hpp>
+#include <boost/signal_network/detail/unfused_inherited.hpp>
+#include <boost/signal_network/filter.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/fusion/sequence/adapted/mpl.hpp>
+
+SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
+
+template<typename Signature, typename T=int>
+class counter : public fused_filter<Signature>
+{
+public:
+ typedef boost::fusion::unfused_inherited<counter<Signature, T>,
+ typename mpl::vector<>::type,
+ typename boost::function_types::parameter_types<Signature> > unfused;
+
+ counter() : count_(0) {}
+ template <class Seq>
+ struct result
+ {
+ typedef typename boost::function_traits<Signature>::result_type type;
+ };
+ typename boost::function_traits<Signature>::result_type
+ operator()(const typename fused_filter<Signature>::parameter_vector &vec_par)
+ {
+ count_++;
+ return static_cast<typename boost::function_traits<Signature>::result_type>
+ (fused_out(vec_par));
+ }
+ T count() {return count_;}
+private:
+ T count_;
+};
+
+SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
+
+#endif // SIGNAL_NETWORK_COUNT_HPP
\ No newline at end of file
Deleted: sandbox/SOC/2007/signals/boost/signal_network/detail/chain_template.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/detail/chain_template.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
+++ (empty file)
@@ -1,39 +0,0 @@
-#ifndef SIGNAL_NETWORK_TEMPLATE_BODY
-
- chain_impl(size_t copies, T *component=NULL)
- {
- initialize(copies, component);
- }
- ~chain_impl()
- {
- delete[] components;
- }
- SIGNAL_NETWORK_FUNCTION(SIGNAL_NETWORK_DEFAULT_SLOT,Signature,SIGNAL_NETWORK_TEMPLATE_ARITY)
- {
- SIGNAL_NETWORK_RETURN(_return) components[0](SIGNAL_NETWORK_ARG_NAMES(SIGNAL_NETWORK_TEMPLATE_ARITY));
- }
- boost::signal<Signature> &default_signal()
- {
- return components[size-1].default_signal();
- }
-private:
- void initialize(size_t copies, T *component=NULL)
- {
- size = copies;
- components = new T[copies];
- for (size_t i=0; i<copies-1; i++)
- {
- if (component) components[i] = *component;
- components[i] >>= components[i+1];
- }
- if (component) components[size-1] = *component;
- }
- T *components;
- size_t size;
-
-#else
-public:
- chain(size_t copies) : SIGNAL_NETWORK_TEMPLATE_CLASS_IMPL_BASE(copies) {}
- chain(size_t copies, T &component) : SIGNAL_NETWORK_TEMPLATE_CLASS_IMPL_BASE(copies, &component) {}
-
-#endif
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/boost/signal_network/detail/connect_template.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/detail/connect_template.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/detail/connect_template.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -2,7 +2,7 @@
static void connect(boost::signal<Signature> &signal, T &link)
{
signal.connect(boost::bind(
- (typename slot_type<T, Signature>::type) &T::operator(),
+ static_cast<typename slot_type<T, Signature>::type>( &T::operator() ),
boost::ref(link) SIGNAL_NETWORK_BIND_ARGS(SIGNAL_NETWORK_TEMPLATE_ARITY)));
}
#else
Deleted: sandbox/SOC/2007/signals/boost/signal_network/detail/function_template.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/detail/function_template.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
+++ (empty file)
@@ -1,15 +0,0 @@
-#ifndef SIGNAL_NETWORK_TEMPLATE_BODY
-public:
- function_impl() {}
-
- void operator()(SIGNAL_NETWORK_ARG_TYPENAMES(SIGNAL_NETWORK_TEMPLATE_ARITY))
- {
- out(func(SIGNAL_NETWORK_ARG_NAMES(SIGNAL_NETWORK_TEMPLATE_ARITY)));
- }
-
-protected:
- boost::function<Signature> func;
-#else
-public:
- function(boost::function<Signature> f) {SIGNAL_NETWORK_TEMPLATE_CLASS_IMPL_BASE::func = f;}
-#endif
\ No newline at end of file
Deleted: sandbox/SOC/2007/signals/boost/signal_network/detail/junction_template.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/detail/junction_template.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
+++ (empty file)
@@ -1,25 +0,0 @@
-/*
- * signal_junction_template.h
- * Utility
- *
- * Created by Stjepan Rajko on 3/9/07.
- * Copyright 2007 __MyCompanyName__. All rights reserved.
- *
- */
-
-#ifndef SIGNAL_NETWORK_TEMPLATE_BODY
-
-junction_impl() : enabled(true) {}
-void enable() {enabled = true;}
-void disable() {enabled = false;}
-SIGNAL_NETWORK_FUNCTION(SIGNAL_NETWORK_DEFAULT_SLOT,Signature,SIGNAL_NETWORK_TEMPLATE_ARITY)
-{
- if (enabled)
- SIGNAL_NETWORK_RETURN(_return) SIGNAL_NETWORK_TEMPLATE_BASE::out(SIGNAL_NETWORK_ARG_NAMES(SIGNAL_NETWORK_TEMPLATE_ARITY));
-}
-private:
-volatile bool enabled;
-
-#else
-
-#endif
\ No newline at end of file
Deleted: sandbox/SOC/2007/signals/boost/signal_network/detail/mutex_template.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/detail/mutex_template.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
+++ (empty file)
@@ -1,11 +0,0 @@
-#ifndef SIGNAL_NETWORK_TEMPLATE_BODY
- SIGNAL_NETWORK_FUNCTION(SIGNAL_NETWORK_DEFAULT_SLOT,Signature,SIGNAL_NETWORK_TEMPLATE_ARITY)
- {
- boost::mutex::scoped_lock lock(mutex_);
- SIGNAL_NETWORK_RETURN(_return) SIGNAL_NETWORK_TEMPLATE_BASE::out(SIGNAL_NETWORK_ARG_NAMES(SIGNAL_NETWORK_TEMPLATE_ARITY));
- }
- private:
- boost::mutex mutex_;
-#else
-
-#endif
Deleted: sandbox/SOC/2007/signals/boost/signal_network/detail/selector_template.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/detail/selector_template.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
+++ (empty file)
@@ -1,11 +0,0 @@
-#ifndef SIGNAL_NETWORK_TEMPLATE_BODY
-
- selector_impl() : selected(0) {}
- void select(int source) {selected = source;}
- BOOST_PP_REPEAT_FROM_TO(1,_inputs_inc,SIGNAL_NETWORK_SELECTOR_INPUT,SIGNAL_NETWORK_TEMPLATE_ARITY)
-private:
- volatile int selected;
-
-#else
-
-#endif
\ No newline at end of file
Added: sandbox/SOC/2007/signals/boost/signal_network/detail/serialize_fusion_vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/signal_network/detail/serialize_fusion_vector.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,83 @@
+#ifndef BOOST_SERIALIZE_FUSION_VECTOR_HPP
+#define BOOST_SERIALIZE_FUSION_VECTOR_HPP
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// vector.hpp - non-intrusive serialization of boost::fusion::vector
+//
+// copyright (c) 2005
+// troy d. straszheim <troy_at_[hidden]>
+// http://www.resophonic.com
+//
+// copyright 2007 Stjepan Rajko
+//
+// 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)
+//
+// See http://www.boost.org for updates, documentation, and revision history.
+//
+
+#include <boost/fusion/sequence/container/vector/vector.hpp>
+
+namespace boost {
+ namespace serialization {
+ namespace detail {
+ namespace vector {
+
+ // primary template, serializes a vector in the
+ // constructor. Class is called like a template function.
+ template <class Archive, class Tuple, int i=0, bool stop=false>
+ struct serialize_impl
+ {
+ serialize_impl(Archive &ar, Tuple& t)
+ {
+ char tag[3] = "T?";
+ tag[1] = '0' + i;
+ ar & make_nvp(tag, boost::fusion::at_c<i>(t));
+ serialize_impl<Archive, Tuple, i+1,
+ i+1 < boost::fusion::result_of::size<Tuple>::value ? false : true>(ar, t);
+ }
+ };
+
+ // no-op called by the primary template when "i" is out of
+ // bounds.
+ template <class Archive, class Tuple, int i>
+ struct serialize_impl<Archive, Tuple, i, true>
+ {
+ serialize_impl(Archive &ar, Tuple& t) { }
+ };
+
+ } // namespace vector
+ } // namespace detail
+
+ //
+ // primary interface functions. Serialize a vector...
+ //
+ template <class Archive,
+ typename T0, typename T1, typename T2, typename T3, typename T4,
+ typename T5, typename T6, typename T7, typename T8, typename T9>
+ void
+ serialize (Archive & ar,
+ boost::fusion::vector<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> & t,
+ unsigned int version)
+ {
+ detail::vector::serialize_impl<
+ Archive,
+ boost::fusion::vector<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>
+ >(ar, t);
+ }
+
+ //
+ // Serialize a "null" vector is a no-op
+ //
+ template <class Archive>
+ void
+ serialize (Archive & ar,
+ boost::fusion::vector<> & nullvector,
+ unsigned int version)
+ {
+ }
+ } // namespace serialization
+} // namespace boost
+
+#endif // BOOST_SERIALIZE_FUSION_VECTOR_HPP
\ No newline at end of file
Deleted: sandbox/SOC/2007/signals/boost/signal_network/detail/socket_receiver_template.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/detail/socket_receiver_template.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
+++ (empty file)
@@ -1,30 +0,0 @@
-#ifndef SIGNAL_NETWORK_TEMPLATE_BODY
-
-public:
- socket_receiver_impl(asio::ip::tcp::socket &socket) :
- socket_(socket),
- stream(std::ios::in | std::ios::out | std::ios::binary) {}
- void operator()()
- {
- int received_size = socket_.receive(asio::buffer(buffer, bufferSize));
- stream.str(empty_string);
- stream.write((char *)buffer, received_size);
- boost::archive::binary_iarchive archive(stream);
- BOOST_PP_REPEAT_FROM_TO(1,SIGNAL_NETWORK_TEMPLATE_ARITY_INC,SIGNAL_NETWORK_SOCKET_UNPACK,_)
-
- storage<Signature>::operator()();
- }
-
-private:
- asio::ip::tcp::socket &socket_;
- std::stringstream stream;
- std::string empty_string;
- boost::archive::binary_iarchive *archive;
- enum { bufferSize = 20000 };
- unsigned char buffer[bufferSize];
-#else
-
-public:
- socket_receiver(asio::ip::tcp::socket &socket) : SIGNAL_NETWORK_TEMPLATE_CLASS_IMPL_BASE (socket) {}
-
-#endif
\ No newline at end of file
Deleted: sandbox/SOC/2007/signals/boost/signal_network/detail/socket_sender_template.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/detail/socket_sender_template.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
+++ (empty file)
@@ -1,24 +0,0 @@
-#ifndef SIGNAL_NETWORK_TEMPLATE_BODY
-
-public:
- socket_sender_impl(asio::ip::tcp::socket &socket) :
- socket_(socket),
- stream(std::ios::in | std::ios::out | std::ios::binary) {};
- SIGNAL_NETWORK_FUNCTION(SIGNAL_NETWORK_DEFAULT_SLOT,Signature,SIGNAL_NETWORK_TEMPLATE_ARITY)
- {
- boost::archive::binary_oarchive archive (stream);
- BOOST_PP_REPEAT_FROM_TO(1,SIGNAL_NETWORK_TEMPLATE_ARITY_INC,SIGNAL_NETWORK_SOCKET_PACK,_)
- boost::asio::write(socket_, asio::buffer(stream.str()),
- boost::asio::transfer_all());
- stream.str(empty_string);
- }
-private:
- asio::ip::tcp::socket &socket_;
- std::stringstream stream;
- std::string empty_string;
-
-#else
-
-public:
- socket_sender(asio::ip::tcp::socket &socket) : SIGNAL_NETWORK_TEMPLATE_CLASS_IMPL_BASE(socket) {}
-#endif
\ No newline at end of file
Deleted: sandbox/SOC/2007/signals/boost/signal_network/detail/storage_template.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/detail/storage_template.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
+++ (empty file)
@@ -1,37 +0,0 @@
-/*
- * signal_storage_template.h
- * Utility
- *
- * Created by Stjepan Rajko on 3/9/07.
- * Copyright 2007 __MyCompanyName__. All rights reserved.
- *
- */
-
-#ifndef SIGNAL_NETWORK_TEMPLATE_BODY
-
-SIGNAL_NETWORK_ARGVAR_TYPEDEFS(SIGNAL_NETWORK_TEMPLATE_ARITY)
-BOOST_PP_IF(SIGNAL_NETWORK_TEMPLATE_ARITY,SIGNAL_NETWORK_STORAGE_SIGNAL,BOOST_PP_EMPTY)()
-typename SIGNAL_NETWORK_TEMPLATE_BASE::result_type operator()()
-{
- SIGNAL_NETWORK_RETURN(_return) SIGNAL_NETWORK_TEMPLATE_BASE::out(SIGNAL_NETWORK_ARGVAR_NAMES(SIGNAL_NETWORK_TEMPLATE_ARITY));
-}
-BOOST_PP_REPEAT_FROM_TO(1,SIGNAL_NETWORK_TEMPLATE_ARITY_INC,SIGNAL_NETWORK_RETURN_STORED,_)
-
-protected:
-SIGNAL_NETWORK_ARGVARS(SIGNAL_NETWORK_TEMPLATE_ARITY)
-
-#else
-#define SIGNAL_NETWORK_ARGVAR_REPEAT_TYPEDEF(z,n,text) typedef typename SIGNAL_NETWORK_TEMPLATE_CLASS_IMPL_BASE::arg##n##_value_type arg##n##_value_type;
-#define SIGNAL_NETWORK_ARGVAR_REPEAT_TYPEDEFS(n) BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(n,1),SIGNAL_NETWORK_ARGVAR_REPEAT_TYPEDEF,_)
-
-public:
- typedef SIGNAL_NETWORK_TEMPLATE_CLASS_IMPL_BASE base_class;
- storage() {}
- BOOST_PP_IF(SIGNAL_NETWORK_TEMPLATE_ARITY,
- storage(SIGNAL_NETWORK_ARGVAR_TYPENAMES(SIGNAL_NETWORK_TEMPLATE_ARITY,typename base_class:: ))
- {operator()(SIGNAL_NETWORK_ARGVAR_NAMES(SIGNAL_NETWORK_TEMPLATE_ARITY));},
- BOOST_PP_EMPTY())
-
-#undef SIGNAL_NETWORK_ARGVAR_REPEAT_TYPEDEF
-#undef SIGNAL_NETWORK_ARGVAR_REPEAT_TYPEDEFS
-#endif
Added: sandbox/SOC/2007/signals/boost/signal_network/detail/unfused_inherited.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/signal_network/detail/unfused_inherited.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,145 @@
+/*=============================================================================
+ Copyright (c) 2006-2007 Tobias Schwinger
+ Copyright (c) 2007 Stjepan Rajko
+
+ Use modification and distribution are 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).
+==============================================================================*/
+
+#if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_INHERITED_HPP_INCLUDED)
+#if !defined(BOOST_PP_IS_ITERATING)
+
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/enum_binary_params.hpp>
+#include <boost/preprocessor/facilities/intercept.hpp>
+
+#include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
+
+#include <boost/mpl/and.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+
+#include <boost/fusion/support/detail/access.hpp>
+#include <boost/fusion/sequence/intrinsic/value_at.hpp>
+#include <boost/fusion/sequence/intrinsic/size.hpp>
+#include <boost/fusion/sequence/container/vector/vector.hpp>
+#include <boost/fusion/sequence/conversion/as_vector.hpp>
+#include <boost/fusion/algorithm/transformation/pop_back.hpp>
+
+#include <boost/fusion/functional/adapter/limits.hpp>
+#include <boost/fusion/functional/adapter/detail/has_type.hpp>
+#include <boost/fusion/functional/adapter/detail/nullary_call_base.hpp>
+
+#include <boost/mpl/size.hpp>
+
+
+namespace boost { namespace fusion
+{
+
+ template <class Function, class CSequence, class Sequence, typename Enable=void> class unfused_inherited;
+
+ //----- ---- --- -- - - - -
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (0,BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY, <boost/signal_network/detail/unfused_inherited.hpp>))
+ #include BOOST_PP_ITERATE()
+}}
+
+#define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_INHERITED_HPP_INCLUDED
+#else // defined(BOOST_PP_IS_ITERATING)
+///////////////////////////////////////////////////////////////////////////////
+//
+// Preprocessor vertical repetition code
+//
+///////////////////////////////////////////////////////////////////////////////
+
+# if BOOST_PP_ITERATION_DEPTH()== 2
+
+#define CONSTRUCTOR_ARGS BOOST_PP_FRAME_ITERATION(1)
+#define OPERATOR_ARGS BOOST_PP_FRAME_ITERATION(2)
+
+ template <class Function, class CSequence, class Sequence>
+ class unfused_inherited<Function, CSequence, Sequence,
+ typename boost::enable_if<
+ boost::mpl::and_<
+ boost::mpl::equal_to<
+ boost::fusion::result_of::size<CSequence>,
+ boost::mpl::int_<CONSTRUCTOR_ARGS> >,
+ boost::mpl::equal_to<
+ boost::fusion::result_of::size<Sequence>,
+ boost::mpl::int_<OPERATOR_ARGS> >
+ > >::type >
+ : public Function
+ {
+ typedef typename result_of::as_vector<CSequence>::type carg_vector_t;
+ typedef typename result_of::as_vector<Sequence>::type arg_vector_t;
+
+ public:
+ using Function::operator();
+
+#define M(z,i,s) \
+ typename result_of::value_at_c<s,i>::type a##i
+#define ADAPTED_ARGS(z,i,s) \
+ typename detail::call_param<typename result_of::value_at_c<s,i>::type>::type a##i
+
+ unfused_inherited(BOOST_PP_ENUM(CONSTRUCTOR_ARGS,ADAPTED_ARGS,carg_vector_t))
+ : Function(BOOST_PP_ENUM_PARAMS(CONSTRUCTOR_ARGS,a))
+ { }
+
+#if OPERATOR_ARGS>0
+ inline typename Function::template result<arg_vector_t>::type
+ operator()(BOOST_PP_ENUM(OPERATOR_ARGS,M,arg_vector_t)) const
+ {
+ arg_vector_t arg(BOOST_PP_ENUM_PARAMS(OPERATOR_ARGS,a));
+ return Function::operator()(arg);
+ }
+
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+ void//inline typename Function::template result<arg_vector_t>::type
+ operator()(BOOST_PP_ENUM(OPERATOR_ARGS,M,arg_vector_t))
+ {
+ arg_vector_t arg(BOOST_PP_ENUM_PARAMS(OPERATOR_ARGS,a));
+ return Function::operator()(arg);
+ }
+#endif
+
+#else
+ inline typename Function::template result<arg_vector_t>::type
+ operator()() const
+ {
+ arg_vector_t arg;
+ return Function::operator()(arg);
+ }
+
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+ inline typename Function::template result<arg_vector_t>::type
+ operator()()
+ {
+ arg_vector_t arg;
+ return Function::operator()(arg);
+ }
+#endif
+
+#endif
+
+#undef M
+#undef ADAPTED_ARGS
+
+ };
+
+#undef CONSTRUCTOR_ARGS
+#undef OPERATOR_ARGS
+
+#else
+
+#define BOOST_PP_ITERATION_PARAMS_2 (3, (0,BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY,<boost/signal_network/detail/unfused_inherited.hpp>))
+#include BOOST_PP_ITERATE()
+
+#endif
+
+#endif // defined(BOOST_PP_IS_ITERATING)
+#endif
+
Added: sandbox/SOC/2007/signals/boost/signal_network/detail/unfused_typed_class.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/signal_network/detail/unfused_typed_class.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,119 @@
+/*=============================================================================
+ Copyright (c) 2006-2007 Tobias Schwinger
+ Copyright (c) 2007 Stjepan Rajko
+
+ Use modification and distribution are 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).
+==============================================================================*/
+
+#if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_TYPED_CLASS_HPP_INCLUDED)
+#if !defined(BOOST_PP_IS_ITERATING)
+
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/enum_binary_params.hpp>
+#include <boost/preprocessor/facilities/intercept.hpp>
+
+#include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
+
+#include <boost/mpl/and.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+
+#include <boost/fusion/support/detail/access.hpp>
+#include <boost/fusion/sequence/intrinsic/value_at.hpp>
+#include <boost/fusion/sequence/intrinsic/size.hpp>
+#include <boost/fusion/sequence/container/vector/vector.hpp>
+#include <boost/fusion/sequence/conversion/as_vector.hpp>
+#include <boost/fusion/algorithm/transformation/pop_back.hpp>
+
+#include <boost/fusion/functional/adapter/limits.hpp>
+#include <boost/fusion/functional/adapter/detail/has_type.hpp>
+#include <boost/fusion/functional/adapter/detail/nullary_call_base.hpp>
+
+#include <boost/mpl/size.hpp>
+
+
+namespace boost { namespace fusion
+{
+
+ template <class Function, class Sequence, typename Enable=void> class unfused_typed_class;
+
+ //----- ---- --- -- - - - -
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (0,BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY, <boost/signal_network/detail/unfused_typed_class.hpp>))
+ #include BOOST_PP_ITERATE()
+}}
+
+#define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_TYPED_CLASS_HPP_INCLUDED
+#else // defined(BOOST_PP_IS_ITERATING)
+///////////////////////////////////////////////////////////////////////////////
+//
+// Preprocessor vertical repetition code
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#define OPERATOR_ARGS BOOST_PP_ITERATION()
+#define CONSTRUCTOR_ARGS BOOST_PP_ITERATION()
+
+ template <class Function, class Sequence>
+ class unfused_typed_class<Function, Sequence,
+ typename boost::enable_if<
+ typename boost::mpl::equal_to<
+ typename boost::fusion::result_of::size<Sequence>::type,
+ typename boost::mpl::int_<OPERATOR_ARGS>::type >::type
+ >::type>
+ : public Function
+ {
+ typedef typename result_of::as_vector<Sequence>::type carg_vector_t;
+ typedef typename result_of::as_vector<Sequence>::type arg_vector_t;
+
+ public:
+
+ using Function::operator();
+
+ inline explicit unfused_typed_class()
+ { }
+
+#define M(z,i,s) \
+ typename result_of::value_at_c<s,i>::type a##i
+
+#if CONSTRUCTOR_ARGS>0
+
+ inline explicit unfused_typed_class(BOOST_PP_ENUM(CONSTRUCTOR_ARGS,M,carg_vector_t))
+ : Function(carg_vector_t(BOOST_PP_ENUM_PARAMS(CONSTRUCTOR_ARGS,a)))
+ { }
+
+#endif
+
+#if OPERATOR_ARGS>0
+ inline typename Function::template result<arg_vector_t>::type
+ operator()(BOOST_PP_ENUM(OPERATOR_ARGS,M,arg_vector_t)) const
+ {
+ arg_vector_t arg(BOOST_PP_ENUM_PARAMS(OPERATOR_ARGS,a));
+ return Function::operator()(arg);
+ }
+
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
+ inline typename Function::template result<arg_vector_t>::type
+ operator()(BOOST_PP_ENUM(OPERATOR_ARGS,M,arg_vector_t))
+ {
+ arg_vector_t arg(BOOST_PP_ENUM_PARAMS(OPERATOR_ARGS,a));
+ return Function::operator()(arg);
+ }
+#endif
+
+#endif
+
+#undef M
+
+ };
+#undef CONSTRUCTOR_ARGS
+#undef OPERATOR_ARGS
+
+#endif // defined(BOOST_PP_IS_ITERATING)
+#endif
+
Modified: sandbox/SOC/2007/signals/boost/signal_network/filter.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/filter.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/filter.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -11,6 +11,8 @@
#include <boost/bind.hpp>
#include <boost/signal_network/base.hpp>
#include <boost/type_traits/is_base_of.hpp>
+#include <boost/fusion/functional/adapter/fused.hpp>
+#include <boost/fusion/sequence/conversion/as_vector.hpp>
SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
@@ -45,6 +47,19 @@
signal_type out;
}; // class filter
+template<typename Signature>
+class fused_filter : public filter<Signature>
+{
+public:
+ fused_filter() : fused_out(filter<Signature>::out) {}
+
+protected:
+ typedef boost::function_types::parameter_types<Signature> parameter_types;
+ typedef typename boost::fusion::result_of::as_vector<parameter_types >::type parameter_vector;
+
+ boost::fusion::fused<typename filter<Signature>::signal_type const &> fused_out;
+}; // class filter
+
SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
#endif // SIGNAL_NETWORK_FILTER_HPP
Modified: sandbox/SOC/2007/signals/boost/signal_network/function.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/function.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/function.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -11,10 +11,38 @@
#include <boost/signal_network/filter.hpp>
#include <boost/signal_network/detail/defines.hpp>
#include <boost/function.hpp>
+#include <boost/signal_network/detail/unfused_inherited.hpp>
+#include <boost/mpl/vector.hpp>
-#define SIGNAL_NETWORK_TEMPLATE_CLASS function
-#define SIGNAL_NETWORK_TEMPLATE_BASE filter<void (typename boost::function_traits<Signature>::result_type)>
-#define SIGNAL_NETWORK_TEMPLATE_NO_RETURNS
-#include <boost/signal_network/detail/loader.hpp>
+SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
+
+template<typename Signature>
+class function : public filter<void (typename boost::function_traits<Signature>::result_type)>
+{
+ typedef boost::function_types::parameter_types<Signature> ParTypes;
+public:
+ typedef boost::fusion::unfused_inherited<function<Signature>,
+ typename mpl::vector<boost::function<Signature> >::type,
+ typename boost::function_types::parameter_types<Signature> > unfused;
+
+ function(boost::function<Signature> f) :
+ func(f),
+ fused_func(boost::fusion::fused<boost::function<Signature> const &>(func)) {}
+ template <class Seq>
+ struct result
+ {
+ typedef void type;
+ };
+ template <class Seq>
+ void operator()(const Seq &vec_par)
+ {
+ out(fused_func(vec_par));
+ }
+protected:
+ boost::function<Signature> func;
+ boost::fusion::fused<boost::function<Signature> const &> fused_func;
+};
+
+SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
#endif // SIGNAL_NETWORK_FUNCTION_HPP
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/boost/signal_network/junction.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/junction.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/junction.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -1,5 +1,3 @@
-// junction.hpp
-
// 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
@@ -12,9 +10,41 @@
#include <boost/signal_network/detail/defines.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits.hpp>
+#include <boost/signal_network/detail/unfused_inherited.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/fusion/sequence/adapted/mpl.hpp>
+
+SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
+
+template<typename Signature>
+class junction : public fused_filter<Signature>
+{
+public:
+ typedef boost::fusion::unfused_inherited<junction<Signature>,
+ typename mpl::vector<>::type,
+ typename boost::function_types::parameter_types<Signature> > unfused;
+
+ junction() : enabled(true) {}
+ void enable() {enabled = true;}
+ void disable() {enabled = false;}
+
+ template <class Seq>
+ struct result
+ {
+ typedef typename boost::function_traits<Signature>::result_type type;
+ };
+
+ typename boost::function_traits<Signature>::result_type
+ operator()(const typename fused_filter<Signature>::parameter_vector &vec_par)
+ {
+ if (enabled)
+ return static_cast<typename boost::function_traits<Signature>::result_type>
+ (fused_out(vec_par));
+ }
+private:
+ volatile bool enabled;
+};
-#define SIGNAL_NETWORK_TEMPLATE_CLASS junction
-#define SIGNAL_NETWORK_TEMPLATE_BASE filter<Signature>
-#include <boost/signal_network/detail/loader.hpp>
+SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
-#endif
+#endif
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/boost/signal_network/mutex.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/mutex.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/mutex.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -11,9 +11,36 @@
#include <boost/signal_network/filter.hpp>
#include <boost/signal_network/detail/defines.hpp>
#include <boost/thread/mutex.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/fusion/sequence/adapted/mpl.hpp>
+#include <boost/signal_network/detail/unfused_inherited.hpp>
-#define SIGNAL_NETWORK_TEMPLATE_CLASS mutex
-#define SIGNAL_NETWORK_TEMPLATE_BASE filter<Signature>
-#include <boost/signal_network/detail/loader.hpp>
+SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
+
+template<typename Signature>
+class mutex : public fused_filter<Signature>
+{
+public:
+ typedef boost::fusion::unfused_inherited<mutex<Signature>,
+ typename mpl::vector<>::type,
+ typename boost::function_types::parameter_types<Signature> > unfused;
+
+ template <class Seq>
+ struct result
+ {
+ typedef typename boost::function_traits<Signature>::result_type type;
+ };
+ typename boost::function_traits<Signature>::result_type
+ operator()(const typename fused_filter<Signature>::parameter_vector &vec_par)
+ {
+ boost::mutex::scoped_lock lock(mutex_);
+ return static_cast<typename boost::function_traits<Signature>::result_type>
+ (fused_out(vec_par));
+ }
+ private:
+ boost::mutex mutex_;
+};
+
+SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
#endif // SIGNAL_NETWORK_MUTEX_HPP
Modified: sandbox/SOC/2007/signals/boost/signal_network/selector.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/selector.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/selector.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -11,19 +11,33 @@
#include <boost/signal_network/filter.hpp>
#include <boost/signal_network/detail/defines.hpp>
-#define SIGNAL_NETWORK_SELECTOR_INPUT(z,n,_arity) \
- SIGNAL_NETWORK_FUNCTION(input##n, Signature, _arity) \
- { \
- if (selected == n) \
- SIGNAL_NETWORK_TEMPLATE_BASE::out(SIGNAL_NETWORK_ARG_NAMES(_arity)); \
- } \
- slot_selector_t<selector_impl<_inputs, Signature, _arity>, Signature> slot##n () \
+SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
+/*
+template<typename Signature>
+class selector : public fused_filter<Signature>
+{
+ selector() : selected(0) {}
+ void select(int source) {selected = source;}
+
+ template <class Seq>
+ struct result
+ {
+ typedef typename boost::function_traits<Signature>::result_type type;
+ };
+ typename boost::function_traits<Signature>::result_type
+ operator()(const VecPar &vec_par)
+ {
+ if (selected == n)
+ return static_cast<typename boost::function_traits<Signature>::result_type>
+ (fused_out(vec_par));
+ }
+ template<int N>
+ slot_selector_t<selector<Signature>, Signature> slot()
{return slot_selector<Signature>(*this, &selector_impl<_inputs, Signature, _arity>::input##n);}
-
-#define SIGNAL_NETWORK_TEMPLATE_CLASS selector
-#define SIGNAL_NETWORK_TEMPLATE_BASE filter<Signature>
-#define SIGNAL_NETWORK_TEMPLATE_ITERATE2
-
-#include <boost/signal_network/detail/loader.hpp>
+private:
+ volatile int selected;
+};
+*/
+SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
#endif // SIGNAL_NETWORK_SELECTOR_HPP
Modified: sandbox/SOC/2007/signals/boost/signal_network/socket_receiver.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/socket_receiver.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/socket_receiver.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -12,13 +12,41 @@
#include <sstream>
#include <boost/asio.hpp>
#include <boost/archive/binary_iarchive.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#include <boost/signal_network/detail/serialize_fusion_vector.hpp>
-#define SIGNAL_NETWORK_SOCKET_UNPACK(z,n,text) archive & storage<Signature>::arg##n##_value;
+SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
-#define SIGNAL_NETWORK_TEMPLATE_CLASS socket_receiver
-#define SIGNAL_NETWORK_TEMPLATE_BASE storage<Signature>
-#include <boost/signal_network/detail/loader.hpp>
+template<typename Signature>
+class socket_receiver : public storage<Signature>
+{
+public:
+ typedef boost::fusion::unfused_typed_class<socket_receiver<Signature>,
+ typename boost::function_types::parameter_types<Signature> > unfused;
+
+ socket_receiver(asio::ip::tcp::socket &socket) :
+ socket_(socket),
+ stream(std::ios::in | std::ios::out | std::ios::binary) {}
+ void operator()()
+ {
+ int received_size = socket_.receive(asio::buffer(buffer, bufferSize));
+ stream.str(empty_string);
+ stream.write((char *)buffer, received_size);
+ boost::archive::binary_iarchive archive(stream);
+ archive & storage::stored;
+ storage<Signature>::operator()();
+ }
+
+private:
+ asio::ip::tcp::socket &socket_;
+ std::stringstream stream;
+ std::string empty_string;
+ boost::archive::binary_iarchive *archive;
+ enum { bufferSize = 20000 };
+ unsigned char buffer[bufferSize];
+};
-#undef SIGNAL_NETWORK_SOCKET_UNPACK
+SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
#endif
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/boost/signal_network/socket_sender.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/socket_sender.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/socket_sender.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -8,16 +8,61 @@
#ifndef SIGNAL_NETWORK_SOCKET_SENDER_HPP
#define SIGNAL_NETWORK_SOCKET_SENDER_HPP
+#include <boost/mpl/vector.hpp>
#include <boost/signal_network/filter.hpp>
#include <boost/asio.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <sstream>
+#include <boost/signal_network/detail/unfused_inherited.hpp>
+#include <boost/signal_network/detail/serialize_fusion_vector.hpp>
-#define SIGNAL_NETWORK_SOCKET_PACK(z,n,text) archive & arg##n;
+SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
+
+template<typename Signature>
+class socket_sender
+{
+public:
+ typedef boost::fusion::unfused_inherited<socket_sender<Signature>,
+ typename mpl::vector<asio::ip::tcp::socket &>::type,
+ typename boost::function_types::parameter_types<Signature> > unfused;
+
+ typedef boost::function_types::parameter_types<Signature> ParTypes;
-#define SIGNAL_NETWORK_TEMPLATE_CLASS socket_sender
-#include <boost/signal_network/detail/loader.hpp>
+ socket_sender(asio::ip::tcp::socket & socket) :
+ socket(& socket),
+ stream(std::ios::in | std::ios::out | std::ios::binary)
+ { }
+ socket_sender() :
+ socket(NULL),
+ stream(std::ios::in | std::ios::out | std::ios::binary)
+ { }
+ virtual ~socket_sender()
+ {
+ }
-#undef SIGNAL_NETWORK_SOCKET_PACK
+ template<class Seq>
+ struct result
+ {
+ typedef void type;
+ };
+ template <class Seq>
+ void operator()(const Seq &vec_par)
+ {
+ if (socket)
+ {
+ boost::archive::binary_oarchive archive (stream);
+ archive & vec_par;
+ boost::asio::write(*socket, asio::buffer(stream.str()),
+ boost::asio::transfer_all());
+ stream.str(empty_string);
+ }
+ }
+private:
+ asio::ip::tcp::socket *socket;
+ std::stringstream stream;
+ std::string empty_string;
+};
+
+SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
#endif
Modified: sandbox/SOC/2007/signals/boost/signal_network/storage.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/storage.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/storage.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -13,6 +13,16 @@
#include <boost/type_traits.hpp>
#include <boost/call_traits.hpp>
+#include <boost/function_types/parameter_types.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/mpl/transform.hpp>
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+#include <boost/fusion/sequence/adapted/mpl.hpp>
+#include <boost/fusion/functional/adapter/fused.hpp>
+
+#include <boost/signal_network/detail/unfused_typed_class.hpp>
+
SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
namespace detail {
@@ -22,46 +32,71 @@
struct storable : public boost::remove_const<typename boost::remove_reference<T>::type > {};
}
-SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
-#define SIGNAL_NETWORK_ARGVAR_TYPEDEF(z,n,text) typedef typename boost::signal_network::signet::detail::storable<typename boost::function_traits<Signature>::arg##n##_type>::type arg##n##_value_type;
-#define SIGNAL_NETWORK_ARGVAR_TYPEDEFS(n) BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(n,1),SIGNAL_NETWORK_ARGVAR_TYPEDEF,_)
+template<typename Signature>
+class storage : public boost::signal_network::signet::filter<Signature>
+{
+public:
+ typedef boost::signal_network::signet::filter<Signature> base_type;
+
+ typedef boost::function_types::parameter_types<Signature> ParTypes;
+ typedef typename boost::mpl::transform<
+ typename boost::mpl::transform<ParTypes, boost::remove_reference<boost::mpl::_> >::type,
+ boost::remove_const<boost::mpl::_> >::type StorableTypes;
+ typedef typename boost::fusion::result_of::as_vector<StorableTypes >::type VecStorable;
+
+ typedef boost::fusion::unfused_typed_class<storage<Signature>,
+ typename boost::function_types::parameter_types<Signature> > unfused;
+
+ storage(const VecStorable &vec_par) : fused_out(out), stored(vec_par) {}
+ storage() : fused_out(out) {}
+
+ template<class Seq>
+ struct result
+ {
+ typedef void type;
+ };
+
+ void operator()()
+ {
+ fused_out(stored);
+ }
+ template <class Seq>
+ void operator()(const Seq &vec_par)
+ {
+ stored = vec_par;
+ }
+ const VecStorable &value()
+ {
+ return stored;
+ }
+ template<int N>
+ typename boost::fusion::result_of::at_c<VecStorable, N>::type value_()
+ {
+ return boost::fusion::at_c<N>(stored);
+ }
+ template<int N>
+ typename boost::mpl::at_c<ParTypes, N>::type value_exact()
+ {
+ return boost::fusion::at_c<N>(stored);
+ }
+ template<int N>
+ slot_selector_t<storage<Signature>,// typename boost::call_traits<
+ typename boost::mpl::at_c<ParTypes, N>::type ()
+ >//::param_type ()>
+ slot()
+ {
+ return boost::signal_network::slot_selector<//typename boost::call_traits<
+ typename boost::mpl::at_c<ParTypes, N>::type
+ ()>(*this, &storage<Signature>::value_exact<N>);
+ }
+
+protected:
+ VecStorable stored;
+ boost::fusion::fused<typename base_type::signal_type const &> fused_out;
+};
-#define SIGNAL_NETWORK_ARGVAR(z,n,text) arg##n##_value_type arg##n##_value;
-#define SIGNAL_NETWORK_ARGVARS(n) BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(n,1),SIGNAL_NETWORK_ARGVAR,_)
-
-#define SIGNAL_NETWORK_ARGVAR_TYPENAME(n,text) typename boost::call_traits<text arg##n##_value_type>::param_type arg##n##_value
-#define SIGNAL_NETWORK_ARGVAR_TYPENAME_COMMA(z,n,text) SIGNAL_NETWORK_ARGVAR_TYPENAME(n,text) BOOST_PP_COMMA()
-#define SIGNAL_NETWORK_ARGVAR_TYPENAMES(n,text) BOOST_PP_REPEAT_FROM_TO(1,n,SIGNAL_NETWORK_ARGVAR_TYPENAME_COMMA,text) BOOST_PP_IF(n,SIGNAL_NETWORK_ARGVAR_TYPENAME(n,text),BOOST_PP_EMPTY())
-
-#define SIGNAL_NETWORK_ARGVAR_NAME(n) arg##n##_value
-#define SIGNAL_NETWORK_ARGVAR_NAME_COMMA(z,n,text) SIGNAL_NETWORK_ARGVAR_NAME(n) BOOST_PP_COMMA()
-#define SIGNAL_NETWORK_ARGVAR_NAMES(n) BOOST_PP_REPEAT_FROM_TO(1,n,SIGNAL_NETWORK_ARGVAR_NAME_COMMA,_) BOOST_PP_IF(n,SIGNAL_NETWORK_ARGVAR_NAME(n),BOOST_PP_EMPTY())
-
-#define SIGNAL_NETWORK_SET_ARGVAR(z,n,text) this->arg##n##_value = arg##n##_value;
-//#define SIGNAL_NETWORK_SET_ARGVAR_COMMA(z,n,text) SIGNAL_NETWORK_SET_ARGVAR(n) BOOST_PP_COMMA()
-//#define SIGNAL_NETWORK_SET_ARGVARS(n) BOOST_PP_REPEAT_FROM_TO(1,n,SIGNAL_NETWORK_SET_ARGVAR_COMMA,_) BOOST_PP_IF(n,SIGNAL_NETWORK_SET_ARGVAR(n),BOOST_PP_EMPTY())
-#define SIGNAL_NETWORK_SET_ARGVARS(n) BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_INC(n),SIGNAL_NETWORK_SET_ARGVAR,_)
-
-#define SIGNAL_NETWORK_RETURN_STORED(z,n,text) \
- typename boost::call_traits<arg##n##_value_type>::param_type value##n() {return arg##n##_value;} \
- slot_selector_t<storage_impl<Signature, SIGNAL_NETWORK_TEMPLATE_ARITY>, typename boost::call_traits<arg##n##_value_type>::param_type ()> slot##n () \
- {return slot_selector<typename boost::call_traits<arg##n##_value_type>::param_type ()>(*this, &storage_impl<Signature, SIGNAL_NETWORK_TEMPLATE_ARITY>::value##n);} \
- arg##n##_value_type value_exact##n() {return arg##n##_value;} \
- slot_selector_t<storage_impl<Signature, SIGNAL_NETWORK_TEMPLATE_ARITY>, arg##n##_value_type ()> slot_exact##n () \
- {return slot_selector<arg##n##_value_type ()>(*this, &storage_impl<Signature, SIGNAL_NETWORK_TEMPLATE_ARITY>::value_exact##n);}
-
-
-#define SIGNAL_NETWORK_STORAGE_SIGNAL() \
-void operator()(SIGNAL_NETWORK_ARGVAR_TYPENAMES(SIGNAL_NETWORK_TEMPLATE_ARITY,BOOST_PP_EMPTY())) \
-{ \
- SIGNAL_NETWORK_SET_ARGVARS(SIGNAL_NETWORK_TEMPLATE_ARITY) \
-}
+SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
-#define SIGNAL_NETWORK_TEMPLATE_CLASS storage
-#define SIGNAL_NETWORK_TEMPLATE_BASE filter<Signature>
-#define SIGNAL_NETWORK_TEMPLATE_ITERATE_MAIN_CLASS
-#include <boost/signal_network/detail/loader.hpp>
-#undef SIGNAL_NETWORK_STORAGE_SIGNAL
#endif // SIGNAL_NETWORK_GENERATOR_HPP
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/boost/signal_network/timed_generator.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/timed_generator.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/timed_generator.hpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -21,7 +21,7 @@
*/
template<class Signature>
-class timed_generator : public storage<Signature>
+class timed_generator : public storage<Signature>::unfused
{
public:
/// Default constructor. Starts the thread, but signals won't be sent until the enable() function is called.
Modified: sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/build.vcproj
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/build.vcproj (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/build.vcproj 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -69,10 +69,6 @@
>
</File>
<File
- RelativePath="..\..\..\..\boost\signal_network\collector.hpp"
- >
- </File>
- <File
RelativePath="..\..\..\..\boost\signal_network\filter.hpp"
>
</File>
@@ -116,10 +112,6 @@
Name="detail"
>
<File
- RelativePath="..\..\..\..\boost\signal_network\detail\chain_template.hpp"
- >
- </File>
- <File
RelativePath="..\..\..\..\boost\signal_network\detail\connect_slot_template.hpp"
>
</File>
@@ -132,14 +124,6 @@
>
</File>
<File
- RelativePath="..\..\..\..\boost\signal_network\detail\function_template.hpp"
- >
- </File>
- <File
- RelativePath="..\..\..\..\boost\signal_network\detail\junction_template.hpp"
- >
- </File>
- <File
RelativePath="..\..\..\..\boost\signal_network\detail\loader.hpp"
>
</File>
@@ -148,11 +132,7 @@
>
</File>
<File
- RelativePath="..\..\..\..\boost\signal_network\detail\mutex_template.hpp"
- >
- </File>
- <File
- RelativePath="..\..\..\..\boost\signal_network\detail\selector_template.hpp"
+ RelativePath="..\..\..\..\boost\signal_network\detail\serialize_fusion_vector.hpp"
>
</File>
<File
@@ -160,23 +140,23 @@
>
</File>
<File
- RelativePath="..\..\..\..\boost\signal_network\detail\socket_receiver_template.hpp"
+ RelativePath="..\..\..\..\boost\signal_network\detail\template_loader.hpp"
>
</File>
<File
- RelativePath="..\..\..\..\boost\signal_network\detail\socket_sender_template.hpp"
+ RelativePath="..\..\..\..\boost\signal_network\detail\template_loader2.hpp"
>
</File>
<File
- RelativePath="..\..\..\..\boost\signal_network\detail\storage_template.hpp"
+ RelativePath="..\..\..\..\boost\signal_network\detail\unfused_inherited.hpp"
>
</File>
<File
- RelativePath="..\..\..\..\boost\signal_network\detail\template_loader.hpp"
+ RelativePath="..\..\..\..\boost\signal_network\detail\unfused_typed_class.hpp"
>
</File>
<File
- RelativePath="..\..\..\..\boost\signal_network\detail\template_loader2.hpp"
+ RelativePath="..\..\..\..\boost\signal_network\detail\unfused_typed_class2.hpp"
>
</File>
</Filter>
Modified: sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/example.vcproj
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/example.vcproj (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/example.vcproj 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -28,7 +28,7 @@
CleanCommandLine="bjam --v2 --clean ../../$(ProjectName) $(ConfigurationName)"
Output="$(OutDir)\example.exe"
PreprocessorDefinitions=""
- IncludeSearchPath="..\../example"
+ IncludeSearchPath="../../../"
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
@@ -48,7 +48,7 @@
CleanCommandLine="bjam --v2 --clean ../../$(ProjectName) $(ConfigurationName)"
Output="$(OutDir)\example.exe"
PreprocessorDefinitions=""
- IncludeSearchPath=""
+ IncludeSearchPath="../../../../"
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
Modified: sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/test.vcproj
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/test.vcproj (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/build/vc8ide/test.vcproj 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -66,6 +66,34 @@
RelativePath="..\..\test\test.cpp"
>
</File>
+ <File
+ RelativePath="..\..\test\test_chain.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\test\test_counter.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\test\test_function.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\test\test_junction.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\test\test_mutex.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\test\test_socket.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\test\test_storage.cpp"
+ >
+ </File>
</Filter>
<File
RelativePath="..\..\test\Jamfile.v2"
Modified: sandbox/SOC/2007/signals/libs/signal_network/example/example.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/example/example.cpp (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/example/example.cpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -6,6 +6,8 @@
// http://www.boost.org/LICENSE_1_0.txt)
#define _CRT_SECURE_NO_DEPRECATE 1
+#include <boost/fusion/sequence/generation/make_vector.hpp>
+
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
@@ -115,29 +117,29 @@
void simple_test()
{
// instantiate all of the components we need
- signet::storage<void ()> banger;
- signet::storage<void (float)> floater(2.5f);
- signet::storage<void (float)> collector(0.0f);
+ signet::storage<void ()>::unfused banger;
+ signet::storage<void (float)>::unfused floater(2.5f);
+ signet::storage<void (float)>::unfused collector(0.0f);
// create the network
banger >>= floater >>= collector;
banger(); // signal from banger will now cause floater to output 2.5
- BOOST_CHECK(collector.value1() == 2.5f);
+ BOOST_CHECK(collector.value_<0>() == 2.5f);
floater(1.5f); // change the value in floater
floater(); // we can also signal floater directly
- BOOST_CHECK(collector.value1() == 1.5f);
+ BOOST_CHECK(collector.value_<0>() == 1.5f);
} // end void simple_test()
void branching_test()
{
- signet::storage<void ()> banger;
+ signet::storage<void ()>::unfused banger;
SignalVoidCounter counter;
- signet::storage<void (float)> floater;
+ signet::storage<void (float)>::unfused floater;
floater(2.5f);
- signet::storage<void (float)> collector(0.0f);
+ signet::storage<void (float)>::unfused collector(0.0f);
banger
| (floater >>= collector) // floater connects to collector, banger to floater
@@ -145,17 +147,17 @@
banger();
BOOST_CHECK(counter.GetCount() == 1);
- BOOST_CHECK(collector.value1() == 2.5f);
+ BOOST_CHECK(collector.value_<0>() == 2.5f);
} // end void branching_test()
void disconnect_test()
{
- signet::storage<void ()> banger;
+ signet::storage<void ()>::unfused banger;
{
SignalVoidCounter counter;
- signet::storage<void (float)> floater;
+ signet::storage<void (float)>::unfused floater;
floater(2.5f);
- signet::storage<void (float)> collector(0.0f);
+ signet::storage<void (float)>::unfused collector(0.0f);
banger
| counter
@@ -163,7 +165,7 @@
banger();
BOOST_CHECK(counter.GetCount() == 1);
- BOOST_CHECK(collector.value1() == 2.5f);
+ BOOST_CHECK(collector.value_<0>() == 2.5f);
} // counter, floater, and collector are now destroyed and disconnected with Boost.Signals
#ifdef SIGNAL_NETWORK_THREAD_SAFE
// if Signal Network has detected thread safe signals, we need to
@@ -184,10 +186,10 @@
void multi_type_test()
{
- signet::storage<void ()> banger;
- signet::storage<void (int)> inter;
+ signet::storage<void ()>::unfused banger;
+ signet::storage<void (int)>::unfused inter;
inter(2);
- signet::storage<void (float)> floater;
+ signet::storage<void (float)>::unfused floater;
floater(3.3f);
SignalIntFloatCollector collector;
@@ -239,8 +241,8 @@
void multi_num_args_test()
{
- signet::storage<void ()> banger;
- signet::storage<void (float)> floater;
+ signet::storage<void ()>::unfused banger;
+ signet::storage<void (float)>::unfused floater;
floater(2.5f);
SignalFloatDuplicator duplicator;
SignalMultiCollector collector;
@@ -260,16 +262,16 @@
} // end void multi_num_args_test()
-class SignalMultiInheritedCollector : public signet::storage<void (float)>, public SignalVoidCounter, public SignalFloat2Collector
+class SignalMultiInheritedCollector : public signet::storage<void (float)>::unfused, public SignalVoidCounter, public SignalFloat2Collector
{
public:
- SignalMultiInheritedCollector() : signet::storage<void (float)>(0) {}
+ SignalMultiInheritedCollector() : signet::storage<void (float)>::unfused(0) {}
};
void multi_num_args_inherited_test()
{
- signet::storage<void ()> banger;
- signet::storage<void (float)> floater;
+ signet::storage<void ()>::unfused banger;
+ signet::storage<void (float)>::unfused floater;
floater(2.5f);
SignalFloatDuplicator duplicator;
SignalMultiInheritedCollector collector;
@@ -278,12 +280,12 @@
| (SignalVoidCounter &) collector
|
(floater
- | (signet::storage<void (float)> &) collector
+ | (signet::storage<void (float)>::unfused &) collector
| (duplicator >>= (SignalFloat2Collector &) collector));
banger();
BOOST_CHECK(collector.GetCount() == 1);
- BOOST_CHECK(collector.value1() == 2.5f); // calls the collector<float>'s operator()
+ BOOST_CHECK(collector.value_<0>() == 2.5f); // calls the collector<float>'s operator()
BOOST_CHECK(collector.GetLast1() == optional<float>(2.5f));
BOOST_CHECK(collector.GetLast2() == optional<float>(2.5f));
} // end void multi_num_args_inherited_test()
@@ -344,7 +346,7 @@
void multi_in_test()
{
- signet::storage<void ()> banger;
+ signet::storage<void ()>::unfused banger;
Signal2VoidCounter counter;
banger
@@ -367,9 +369,9 @@
void junction_test()
{
- signet::storage<void ()> banger1, banger2;
+ signet::storage<void ()>::unfused banger1, banger2;
SignalVoidCounter counter1, counter2;
- signet::junction<void ()> junction;
+ signet::junction<void ()>::unfused junction;
banger1 >>= junction >>= counter1;
banger2 >>= junction >>= counter2;
@@ -397,11 +399,11 @@
void selector_test()
{
- signet::storage<void ()> banger;
- signet::storage<void (float)> floater1, floater2;
+/* signet::storage<void ()>::unfused banger;
+ signet::storage<void (float)>::unfused floater1, floater2;
floater1(1.0f);
floater2(2.0f);
- signet::storage<void (float)> collector(0.0f);
+ signet::storage<void (float)>::unfused collector(0.0f);
signet::selector<2, void (float)> selector;
banger >>= floater1 >>= selector.slot1();
@@ -410,15 +412,15 @@
selector.select(0);
banger();
- BOOST_CHECK(collector.value1() == 0.0f);
+ BOOST_CHECK(collector.value_<0>() == 0.0f);
selector.select(1);
banger();
- BOOST_CHECK(collector.value1() == 1.0f);
+ BOOST_CHECK(collector.value_<0>() == 1.0f);
selector.select(2);
banger();
- BOOST_CHECK(collector.value1() == 2.0f);
+ BOOST_CHECK(collector.value_<0>() == 2.0f);*/
} // end void selector_test()
#include <iostream>
@@ -436,7 +438,7 @@
{
signet::timed_generator<void ()> banger1;
signet::timed_generator<void ()> banger2;
- signet::mutex<void ()> lock;
+ signet::mutex<void ()>::unfused lock;
SignalVoidCounter counter;
ticker tick;
@@ -461,13 +463,13 @@
void filter_test()
{
DoublerClass doubler1, doubler2;
- signet::storage<void (float)> floater(1.0f);
- signet::storage<void (float)> collector(0.0f);
+ signet::storage<void (float)>::unfused floater(1.0f);
+ signet::storage<void (float)>::unfused collector(0.0f);
floater >>= doubler1 >>= doubler2 >>= collector;
floater();
- BOOST_CHECK(collector.value1() == 4.0f);
+ BOOST_CHECK(collector.value_<0>() == 4.0f);
} // end void filter_test()
float DoublerFunc(float x)
@@ -477,27 +479,27 @@
void function_test()
{
- signet::function<float(float)> double_fun1(&DoublerFunc);
- signet::function<float(float)> double_fun2(&DoublerFunc);
- signet::storage<void (float)> floater(1.0f);
- signet::storage<void (float)> collector(0.0f);
+ signet::function<float(float)>::unfused double_fun1(&DoublerFunc);
+ signet::function<float(float)>::unfused double_fun2(&DoublerFunc);
+ signet::storage<void (float)>::unfused floater(1.0f);
+ signet::storage<void (float)>::unfused collector(0.0f);
floater >>= double_fun1 >>= double_fun2 >>= collector;
floater();
- BOOST_CHECK(collector.value1() == 4.0f);
+ BOOST_CHECK(collector.value_<0>() == 4.0f);
} // end void function_test()
void chain_test()
{
- signet::chain<DoublerClass, void(float)> doubling_chain(4);
- signet::storage<void (float)> floater(1.0f);
- signet::storage<void (float)> collector(0.0f);
+ signet::chain<DoublerClass, void(float)>::unfused doubling_chain(4, NULL);
+ signet::storage<void (float)>::unfused floater(1.0f);
+ signet::storage<void (float)>::unfused collector(0.0f);
floater >>= doubling_chain >>= collector;
floater();
- BOOST_CHECK(collector.value1() == 16.0f);
+ BOOST_CHECK(collector.value_<0>() == 16.0f);
} // end void chain_test
class PullDoubler : public signet::filter<float ()>
@@ -511,10 +513,10 @@
void pull_test()
{
- signet::storage<void(float)> generator(1.0f);
+ signet::storage<void(float)>::unfused generator(1.0f);
PullDoubler doubler;
- doubler >>= generator.slot_exact1();
+ doubler >>= generator.slot<0>();
BOOST_CHECK(doubler() == 2.0f);
} // end void pull_test
@@ -540,9 +542,9 @@
acceptor.accept(socket);
// instantiate the components - a float generator, a filter that adds 2, and a sender
- signet::storage<void (float)> generator(1.0f);
- signet::function<float(float)> add2(boost::bind(std::plus<float>(), _1, 2.0f));
- signet::socket_sender<void (float)> sender(socket);
+ signet::storage<void (float)>::unfused generator(1.0f);
+ signet::function<float(float)>::unfused add2(boost::bind(std::plus<float>(), _1, 2.0f));
+ signet::socket_sender<void (float)>::unfused sender(socket);
// create the network
generator >>= add2 >>= sender;
@@ -565,8 +567,8 @@
socket.connect(endpoint_recv);
// instatiate the components
- signet::socket_receiver<void (float)> receiver(socket);
- signet::storage<void (float)> collector(0.0f);
+ signet::socket_receiver<void (float)> receiver(socket);
+ signet::storage<void (float)>::unfused collector(0.0f);
// set up the network
receiver >>= collector;
@@ -574,13 +576,29 @@
// this receiver is synchronous - we have to tell it to receive a signal
receiver();
- BOOST_CHECK(collector.value1() == 3.0f);
+ BOOST_CHECK(collector.value_<0>() == 3.0f);
t.join();
} // end void asio_test
test_suite* init_unit_test_suite(int argc, char* argv[])
{
+ signet::storage<void (int, int)> s;
+ boost::fusion::vector<int, int> val(4, 5);
+ s(val);
+ std::cout << s.value_<0>() << s.value_<1>() << std::endl;
+ signet::storage<void (int, int) >::unfused s2;
+
+ s >>= s2;
+ s();
+ std::cout << s2.value_<0>() << s2.value_<1>() << std::endl;
+
+ signet::storage<void (int, int) >::unfused s3(5, 6);
+ std::cout << s3.value_<0>() << s3.value_<1>() << std::endl;
+ s3(7, 8);
+ std::cout << s3.value_<0>() << s3.value_<1>() << std::endl;
+
+
test_suite* test = BOOST_TEST_SUITE( "Utility test suite" );
test->add(BOOST_TEST_CASE(&simple_test));
Modified: sandbox/SOC/2007/signals/libs/signal_network/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/test/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/Jamfile.v2 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -3,20 +3,21 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-
import testing ;
project
: requirements
<include>../../..
- <library>/boost/test//boost_unit_test_framework/<link>static
<library>/boost/signals//boost_signals/<link>static
- <library>/boost/thread//boost_thread/<link>static
<library>/boost/system//boost_system/<link>static
- <library>/boost/serialization//boost_serialization/<link>static
<define>BOOST_ALL_NO_LIB=1
;
-
-test-suite signal_network
- : [ run test.cpp ]
- ;
\ No newline at end of file
+
+run test_storage.cpp ;
+run test_counter.cpp ;
+run test_junction.cpp ;
+run test_function.cpp ;
+run test_chain.cpp ;
+run test_mutex.cpp /boost/thread//boost_thread/<link>static ;
+run test_socket.cpp /boost/serialization//boost_serialization/<link>static
+ /boost/thread//boost_thread/<link>static ;
\ No newline at end of file
Deleted: sandbox/SOC/2007/signals/libs/signal_network/test/test.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/test/test.cpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
+++ (empty file)
@@ -1,604 +0,0 @@
-// SignalLinkTests.cpp
-
-// 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)
-
-#define _CRT_SECURE_NO_DEPRECATE 1
-
-#include <boost/test/unit_test.hpp>
-using boost::unit_test::test_suite;
-
-#define BOOST_SIGNALS_STATIC_LINK
-#include <boost/optional.hpp>
-#include <boost/signal_network/filter.hpp>
-#include <boost/signal_network/storage.hpp>
-#include <boost/signal_network/junction.hpp>
-#include <boost/signal_network/selector.hpp>
-#include <boost/signal_network/mutex.hpp>
-#include <boost/signal_network/timed_generator.hpp>
-#include <boost/signal_network/function.hpp>
-#include <boost/signal_network/chain.hpp>
-
-#ifdef WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#define _WIN32_WINDOWS
-#endif
-#include <boost/signal_network/socket_receiver.hpp>
-#include <boost/signal_network/socket_sender.hpp>
-#undef _WIN32_WINDOWS
-
-// for access to connection operators >>= and |
-using namespace boost::signal_network;
-using namespace boost;
-
-class SignalVoidCounter
-#ifdef SIGNAL_NETWORK_TRACKABLE
- // Two base signals implementations are supported currently
- // (Boost.Signals by Doug Gregor and the
- // thread_safe_signals version under implementation by Frank Mori Hess).
- // SIGNAL_NETWORK_TRACKABLE is defined if you are using Boost.Signals
- // - in this case, we want to make our component trackable so that
- // it gets disconnected automatically when this object is destroyed.
- : public boost::signals::trackable
-#endif
-{
- volatile int cnt;
-public:
- SignalVoidCounter() : cnt(0) {}
- void operator()()
- {
- cnt++; // whenever a void() signal is received, increase the counter
- }
- int GetCount()
- {
- return cnt;
- }
-}; // end class SignalVoidCounter
-
-class SignalIntFloatCollector
-{
- optional<int> last_int;
- optional<float> last_float;
-public:
- void operator()(int x)
- {
- last_int = x;
- }
- void operator()(float x)
- {
- last_float = x;
- }
- optional<int> GetLastInt()
- {
- return last_int;
- }
- optional<float> GetLastFloat()
- {
- return last_float;
- }
-}; // end class SignalIntFloatCollector
-
-class SignalFloatDoubler : public signet::filter<void (float, float)>
-{
-public:
- void operator()(float val) {out(val, val*2);}
-};
-
-class SignalFloatDuplicator : public signet::filter<void (float, float)>
-{
-public:
- void operator()(float val) {out(val, val);}
-};
-
-class SignalFloat2Collector
-{
- optional<float> last1, last2;
-public:
- void operator()(float val1, float val2)
- {
- last1 = val1;
- last2 = val2;
- }
- optional<float> GetLast1()
- {
- return last1;
- }
- optional<float> GetLast2()
- {
- return last2;
- }
-};
-
-void simple_test()
-{
- // instantiate all of the components we need
- signet::storage<void ()> banger;
- signet::storage<void (float)> floater(2.5f);
- signet::storage<void (float)> collector(0.0f);
-
- // create the network
- banger >>= floater >>= collector;
-
- banger(); // signal from banger will now cause floater to output 2.5
- BOOST_CHECK(collector.value1() == 2.5f);
-
- floater(1.5f); // change the value in floater
- floater(); // we can also signal floater directly
- BOOST_CHECK(collector.value1() == 1.5f);
-} // end void simple_test()
-
-void branching_test()
-{
- signet::storage<void ()> banger;
- SignalVoidCounter counter;
- signet::storage<void (float)> floater;
- floater(2.5f);
-
- signet::storage<void (float)> collector(0.0f);
-
- banger
- | (floater >>= collector) // floater connects to collector, banger to floater
- | counter; // and banger to counter
-
- banger();
- BOOST_CHECK(counter.GetCount() == 1);
- BOOST_CHECK(collector.value1() == 2.5f);
-} // end void branching_test()
-
-void disconnect_test()
-{
- signet::storage<void ()> banger;
- {
- SignalVoidCounter counter;
- signet::storage<void (float)> floater;
- floater(2.5f);
- signet::storage<void (float)> collector(0.0f);
-
- banger
- | counter
- | (floater >>= collector);
-
- banger();
- BOOST_CHECK(counter.GetCount() == 1);
- BOOST_CHECK(collector.value1() == 2.5f);
- } // counter, floater, and collector are now destroyed and disconnected with Boost.Signals
-#ifdef SIGNAL_NETWORK_THREAD_SAFE
- // if Signal Network has detected thread safe signals, we need to
- // touch the signal to disconnect things that are destroyed:
- // unfortunatelly, this call hangs on MSVC!
- // banger();
-#endif
- BOOST_CHECK(banger.default_signal().num_slots() == 0);
-
- SignalVoidCounter counter;
-
- banger >>= counter;
- banger.disconnect_all_slots();
-
- banger();
- BOOST_CHECK(counter.GetCount() == 0);
-} // end void disconnect_test
-
-void multi_type_test()
-{
- signet::storage<void ()> banger;
- signet::storage<void (int)> inter;
- inter(2);
- signet::storage<void (float)> floater;
- floater(3.3f);
- SignalIntFloatCollector collector;
-
- banger
- | (inter >>= collector)
- | (floater >>= collector);
-
- banger();
- BOOST_CHECK(collector.GetLastInt() == optional<int>(2));
- BOOST_CHECK(collector.GetLastFloat() == optional<float>(3.3f));
-} // end void multi_type_test()
-
-class SignalMultiCollector
-{
- optional<float> last, last1, last2;
- int cnt;
-public:
- SignalMultiCollector() : cnt(0) {}
- void operator()()
- {
- cnt++;
- }
- int GetCount()
- {
- return cnt;
- }
- void operator()(float val1, float val2)
- {
- last1 = val1;
- last2 = val2;
- }
- optional<float> GetLast1()
- {
- return last1;
- }
- optional<float> GetLast2()
- {
- return last2;
- }
- void operator()(float x)
- {
- last = x;
- }
- optional<float> GetLast()
- {
- return last;
- }
-}; // end class SignalMultiCollector
-
-void multi_num_args_test()
-{
- signet::storage<void ()> banger;
- signet::storage<void (float)> floater;
- floater(2.5f);
- SignalFloatDuplicator duplicator;
- SignalMultiCollector collector;
-
- banger
- | collector
- |
- (floater
- | collector
- | (duplicator >>= collector));
-
- banger();
- BOOST_CHECK(collector.GetCount() == 1);
- BOOST_CHECK(collector.GetLast() == optional<float>(2.5f));
- BOOST_CHECK(collector.GetLast1() == optional<float>(2.5f));
- BOOST_CHECK(collector.GetLast2() == optional<float>(2.5f));
-} // end void multi_num_args_test()
-
-
-class SignalMultiInheritedCollector : public signet::storage<void (float)>, public SignalVoidCounter, public SignalFloat2Collector
-{
-public:
- SignalMultiInheritedCollector() : signet::storage<void (float)>(0) {}
-};
-
-void multi_num_args_inherited_test()
-{
- signet::storage<void ()> banger;
- signet::storage<void (float)> floater;
- floater(2.5f);
- SignalFloatDuplicator duplicator;
- SignalMultiInheritedCollector collector;
-
- banger
- | (SignalVoidCounter &) collector
- |
- (floater
- | (signet::storage<void (float)> &) collector
- | (duplicator >>= (SignalFloat2Collector &) collector));
-
- banger();
- BOOST_CHECK(collector.GetCount() == 1);
- BOOST_CHECK(collector.value1() == 2.5f); // calls the collector<float>'s operator()
- BOOST_CHECK(collector.GetLast1() == optional<float>(2.5f));
- BOOST_CHECK(collector.GetLast2() == optional<float>(2.5f));
-} // end void multi_num_args_inherited_test()
-
-class SignalOutIntFloat : public signet::filter<void (float)>
-{
-public:
- SignalOutIntFloat(float x) : x(x) {}
- void operator()()
- {
- out(x);
- out_int((int)x);
- }
- boost::signal<void (int)> out_int;
-private:
- float x;
-}; // end class SignalOutIntFloat
-
-void multi_out_test()
-{
- SignalOutIntFloat multi_out(2.5f);
- SignalIntFloatCollector collector;
-
- multi_out >>= collector;
- multi_out.out_int >>= collector;
- multi_out();
-
- BOOST_CHECK(collector.GetLastFloat() == optional<float>(2.5f));
- BOOST_CHECK(collector.GetLastInt() == optional<int>(2));
-} // end void multi_out_test()
-
-class Signal2VoidCounter : public SignalVoidCounter
-{
-public:
- SignalVoidCounter other;
-}; // end class Signal2VoidCounter
-
-class Signal2VoidInputs : public signet::filter<void(int)>
-{
- int result;
-public:
- Signal2VoidInputs() : result(0) {};
- void operator()()
- {
- result++;
- out(result);
- }
- void AltInput()
- {
- result+=10;
- out(result);
- }
- int GetResult()
- {
- return result;
- }
-}; // end class Signal2VoidInputs
-
-void multi_in_test()
-{
- signet::storage<void ()> banger;
- Signal2VoidCounter counter;
-
- banger
- | counter
- | counter.other;
-
- banger();
- BOOST_CHECK(counter.GetCount() == 1);
- BOOST_CHECK(counter.other.GetCount() == 1);
-
- Signal2VoidInputs inputs;
-
- banger
- | inputs
- | slot_selector<void ()> (inputs, &Signal2VoidInputs::AltInput);
-
- banger();
- BOOST_CHECK(inputs.GetResult() == 11);
-}; // end void multi_in_test
-
-void junction_test()
-{
- signet::storage<void ()> banger1, banger2;
- SignalVoidCounter counter1, counter2;
- signet::junction<void ()> junction;
-
- banger1 >>= junction >>= counter1;
- banger2 >>= junction >>= counter2;
-
- banger1();
- banger2();
-
- BOOST_CHECK(counter1.GetCount() == 2);
- BOOST_CHECK(counter2.GetCount() == 2);
-
- junction.disable();
- banger1();
- banger2();
-
- BOOST_CHECK(counter1.GetCount() == 2);
- BOOST_CHECK(counter2.GetCount() == 2);
-
- junction.enable();
- banger1();
- banger2();
-
- BOOST_CHECK(counter1.GetCount() == 4);
- BOOST_CHECK(counter2.GetCount() == 4);
-} // end void junction_test()
-
-void selector_test()
-{
- signet::storage<void ()> banger;
- signet::storage<void (float)> floater1, floater2;
- floater1(1.0f);
- floater2(2.0f);
- signet::storage<void (float)> collector(0.0f);
- signet::selector<2, void (float)> selector;
-
- banger >>= floater1 >>= selector.slot1();
- banger >>= floater2 >>= selector.slot2();
- selector >>= collector;
-
- selector.select(0);
- banger();
- BOOST_CHECK(collector.value1() == 0.0f);
-
- selector.select(1);
- banger();
- BOOST_CHECK(collector.value1() == 1.0f);
-
- selector.select(2);
- banger();
- BOOST_CHECK(collector.value1() == 2.0f);
-} // end void selector_test()
-
-#include <iostream>
-using namespace std;
-
-struct ticker
-{
- void operator()()
- {
- cout << "tick" << endl;
- }
-};
-
-void mutex_test()
-{
- signet::timed_generator<void ()> banger1;
- signet::timed_generator<void ()> banger2;
- signet::mutex<void ()> lock;
- SignalVoidCounter counter;
- ticker tick;
-
- banger1 >>= lock >>= counter;
- banger2 >>= lock >>= tick;
- banger1.enable(0.5, 5);
- banger2.enable(0.5, 5);
-
- while (counter.GetCount() < 10) {}
-
- BOOST_CHECK(counter.GetCount() == 10);
- banger1.join();
- banger2.join();
-} // end void mutex_test
-
-class DoublerClass : public signet::filter<void (float)>
-{
-public:
- void operator()(float x) {out(2*x);}
-};
-
-void filter_test()
-{
- DoublerClass doubler1, doubler2;
- signet::storage<void (float)> floater(1.0f);
- signet::storage<void (float)> collector(0.0f);
-
- floater >>= doubler1 >>= doubler2 >>= collector;
- floater();
-
- BOOST_CHECK(collector.value1() == 4.0f);
-} // end void filter_test()
-
-float DoublerFunc(float x)
-{
- return x*2;
-}
-
-void function_test()
-{
- signet::function<float(float)> double_fun1(&DoublerFunc);
- signet::function<float(float)> double_fun2(&DoublerFunc);
- signet::storage<void (float)> floater(1.0f);
- signet::storage<void (float)> collector(0.0f);
-
- floater >>= double_fun1 >>= double_fun2 >>= collector;
- floater();
-
- BOOST_CHECK(collector.value1() == 4.0f);
-} // end void function_test()
-
-void chain_test()
-{
- signet::chain<DoublerClass, void(float)> doubling_chain(4);
- signet::storage<void (float)> floater(1.0f);
- signet::storage<void (float)> collector(0.0f);
-
- floater >>= doubling_chain >>= collector;
- floater();
-
- BOOST_CHECK(collector.value1() == 16.0f);
-} // end void chain_test
-
-class PullDoubler : public signet::filter<float ()>
-{
-public:
- float operator()()
- {
- return 2*out();
- }
-};
-
-void pull_test()
-{
- signet::storage<void(float)> generator(1.0f);
- PullDoubler doubler;
-
- doubler >>= generator.slot_exact1();
-
- BOOST_CHECK(doubler() == 2.0f);
-} // end void pull_test
-
-// asio test
-boost::mutex mutex_;
-boost::condition cond;
-asio::io_service io_service;
-
-// This function will set up an asio acceptor, and wait for a connection.
-// Once established, it will set up a signal network which will send
-// its final signal through the socket.
-void asio_server()
-{
- // set up the socket
- asio::ip::tcp::acceptor acceptor(io_service, asio::ip::tcp::endpoint(asio::ip::tcp::v4(), 1097));
- asio::ip::tcp::socket socket(io_service);
- {
- boost::mutex::scoped_lock lock(mutex_);
- acceptor.listen();
- cond.notify_all();
- }
- acceptor.accept(socket);
-
- // instantiate the components - a float generator, a filter that adds 2, and a sender
- signet::storage<void (float)> generator(1.0f);
- signet::function<float(float)> add2(boost::bind(std::plus<float>(), _1, 2.0f));
- signet::socket_sender<void (float)> sender(socket);
-
- // create the network
- generator >>= add2 >>= sender;
-
- // cause the generator to send it's stored value
- generator();
-}
-
-// main test function
-void asio_test()
-{
- // start the server in a separate thread
- boost::mutex::scoped_lock lock(mutex_);
- boost::thread t(asio_server);
- cond.wait(lock);
-
- // set up the socket
- asio::ip::tcp::endpoint endpoint_recv(asio::ip::address::from_string("127.0.0.1"), 1097);
- asio::ip::tcp::socket socket(io_service);
- socket.connect(endpoint_recv);
-
- // instatiate the components
- signet::socket_receiver<void (float)> receiver(socket);
- signet::storage<void (float)> collector(0.0f);
-
- // set up the network
- receiver >>= collector;
-
- // this receiver is synchronous - we have to tell it to receive a signal
- receiver();
-
- BOOST_CHECK(collector.value1() == 3.0f);
-
- t.join();
-} // end void asio_test
-
-test_suite* init_unit_test_suite(int argc, char* argv[])
-{
- test_suite* test = BOOST_TEST_SUITE( "Utility test suite" );
-
- test->add(BOOST_TEST_CASE(&simple_test));
- test->add(BOOST_TEST_CASE(&branching_test));
- test->add(BOOST_TEST_CASE(&disconnect_test));
- test->add(BOOST_TEST_CASE(&multi_type_test));
- test->add(BOOST_TEST_CASE(&multi_num_args_test));
- test->add(BOOST_TEST_CASE(&multi_num_args_inherited_test));
- test->add(BOOST_TEST_CASE(&multi_out_test));
- test->add(BOOST_TEST_CASE(&multi_in_test));
- test->add(BOOST_TEST_CASE(&junction_test));
- test->add(BOOST_TEST_CASE(&selector_test));
- test->add(BOOST_TEST_CASE(&mutex_test));
- test->add(BOOST_TEST_CASE(&filter_test));
- test->add(BOOST_TEST_CASE(&function_test));
- test->add(BOOST_TEST_CASE(&chain_test));
- test->add(BOOST_TEST_CASE(&pull_test));
- test->add(BOOST_TEST_CASE(&asio_test));
-
- return test;
-}
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_chain.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_chain.cpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,33 @@
+// 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)
+
+#include <boost/signal_network/chain.hpp>
+#include <boost/signal_network/storage.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+class DoublerClass : public signet::filter<void (float)>
+{
+public:
+ void operator()(float x) {out(2*x);}
+};
+
+int test_main(int, char* [])
+{
+ signet::chain<DoublerClass, void(float)>::unfused doubling_chain(4, NULL);
+ signet::storage<void (float)>::unfused floater(1.0f);
+ signet::storage<void (float)>::unfused collector(0.0f);
+
+ floater >>= doubling_chain >>= collector;
+ floater();
+
+ BOOST_CHECK(collector.value_<0>() == 16.0f);
+
+ return 0;
+} // int test_main(int, char* [])
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_counter.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_counter.cpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,23 @@
+// Copyright Stjepan Rajko 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/signal_network/counter.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+int test_main(int, char* [])
+{
+ signet::counter<void ()>::unfused counter1;
+
+ for (int i=0; i<33; i++)
+ counter1();
+ BOOST_CHECK_EQUAL(counter1.count(), 33);
+
+ return 0;
+} // int test_main(int, char* [])
\ No newline at end of file
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_function.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_function.cpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,33 @@
+// 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)
+
+#include <boost/signal_network/function.hpp>
+#include <boost/signal_network/storage.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+float DoublerFunc(float x)
+{
+ return x*2;
+}
+
+int test_main(int, char* [])
+{
+ signet::function<float(float)>::unfused double_fun1(&DoublerFunc);
+ signet::function<float(float)>::unfused double_fun2(&DoublerFunc);
+ signet::storage<void (float)>::unfused floater(1.0f);
+ signet::storage<void (float)>::unfused collector(0.0f);
+
+ floater >>= double_fun1 >>= double_fun2 >>= collector;
+ floater();
+
+ BOOST_CHECK(collector.value_<0>() == 4.0f);
+
+ return 0;
+} // int test_main(int, char* [])
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_junction.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_junction.cpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,46 @@
+// 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)
+
+#include <boost/signal_network/junction.hpp>
+#include <boost/signal_network/counter.hpp>
+#include <boost/signal_network/storage.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+int test_main(int, char* [])
+{
+ signet::storage<void ()>::unfused banger1, banger2;
+ signet::counter<void ()>::unfused counter1, counter2;
+ signet::junction<void ()>::unfused junction;
+
+ banger1 >>= junction >>= counter1;
+ banger2 >>= junction >>= counter2;
+
+ banger1();
+ banger2();
+
+ BOOST_CHECK(counter1.count() == 2);
+ BOOST_CHECK(counter2.count() == 2);
+
+ junction.disable();
+ banger1();
+ banger2();
+
+ BOOST_CHECK(counter1.count() == 2);
+ BOOST_CHECK(counter2.count() == 2);
+
+ junction.enable();
+ banger1();
+ banger2();
+
+ BOOST_CHECK(counter1.count() == 4);
+ BOOST_CHECK(counter2.count() == 4);
+
+ return 0;
+} // int test_main(int, char* [])
\ No newline at end of file
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_mutex.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_mutex.cpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,44 @@
+// 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)
+
+#include <boost/signal_network/mutex.hpp>
+#include <boost/signal_network/timed_generator.hpp>
+#include <boost/signal_network/counter.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+struct ticker
+{
+ void operator()()
+ {
+ std::cout << "tick" << std::endl;
+ }
+};
+
+int test_main(int, char* [])
+{
+ signet::timed_generator<void ()> banger1;
+ signet::timed_generator<void ()> banger2;
+ signet::mutex<void ()>::unfused lock;
+ signet::counter<void ()>::unfused counter;
+ ticker tick;
+
+ banger1 >>= lock >>= counter;
+ banger2 >>= lock >>= tick;
+ banger1.enable(0.5, 5);
+ banger2.enable(0.5, 5);
+
+ while (counter.count() < 10) {}
+
+ BOOST_CHECK_EQUAL(counter.count(), 10);
+ banger1.join();
+ banger2.join();
+
+ return 0;
+} // int test_main(int, char* [])
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_socket.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_socket.cpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,85 @@
+// 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)
+
+#include <boost/asio.hpp>
+#include <boost/test/included/test_exec_monitor.hpp>
+
+/*#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#define _WIN32_WINDOWS
+#endif*/
+#include <boost/signal_network/socket_receiver.hpp>
+#include <boost/signal_network/socket_sender.hpp>
+#include <boost/signal_network/function.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+
+// asio test
+boost::mutex mutex_;
+boost::condition cond;
+asio::io_service io_service;
+
+// This function will set up an asio acceptor, and wait for a connection.
+// Once established, it will set up a signal network which will send
+// its final signal through the socket.
+void asio_server()
+{
+ // set up the socket
+ asio::ip::tcp::acceptor acceptor(io_service, asio::ip::tcp::endpoint(asio::ip::tcp::v4(), 1097));
+ asio::ip::tcp::socket socket(io_service);
+ {
+ boost::mutex::scoped_lock lock(mutex_);
+ acceptor.listen();
+ cond.notify_all();
+ }
+ acceptor.accept(socket);
+
+ // instantiate the components - a float generator, a filter that adds 2, and a sender
+ signet::storage<void (float)>::unfused generator(1.0f);
+ signet::function<float(float)>::unfused add2(boost::bind(std::plus<float>(), _1, 2.0f));
+ signet::socket_sender<void (float)>::unfused sender(socket);
+
+ // create the network
+ generator >>= add2 >>= sender;
+
+ // cause the generator to send it's stored value
+ generator();
+}
+
+int test_main(int, char* [])
+{
+ // start the server in a separate thread
+ boost::mutex::scoped_lock lock(mutex_);
+ boost::thread t(asio_server);
+ cond.wait(lock);
+
+ // set up the socket
+ asio::ip::tcp::endpoint endpoint_recv(asio::ip::address::from_string("127.0.0.1"), 1097);
+ asio::ip::tcp::socket socket(io_service);
+ socket.connect(endpoint_recv);
+
+ // instatiate the components
+ signet::socket_receiver<void (float)> receiver(socket);
+ signet::storage<void (float)>::unfused collector(0.0f);
+
+ // set up the network
+ receiver >>= collector;
+
+ // this receiver is synchronous - we have to tell it to receive a signal
+ receiver();
+
+ BOOST_CHECK(collector.value_<0>() == 3.0f);
+
+ t.join();
+
+ return 0;
+} // int test_main(int, char* [])
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_storage.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_storage.cpp 2007-06-03 13:50:21 EDT (Sun, 03 Jun 2007)
@@ -0,0 +1,31 @@
+// Copyright Stjepan Rajko 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/signal_network/storage.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+int test_main(int, char* [])
+{
+ // instantiate all of the components we need
+ signet::storage<void ()>::unfused banger;
+ signet::storage<void (float)>::unfused floater(2.5f);
+ signet::storage<void (float)>::unfused collector(0.0f);
+
+ // create the network
+ banger >>= floater >>= collector;
+
+ banger(); // signal from banger will now cause floater to output 2.5
+ BOOST_CHECK_EQUAL(collector.value_<0>(), 2.5f);
+
+ floater(1.5f); // change the value in floater
+ floater(); // we can also signal floater directly
+ BOOST_CHECK_EQUAL(collector.value_<0>(), 1.5f);
+ return 0;
+} // int test_main(int, char* [])
\ No newline at end of file
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk