|
Boost-Commit : |
From: srajko_at_[hidden]
Date: 2007-06-14 12:59:04
Author: srajko
Date: 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
New Revision: 7043
URL: http://svn.boost.org/trac/boost/changeset/7043
Log:
add connection tests, fix connection bugs, update docs (connections, filter)
Added:
sandbox/SOC/2007/signals/libs/signal_network/test/test_disconnect.cpp (contents, props changed)
sandbox/SOC/2007/signals/libs/signal_network/test/test_filter.cpp (contents, props changed)
sandbox/SOC/2007/signals/libs/signal_network/test/test_multi_args.cpp (contents, props changed)
sandbox/SOC/2007/signals/libs/signal_network/test/test_multi_out.cpp (contents, props changed)
sandbox/SOC/2007/signals/libs/signal_network/test/test_multi_type.cpp (contents, props changed)
sandbox/SOC/2007/signals/libs/signal_network/test/test_pull.cpp (contents, props changed)
sandbox/SOC/2007/signals/libs/signal_network/test/test_same_type.cpp (contents, props changed)
Text files modified:
sandbox/SOC/2007/signals/boost/signal_network/base.hpp | 8
sandbox/SOC/2007/signals/boost/signal_network/detail/connect_slot.hpp | 4
sandbox/SOC/2007/signals/boost/signal_network/storage.hpp | 4
sandbox/SOC/2007/signals/libs/signal_network/build/xcodeide/signal_network.xcodeproj/project.pbxproj | 14 +
sandbox/SOC/2007/signals/libs/signal_network/doc/components.qbk | 22 +
sandbox/SOC/2007/signals/libs/signal_network/doc/connections.qbk | 82 ++++---
sandbox/SOC/2007/signals/libs/signal_network/doc/introduction.qbk | 12
sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network.qbk | 10
sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network_doxygen.xml | 4
sandbox/SOC/2007/signals/libs/signal_network/test/Jamfile.v2 | 13
sandbox/SOC/2007/signals/libs/signal_network/test/test_branching.cpp | 1
sandbox/SOC/2007/signals/libs/signal_network/test/test_chain.cpp | 2
sandbox/SOC/2007/signals/libs/signal_network/test/test_connections.cpp | 461 ----------------------------------------
13 files changed, 115 insertions(+), 522 deletions(-)
Modified: sandbox/SOC/2007/signals/boost/signal_network/base.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/base.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/base.hpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -79,7 +79,7 @@
SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
namespace detail {
-
+
template<typename T, typename Signature, typename Combiner, typename Group, typename GroupCompare>
void connect(boost::signal<Signature, Combiner, Group, GroupCompare> &signal, T &link)
{
@@ -88,7 +88,7 @@
}
template<typename T, typename Signature, typename Combiner, typename Group, typename GroupCompare>
- void connect_slot(boost::signal<Signature> &signal, const slot_selector_t<T, Signature> &link)
+ void connect_slot(boost::signal<Signature, Combiner, Group, GroupCompare> &signal, const slot_selector_t<T, Signature> &link)
{
connect_slot_impl<T, Signature, Combiner, Group, GroupCompare, boost::function_traits<Signature>::arity>
::connect_slot(signal, link);
@@ -141,11 +141,11 @@
operator | (Filter &filter, slot_selector_t<T, Signature> link) {signet::detail::connect_slot(filter.default_signal(), link); return filter;}
template<typename Signature, typename Combiner, typename Group, typename GroupCompare, typename T>
-boost::signal<Signature> &operator >>= (boost::signal<Signature> &signal, T &link)
+boost::signal<Signature> &operator >>= (boost::signal<Signature, Combiner, Group, GroupCompare> &signal, T &link)
{signet::detail::connect(signal, link); return signal;}
template<typename Signature, typename Combiner, typename Group, typename GroupCompare, typename T>
-boost::signal<Signature> &operator >= (boost::signal<Signature> &signal, T &link)
+boost::signal<Signature> &operator | (boost::signal<Signature, Combiner, Group, GroupCompare> &signal, T &link)
{signet::detail::connect(signal, link); return signal;}
SIGNAL_NETWORK_CLOSE_SIGNAL_NETWORK_NAMESPACE
Modified: sandbox/SOC/2007/signals/boost/signal_network/detail/connect_slot.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/signal_network/detail/connect_slot.hpp (original)
+++ sandbox/SOC/2007/signals/boost/signal_network/detail/connect_slot.hpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -14,7 +14,7 @@
template<typename T, typename Signature, typename Combiner, typename Group, typename GroupCompare, int Arity>
struct connect_slot_impl;
-#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,3,<boost/signal_network/detail/connect.hpp>))
+#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,3,<boost/signal_network/detail/connect_slot.hpp>))
#include BOOST_PP_ITERATE()
} // namespace detail
@@ -26,7 +26,7 @@
#else // defined(BOOST_PP_IS_ITERATING)
template<typename T, typename Signature, typename Combiner, typename Group, typename GroupCompare>
-struct connect_impl<T, Signature, Combiner, Group, GroupCompare, BOOST_PP_ITERATION()>
+struct connect_slot_impl<T, Signature, Combiner, Group, GroupCompare, BOOST_PP_ITERATION()>
{
static void connect_slot(boost::signal<Signature, Combiner, Group, GroupCompare> &signal, const slot_selector_t<T, Signature> &slot)
{
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-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -133,7 +133,7 @@
{
return boost::signal_network::slot_selector<
typename boost::fusion::result_of::at_c<storable_vector, N>::type ()>
- (*this, &storage<Signature>::template at<N>);
+ (*this, &this_type::template at<N>);
}
/** \return The slot selector for the value_at function.
*/
@@ -147,7 +147,7 @@
{
return boost::signal_network::slot_selector<
typename boost::mpl::at_c<typename base_type::parameter_types, N>::type ()>
- (*this, &storage<Signature>::template value_at<N>);
+ (*this, &this_type::template value_at<N>);
}
protected:
storable_vector stored;
Modified: sandbox/SOC/2007/signals/libs/signal_network/build/xcodeide/signal_network.xcodeproj/project.pbxproj
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/build/xcodeide/signal_network.xcodeproj/project.pbxproj (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/build/xcodeide/signal_network.xcodeproj/project.pbxproj 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -104,6 +104,11 @@
08C6759C0C13A03E00D85379 /* test_mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = test_mutex.cpp; sourceTree = "<group>"; };
08C6759D0C13A03E00D85379 /* test_socket.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = test_socket.cpp; sourceTree = "<group>"; };
08C6759E0C13A03E00D85379 /* test_storage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = test_storage.cpp; sourceTree = "<group>"; };
+ 08EBB2CB0C210CC9004BE220 /* test_pull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_pull.cpp; sourceTree = "<group>"; };
+ 08EBB3020C21105B004BE220 /* test_disconnect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_disconnect.cpp; sourceTree = "<group>"; };
+ 08EBB3910C211C36004BE220 /* test_multi_type.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_multi_type.cpp; sourceTree = "<group>"; };
+ 08EBB3BC0C211F23004BE220 /* test_same_type.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_same_type.cpp; sourceTree = "<group>"; };
+ 08EBB3E00C21209B004BE220 /* test_multi_args.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_multi_args.cpp; sourceTree = "<group>"; };
08EC84040C18DA8100820E53 /* connect.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = connect.hpp; sourceTree = "<group>"; };
08EC847E0C18EC9800820E53 /* connect_slot.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = connect_slot.hpp; sourceTree = "<group>"; };
08EFEADE0C1C892A00097C80 /* instantiator.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = instantiator.hpp; sourceTree = "<group>"; };
@@ -116,6 +121,8 @@
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>"; };
08F082840C1DE02F00687E1B /* test_branching.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_branching.cpp; sourceTree = "<group>"; };
+ 08F803D30C21895700D8296D /* test_multi_out.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_multi_out.cpp; sourceTree = "<group>"; };
+ 08F804AD0C219CC300D8296D /* test_filter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_filter.cpp; sourceTree = "<group>"; };
08FD5DE80C1BA60700F00877 /* html_footer.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html; path = html_footer.html; sourceTree = "<group>"; };
08FD5DE90C1BA60700F00877 /* html_header.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html; path = html_header.html; sourceTree = "<group>"; };
08FD5DEA0C1BA60700F00877 /* signal_network.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = signal_network.hpp; sourceTree = "<group>"; };
@@ -201,6 +208,13 @@
08C6759E0C13A03E00D85379 /* test_storage.cpp */,
08668C560C19AD0100ACB19A /* test_connections.cpp */,
08F082840C1DE02F00687E1B /* test_branching.cpp */,
+ 08EBB2CB0C210CC9004BE220 /* test_pull.cpp */,
+ 08EBB3020C21105B004BE220 /* test_disconnect.cpp */,
+ 08EBB3910C211C36004BE220 /* test_multi_type.cpp */,
+ 08EBB3BC0C211F23004BE220 /* test_same_type.cpp */,
+ 08EBB3E00C21209B004BE220 /* test_multi_args.cpp */,
+ 08F803D30C21895700D8296D /* test_multi_out.cpp */,
+ 08F804AD0C219CC300D8296D /* test_filter.cpp */,
);
name = test;
path = ../../test;
Modified: sandbox/SOC/2007/signals/libs/signal_network/doc/components.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/doc/components.qbk (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/doc/components.qbk 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -5,8 +5,26 @@
[section:filter filter]
[*See also]: [classref boost::signal_network::signet::filter filter class reference.]
-The __filter__ class is used as a base class for in / out components. It provides support for Signal Network connection operators,
-and provides a default output signal.
+The __filter__ class is provided as a base class for in / out components. It provides support for Signal Network connection operators,
+and provides a default output signal. Here is an example of a simple class which inherits __filter__:
+
+[test_filter_classes]
+
+The type of the output signal (in the above example, `unfused_out_signal`) is specified as the second template parameter.
+There are three options:
+
+* `unfused_out_signal` provides an unfused output signal named `out`.
+* `fused_out_signal` provides a fused output signal named `fused_out`.
+* `combined_out_signal` provides an unfused output signal named `out`, and a fused adapter for the signal named `fused_out`.
+ This is useful for components which wish to use fusion internally but output an unfused signal.
+
+A component developed on top of the __filter__ class can then be used in the appropriate network. Here is an example
+which uses the class defined above:
+
+[table filter-based class use example
+ [[fused][unfused]]
+ [[[test_filter_fused]][[test_filter_unfused]]]
+]
[endsect][/filter]
Modified: sandbox/SOC/2007/signals/libs/signal_network/doc/connections.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/doc/connections.qbk (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/doc/connections.qbk 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -2,6 +2,8 @@
[section:chaining Chaining]
+Chaining of components can be done using `operator >>=`.
+
[table chaining example
[[fused][unfused]]
[[[test_storage_fused]][[test_storage_unfused]]]
@@ -13,7 +15,7 @@
More complex connections can also be made relatively easily using
both `operator >>=`
-and `operator |`
+and `operator |`, with `operator |` being used for branching.
[table branching example
[[fused][unfused]]
@@ -31,80 +33,90 @@
The following example illustrates this:
-\dontinclude example.cpp
-\skip PullDoubler
-\until end void pull_test
+[table pull-based network example
+ [[fused][unfused]]
+ [[[/test_pull_fused]][[test_pull_unfused]]]
+]
+
+The example uses the following classes:
+
+[test_pull_classes]
[endsect][/pull]
[section:disconnect Disconnecting]
-
-\subsection signal_network_disconnect_example Disconnecting connections
Connections can be terminated in two ways. One is through the "trackable"
mechanism of Boost.Signals, which will automatically destroy connections
to a trackable object when the object is destroyed. The other
way is through the disconnect_all_slots method of the signal sender.
-\dontinclude example.cpp
-\skip void disconnect_test
-\until end void disconnect_test
+[table disconnect example
+ [[fused][unfused]]
+ [[[/test_disconnect_fused]][[test_disconnect_unfused]]]
+]
[endsect][/disconnect]
-[section:multiple_different Multiple inputs of different signatures]
+[section:multiple_different Multiple slots of different signatures]
It is simple to have an object provide multiple slots through operator() functions
-of different signatures. The following class does so through providing 1-ary slots
+of different signatures. The following class does so through providing unary slots
of different types:
-\dontinclude example.cpp
-\skip class SignalIntFloatCollector
-\until end class
-
-The following class, on the other hand, uses slots of different number of arguments:
-\dontinclude example.cpp
-\skip class SignalMultiCollector
-\until end class
+[test_multi_type_classes]
+
+[/The following class, on the other hand, uses slots of different number of arguments:
+
+[test_multi_type_classes]]
In such cases, where the operator() functions differ in their signature,
standard connection operators will work out the correct connection:
-\dontinclude example.cpp
-\skip void multi_type_test
-\until end void multi_type_test
+[table multiple slots example
+ [[fused][unfused]]
+ [[[/test_multi_args_unfused]][[test_multi_args_unfused]]]
+]
[endsect][/multiple_different]
[section:multiple_same Multiple inputs of the same signature]
In some cases, a class may want to receive multiple signals of the same
-signature. For example, the following class can receive a void() signal
+signature. [/For example, the following class can receive a void() signal
through its inherited operator() function, as well as through the
operator() function of member "other":
-\dontinclude example.cpp
-\skip class Signal2VoidCounter
-\until end class
-Similarly, the following class could receive void() signals both
+[test_same_type_class1]]
+
+For example, the following class could receive void() signals both
through operator() and through AltInput:
-\dontinclude example.cpp
-\skip class Signal2VoidInputs
-\until end class
+
+[test_same_type_classes]
The following example shows how to connect signals to all of the above slots.
For the class Signal2VoidInputs, this is accomplished using the
slot_selector function:
-\skip void multi_in_test
-\until end void multi_in_test
+
+[table multiple slots example
+ [[fused][unfused]]
+ [[[/test_same_type_fused]][[test_same_type_unfused]]]
+]
[endsect][/multiple_same]
[section:multi_out Multiple outputs]
-\dontinclude example.cpp
-\skip class SignalOutIntFloat
-\until end void multi_out_test
+Multiple outputs can be achieved by introducing additional signals in the class.
+
+[table multiple outs example
+ [[fused][unfused]]
+ [[[/test_multi_out_fused]][[test_multi_out_unfused]]]
+]
+
+The example uses the following classes:
+
+[test_multi_out_classes]
[endsect][/multi_out]
Modified: sandbox/SOC/2007/signals/libs/signal_network/doc/introduction.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/doc/introduction.qbk (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/doc/introduction.qbk 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -14,14 +14,14 @@
facilitating large-scale use of Boost.Signals as a mechanism to model the transfer
of data between processing components.
-[*["I don't get it. Data is all over the place in C++. How is it not already a dataflow language?]]
-
The wikipedia description of [@http://en.wikipedia.org/wiki/Dataflow_language dataflow languages]
does a pretty good job of introducing the dataflow concept. Perhaps the most interesting point I'd like to
focus on here is the notion that "data is what it is all about". Even though data is an integral
part of C++, and lot of things are very much about the data, programs tend not to be modeled with the
flow of data as the central representation mechanism.
+[*["Data is all over the place in C++. How is it not already a dataflow language?]]
+
Take the following example - a simple real-time camera-input-displayed-on-the-screen
application. Suppose there are three parts to the application - getting each image frame from the camera,
processing the image in some way, and displaying it on the screen. A program that does it might
@@ -71,7 +71,7 @@
First, maintenance of the program has just become very intuitive. You don't
want to process the image any more? Connect the camera signal directly to the screen display and cut out
the image processing component. Someone gives you a new video signal generator component you'd like to use as input
-instead of the camera? Just plug it in.
+instead of the camera? Just plug it in. Literally.
Second, the program can now be divided between threads, processors, or computers more easily.
The display is on a different computer? No problem, just put the connection to it through a network socket.
@@ -83,11 +83,11 @@
With a visaul development environment, programming becomes as easy as connecting components with connections
(again, the Signal Network library provides no visual programming functionality).
-[*["I still don't get it. I can do all of this using my favorite non-dataflow programming approach just the same!]]
+[*["But I can do all of this using my favorite non-dataflow programming approach just the same!]]
Sure. Maybe you can. But if the application is really about the flow of data, why not
model it and implement it that way? If it's about the data signals and the components that process it,
-rather than about the sequence of instructions that needs to be executed, then the dataflowimplementation can reflect
+rather than about the sequence of instructions that needs to be executed, then the dataflow implementation can reflect
the application more closely, and it just might be easier to design and maintain.
[h4 Signal-based approach and pin-based approach]
@@ -282,7 +282,7 @@
signal network. The most basic is __storage__, which
can be used to store a value received through a signal, send it on, and/or retreive it.
-By default, components in the library use operator() to receive a signal.
+By default, components in the library use `operator()` to receive a signal.
For example, __storage__ objects can receive
signals through [memberref boost::signal_network::signet::storage::operator()(void) operator()()].
Upon receiving this signal, they will output their stored value through another signal.
Modified: sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network.qbk (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network.qbk 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -27,10 +27,18 @@
[def __fusion__ [@http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/index.html Boost.Fusion]]
+[import ../test/test_filter.cpp]
[import ../test/test_storage.cpp]
[import ../test/test_function.cpp]
[import ../test/test_chain.cpp]
[import ../test/test_socket.cpp]
+[import ../test/test_branching.cpp]
+[import ../test/test_pull.cpp]
+[import ../test/test_disconnect.cpp]
+[import ../test/test_multi_type.cpp]
+[import ../test/test_multi_args.cpp]
+[import ../test/test_same_type.cpp]
+[import ../test/test_multi_out.cpp]
The Signal Network library aims to facilitate the
implementation and interconnection of objects into signal networks using Boost.Signals.
@@ -137,7 +145,7 @@
* Thanks to all the members of the Boost community who have expressed an interest in this library
and contributed [link signal_network.discussion valuable feedback].
-* Thanks to Douglas Gregor for making himself available as a mentor for this project.
+* Thanks to Douglas Gregor for making himself available as a mentor for this project, and for his support, suggestions and feedback.
* Thanks to Tobias Schwinger for a most valuable discussion on various [link signal_network.introduction.dataflow
dataflow-oriented approaches and ideas].
Modified: sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network_doxygen.xml
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network_doxygen.xml (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/doc/signal_network_doxygen.xml 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -37,13 +37,13 @@
<template-type-parameter name="Group"/>
<template-type-parameter name="GroupCompare"/>
<template-type-parameter name="T"/>
- </template><parameter name="signal"><paramtype>boost::signal< Signature > &</paramtype></parameter><parameter name="link"><paramtype>T &</paramtype></parameter></function><function name="operator>="><type>boost::signal< Signature > &</type><template>
+ </template><parameter name="signal"><paramtype>boost::signal< Signature, Combiner, Group, GroupCompare > &</paramtype></parameter><parameter name="link"><paramtype>T &</paramtype></parameter></function><function name="operator|"><type>boost::signal< Signature > &</type><template>
<template-type-parameter name="Signature"/>
<template-type-parameter name="Combiner"/>
<template-type-parameter name="Group"/>
<template-type-parameter name="GroupCompare"/>
<template-type-parameter name="T"/>
- </template><parameter name="signal"><paramtype>boost::signal< Signature > &</paramtype></parameter><parameter name="link"><paramtype>T &</paramtype></parameter></function></namespace></namespace><macro name="SIGNAL_NETWORK_TRACKABLE"/><macro name="SIGNAL_NETWORK_OPEN_SIGNAL_NETWORK_NAMESPACE"/><macro name="SIGNAL_NETWORK_CLOSE_SIGNAL_NETWORK_NAMESPACE"/><macro name="SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE"/><macro name="SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE"/></header><header name="boost/signal_network/chain.hpp"><namespace name="boost"><namespace name="signal_network"><namespace name="signet"><class name="chain"><template>
+ </template><parameter name="signal"><paramtype>boost::signal< Signature, Combiner, Group, GroupCompare > &</paramtype></parameter><parameter name="link"><paramtype>T &</paramtype></parameter></function></namespace></namespace><macro name="SIGNAL_NETWORK_TRACKABLE"/><macro name="SIGNAL_NETWORK_OPEN_SIGNAL_NETWORK_NAMESPACE"/><macro name="SIGNAL_NETWORK_CLOSE_SIGNAL_NETWORK_NAMESPACE"/><macro name="SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE"/><macro name="SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE"/></header><header name="boost/signal_network/chain.hpp"><namespace name="boost"><namespace name="signal_network"><namespace name="signet"><class name="chain"><template>
<template-type-parameter name="T"/>
<template-type-parameter name="Signature"/>
</template><purpose>Connects a number of components of the same type in a chain. </purpose><description><para>
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-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -13,6 +13,7 @@
<define>BOOST_ALL_NO_LIB=1
;
+run test_filter.cpp ;
run test_storage.cpp ;
run test_counter.cpp ;
run test_junction.cpp ;
@@ -23,9 +24,11 @@
run test_socket.cpp
/boost/serialization//boost_serialization/<link>static
/boost/thread//boost_thread/<link>static ;
-# run test_connections.cpp
-# /boost/test//boost_unit_test_framework/<link>static
-# /boost/thread//boost_thread/<link>static
-# /boost/serialization//boost_serialization/<link>static ;
+run test_branching.cpp ;
+run test_pull.cpp ;
+run test_disconnect.cpp ;
+run test_multi_type.cpp ;
+run test_multi_args.cpp ;
+run test_same_type.cpp ;
+run test_multi_out.cpp ;
-run test_branching.cpp ;
\ No newline at end of file
Modified: sandbox/SOC/2007/signals/libs/signal_network/test/test_branching.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/test/test_branching.cpp (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_branching.cpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -7,7 +7,6 @@
#include <boost/signal_network/counter.hpp>
#include <boost/test/included/test_exec_monitor.hpp>
-#include <boost/fusion/sequence/view/single_view.hpp>
// for access to connection operators >>= and |
using namespace boost::signal_network;
Modified: sandbox/SOC/2007/signals/libs/signal_network/test/test_chain.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/test/test_chain.cpp (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_chain.cpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -28,7 +28,7 @@
typedef void result_type;
void operator()(const fusion::vector<float> &x)
{
- // this should be more general but having problems with the general approach...
+ // this could be more general but I'm having problems with the general approach...
fusion::vector<float> y;
boost::fusion::at_c<0>(y) = 2 * boost::fusion::at_c<0>(x);
fused_out(y);
Modified: sandbox/SOC/2007/signals/libs/signal_network/test/test_connections.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/signal_network/test/test_connections.cpp (original)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_connections.cpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -34,64 +34,12 @@
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
{
@@ -112,118 +60,6 @@
}
};
-void disconnect_test()
-{
- signet::storage<void ()>::unfused banger;
- {
- SignalVoidCounter counter;
- signet::storage<void (float)>::unfused floater;
- floater(2.5f);
- signet::storage<void (float)>::unfused collector(0.0f);
-
- banger
- | counter
- | (floater >>= collector);
-
- banger();
- BOOST_CHECK(counter.GetCount() == 1);
- 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
- // 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 ()>::unfused banger;
- signet::storage<void (int)>::unfused inter;
- inter(2);
- signet::storage<void (float)>::unfused 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 ()>::unfused banger;
- signet::storage<void (float)>::unfused 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)>::unfused, public SignalVoidCounter, public SignalFloat2Collector
{
public:
@@ -252,112 +88,8 @@
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 ()>::unfused 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 ()>::unfused banger1, banger2;
- SignalVoidCounter counter1, counter2;
- signet::junction<void ()>::unfused 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()
{
@@ -385,200 +117,7 @@
BOOST_CHECK(collector.value_<0>() == 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 ()>::unfused 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)>::unfused floater(1.0f);
- signet::storage<void (float)>::unfused collector(0.0f);
-
- floater >>= doubler1 >>= doubler2 >>= collector;
- floater();
- BOOST_CHECK(collector.value_<0>() == 4.0f);
-} // end void filter_test()
-
-float DoublerFunc(float x)
-{
- return x*2;
-}
-
-void function_test()
-{
- 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);
-} // end void function_test()
-
-void chain_test()
-{
- 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);
-} // end void chain_test
-
-class PullDoubler : public signet::filter<float ()>
-{
-public:
- float operator()()
- {
- return 2*out();
- }
-};
-
-void pull_test()
-{
- signet::storage<void(float)>::unfused generator(1.0f);
- PullDoubler doubler;
-
- doubler >>= generator.slot<0>();
-
- 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)>::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();
-}
-
-// 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)>::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();
-} // 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));
- 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_disconnect.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_disconnect.cpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -0,0 +1,54 @@
+// 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>
+#include <boost/signal_network/counter.hpp>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+int test_main(int, char* [])
+{
+ {
+ //[ test_disconnect_unfused
+ signet::storage<void ()>::unfused banger;
+ {
+ signet::counter<void ()>::unfused counter;
+ signet::storage<void (float)>::unfused floater;
+ floater(2.5f);
+ signet::storage<void (float)>::unfused collector(0.0f);
+
+ banger
+ | counter
+ | (floater >>= collector);
+
+ banger();
+ BOOST_CHECK_EQUAL(counter.count(), 1);
+ BOOST_CHECK_EQUAL(collector.at<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
+ // touch the signal to disconnect things that are destroyed:
+ // unfortunatelly, this call hangs on MSVC!
+ // banger();
+#endif
+ BOOST_CHECK_EQUAL(banger.default_signal().num_slots(), 0u);
+
+ signet::counter<void ()>::unfused counter;
+
+ banger >>= counter;
+ banger.disconnect_all_slots();
+
+ banger();
+ BOOST_CHECK_EQUAL(counter.count(), 0);
+ //]
+ }
+ return 0;
+} // int test_main(int, char* [])
+
+
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_filter.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_filter.cpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -0,0 +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)
+
+#include <boost/signal_network/storage.hpp>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+//[ test_filter_classes
+
+class DoublerClass : public signet::filter<void (float), signet::unfused_out_signal>
+{
+public:
+ void operator()(float x) {out(2*x);}
+};
+
+class FusedDoublerClass : public signet::filter<void (float), signet::fused_out_signal>
+{
+public:
+ typedef void result_type;
+ void operator()(const fusion::vector<float> &x)
+ {
+ // this could be more general but I'm having problems with the general approach...
+ fusion::vector<float> y;
+ boost::fusion::at_c<0>(y) = 2 * boost::fusion::at_c<0>(x);
+ fused_out(y);
+ }
+};
+
+//]
+
+int test_main(int, char* [])
+{
+ {
+ //[ test_filter_unfused
+
+ DoublerClass doubler1, doubler2;
+ signet::storage<void (float)>::unfused floater(1.0f);
+ signet::storage<void (float)>::unfused collector(0.0f);
+
+ floater >>= doubler1 >>= doubler2 >>= collector;
+ floater();
+
+ BOOST_CHECK_EQUAL(collector.at<0>(), 4.0f);
+
+ //]
+ }
+ {
+ //[ test_filter_fused
+
+ FusedDoublerClass doubler1, doubler2;
+ signet::storage<void (float)> floater(1.0f);
+ signet::storage<void (float)> collector(0.0f);
+
+ floater >>= doubler1 >>= doubler2 >>= collector;
+ floater();
+
+ BOOST_CHECK_EQUAL(collector.at<0>(), 4.0f);
+
+ //]
+ }
+ return 0;
+} // int test_main(int, char* [])
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_multi_args.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_multi_args.cpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -0,0 +1,91 @@
+// 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>
+#include <boost/optional.hpp>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+//[ test_multi_args_class1
+
+class SignalFloatDuplicator : public signet::filter<void (float, float)>
+{
+public:
+ void operator()(float val) {out(val, val);}
+};
+
+//]
+
+//[ test_multi_args_class2
+
+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
+
+//]
+
+int test_main(int, char* [])
+{
+ {
+ //[ test_multi_args_unfused
+ signet::storage<void ()>::unfused banger;
+ signet::storage<void (float)>::unfused floater;
+ floater(2.5f);
+ SignalFloatDuplicator duplicator;
+ SignalMultiCollector collector;
+
+ banger
+ | collector
+ |
+ (floater
+ | collector
+ | (duplicator >>= collector));
+
+ banger();
+ BOOST_CHECK_EQUAL(collector.GetCount(), 1);
+ BOOST_CHECK_EQUAL(collector.GetLast(), optional<float>(2.5f));
+ BOOST_CHECK_EQUAL(collector.GetLast1(), optional<float>(2.5f));
+ BOOST_CHECK_EQUAL(collector.GetLast2(), optional<float>(2.5f));
+ //]
+ }
+ return 0;
+} // int test_main(int, char* [])
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_multi_out.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_multi_out.cpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -0,0 +1,53 @@
+// 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>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+//[ test_multi_out_classes
+
+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
+
+//]
+
+int test_main(int, char* [])
+{
+ {
+ //[ test_multi_out_unfused
+
+ SignalOutIntFloat multi_out(2.5f);
+ signet::storage<void (float)>::unfused float_collector(0);
+ signet::storage<void (int)>::unfused int_collector(0);
+
+ multi_out >>= float_collector;
+ multi_out.out_int >>= int_collector;
+ multi_out();
+
+ BOOST_CHECK_EQUAL(float_collector.at<0>(), 2.5f);
+ BOOST_CHECK_EQUAL(int_collector.at<0>(), 2);
+
+ //]
+ }
+return 0;
+} // int test_main(int, char* [])
+
+
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_multi_type.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_multi_type.cpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -0,0 +1,63 @@
+// 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>
+#include <boost/optional.hpp>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+//[ test_multi_type_classes
+
+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
+
+//]
+
+int test_main(int, char* [])
+{
+ {
+ //[ test_multi_type_unfused
+ signet::storage<void ()>::unfused banger;
+ signet::storage<void (int)>::unfused inter;
+ inter(2);
+ signet::storage<void (float)>::unfused floater;
+ floater(3.3f);
+ SignalIntFloatCollector collector;
+
+ banger
+ | (inter >>= collector)
+ | (floater >>= collector);
+
+ banger();
+ BOOST_CHECK_EQUAL(collector.GetLastInt(), optional<int>(2));
+ BOOST_CHECK_EQUAL(collector.GetLastFloat(), optional<float>(3.3f));
+ //]
+ }
+ return 0;
+} // int test_main(int, char* [])
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_pull.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_pull.cpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -0,0 +1,41 @@
+// 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>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+//[ test_pull_classes
+class PullDoubler : public signet::filter<float (), signet::unfused_out_signal>
+{
+public:
+ float operator()()
+ {
+ return 2*out();
+ }
+};
+//]
+
+int test_main(int, char* [])
+{
+ {
+ //[ test_pull_unfused
+
+ signet::storage<void(float)>::unfused generator(1.0f);
+ PullDoubler doubler;
+
+ doubler >>= generator.value_at_slot<0>();
+
+ BOOST_CHECK(doubler() == 2.0f);
+ //]
+ }
+ return 0;
+} // int test_main(int, char* [])
+
+
Added: sandbox/SOC/2007/signals/libs/signal_network/test/test_same_type.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/signal_network/test/test_same_type.cpp 2007-06-14 12:59:02 EDT (Thu, 14 Jun 2007)
@@ -0,0 +1,70 @@
+// 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>
+#include <boost/signal_network/counter.hpp>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+// for access to connection operators >>= and |
+using namespace boost::signal_network;
+using namespace boost;
+
+//[ test_same_type_classes
+
+class Signal2VoidCounter : public signet::counter<void ()>::unfused
+{
+public:
+ signet::counter<void ()>::unfused other;
+}; // end class Signal2VoidCounter
+
+class Signal2VoidInputs
+{
+ int result;
+public:
+ Signal2VoidInputs() : result(0) {};
+ void operator()()
+ {
+ result++;
+ }
+ void AltInput()
+ {
+ result+=10;
+ }
+ int GetResult()
+ {
+ return result;
+ }
+}; // end class Signal2VoidInputs
+
+//]
+
+int test_main(int, char* [])
+{
+ {
+ //[ test_same_type_unfused
+ signet::storage<void ()>::unfused banger;
+ Signal2VoidCounter counter;
+
+ banger
+ | counter
+ | counter.other;
+
+ banger();
+ BOOST_CHECK_EQUAL(counter.count(), 1);
+ BOOST_CHECK_EQUAL(counter.other.count(), 1);
+
+ Signal2VoidInputs inputs;
+
+ banger
+ | inputs
+ | slot_selector<void ()> (inputs, &Signal2VoidInputs::AltInput);
+
+ banger();
+ BOOST_CHECK_EQUAL(inputs.GetResult(), 11);
+ //]
+ }
+ return 0;
+} // int test_main(int, char* [])
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