Boost logo

Boost-Commit :

From: stipe_at_[hidden]
Date: 2008-07-16 13:09:23


Author: srajko
Date: 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
New Revision: 47477
URL: http://svn.boost.org/trac/boost/changeset/47477

Log:
Dataflow.Managed supports generic vectors of ports
Added:
   sandbox/SOC/2007/signals/boost/fusion/
   sandbox/SOC/2007/signals/boost/fusion/container/
   sandbox/SOC/2007/signals/boost/fusion/container/lazy_sequence.hpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/test/utility/test_lazy_sequence.cpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/test/utility/test_vector_same_initialization.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/signals/boost/dataflow/detail/make_ref.hpp | 5 ++
   sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp | 100 +++++++++++++++++++++++++++++++--------
   sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj | 23 +++++++++
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_example.cpp | 2
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp | 54 ++++++++++++++++++--
   sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/test_managed_port.cpp | 4
   sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_fusion_component.cpp | 7 ++
   sandbox/SOC/2007/signals/libs/dataflow/test/utility/Jamfile.v2 | 4 +
   8 files changed, 164 insertions(+), 35 deletions(-)

Modified: sandbox/SOC/2007/signals/boost/dataflow/detail/make_ref.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/detail/make_ref.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/detail/make_ref.hpp 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -22,6 +22,11 @@
         struct result<make_ref(T&)>
             : boost::add_reference<T>
         {};
+
+ template<typename T>
+ struct result<make_ref(T)>
+ : boost::add_reference<T>
+ {};
         
         template<typename T>
         typename boost::add_reference<T>::type operator()(T& t) const

Modified: sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -6,59 +6,117 @@
 #ifndef BOOST_DATAFLOW_MANAGED_FUSION_COMPONENT_HPP
 #define BOOST_DATAFLOW_MANAGED_FUSION_COMPONENT_HPP
 
+#include <boost/dataflow/detail/make_ref.hpp>
 #include <boost/dataflow/support/fusion_component.hpp>
 #include <boost/dataflow/managed/port.hpp>
 #include <boost/dataflow/managed/component.hpp>
 #include <boost/dataflow/support/component_operation.hpp>
+#include <boost/dataflow/utility/forced_sequence.hpp>
+#include <boost/fusion/container/lazy_sequence.hpp>
+#include <boost/fusion/include/as_vector.hpp>
+#include <boost/fusion/include/size.hpp>
+#include <boost/fusion/include/transform.hpp>
 #include <boost/mpl/map.hpp>
+#include <boost/mpl/joint_view.hpp>
+#include <boost/mpl/vector.hpp>
 
 namespace boost { namespace dataflow { namespace managed {
 
-template<typename InOutType>
+namespace detail
+{
+ struct add_reference;
+
+ template<typename T, typename PortCategory>
+ struct make_managed_port
+ {
+ typedef managed::port<T, PortCategory> type;
+ };
+
+ template<typename ConsumerSignatures, typename ProducerSignatures>
+ struct make_fusion_ports
+ {
+ typedef typename fusion::result_of::as_vector<
+ mpl::joint_view<
+ typename mpl::transform<
+ ConsumerSignatures,
+ make_managed_port<mpl::_1, ports::consumer>
+ >::type,
+ typename mpl::transform<
+ ProducerSignatures,
+ make_managed_port<mpl::_1, ports::producer>
+ >::type
+ >
+ >::type type;
+ };
+
+}
+
+template<typename InTypes, typename OutTypes>
 struct component_traits
- : public dataflow::fusion_component_traits<
- fusion::vector<
- managed::port<InOutType, ports::consumer> &,
- managed::port<InOutType, ports::producer> &
- >,
+ : public dataflow::component_traits<
+ typename detail::make_fusion_ports<InTypes, OutTypes>::type,
         mpl::map< >,
         managed::tag>
 {
+ typedef boost::fusion::transform_view<
+ typename detail::make_fusion_ports<InTypes, OutTypes>::type,
+ boost::dataflow::detail::make_ref
+ > fusion_ports;
+
     template<typename Component>
     static typename component_traits::fusion_ports get_ports(Component &component)
     {
- return typename component_traits::fusion_ports(
- component.consumer_port(),
- component.producer_port());
+ return typename component_traits::fusion_ports(component.ports(), boost::dataflow::detail::make_ref());
     };
 };
 
-template<typename InOutType>
+namespace detail {
+
+ struct component_f
+ {
+ typedef component &result_type;
+
+ component_f(component &c)
+ : m_component(c) {}
+
+ template<typename Index>
+ result_type operator()(Index) const
+ { return m_component; }
+
+ mutable result_type m_component;
+ };
+
+}
+
+template<typename InTypes, typename OutTypes=InTypes>
 class fusion_component : public component
 {
 public:
- typedef component_traits<InOutType> dataflow_traits;
+ typedef typename dataflow::utility::forced_sequence<InTypes>::type in_types_sequence;
+ typedef typename dataflow::utility::forced_sequence<OutTypes>::type out_types_sequence;
+
+ typedef component_traits<in_types_sequence, out_types_sequence> dataflow_traits;
+ typedef typename detail::make_fusion_ports<in_types_sequence, out_types_sequence>::type ports_type;
     
     fusion_component(network &n)
         : component(n)
- , m_consumer_port(*this)
- , m_producer_port(*this)
+ , m_ports(boost::fusion::make_lazy_sequence(detail::component_f(*this), typename fusion::result_of::size<ports_type>::type()))
     {}
- port<InOutType, ports::consumer> &consumer_port()
- { return m_consumer_port; }
- port<InOutType, ports::producer> &producer_port()
- { return m_producer_port; }
+ template<int Index>
+ typename fusion::result_of::at_c<ports_type, Index>::type port()
+ { return fusion::at_c<Index>(m_ports); }
+ ports_type &ports()
+ { return m_ports; }
 protected:
- port<InOutType, ports::consumer> m_consumer_port;
- port<InOutType, ports::producer> m_producer_port;
+ ports_type m_ports;
 };
 
 }
 
 namespace extension {
 
- template<typename T>
- struct component_operation_impl<managed::component_traits<T>, operations::invoke >
+ template<typename InTypesSequence, typename OutTypesSequence>
+ struct component_operation_impl<managed::component_traits<InTypesSequence,OutTypesSequence>, operations::invoke >
     {
         typedef void result_type;
         

Added: sandbox/SOC/2007/signals/boost/fusion/container/lazy_sequence.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/fusion/container/lazy_sequence.hpp 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -0,0 +1,195 @@
+/*=============================================================================
+ Copyright (c) 2001-2006 Joel de Guzman
+ Copyright (c) 2006 Dan Marsden
+ Copyright (c) 2008 Stjepan Rajko
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#if !defined(FUSION_SEQUENCE_CLASS_LAZY_SEQUENCE_10022005_0602)
+#define FUSION_SEQUENCE_CLASS_LAZY_SEQUENCE_10022005_0602
+
+#include <boost/fusion/sequence/sequence_facade.hpp>
+#include <boost/fusion/iterator/iterator_facade.hpp>
+
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/minus.hpp>
+
+#include <boost/utility/result_of.hpp>
+
+#include <boost/function_types/is_function.hpp>
+
+namespace boost { namespace fusion {
+
+ template<typename Seq, int N>
+ struct lazy_sequence_iterator
+ : fusion::iterator_facade<lazy_sequence_iterator<Seq, N>, fusion::random_access_traversal_tag>
+ {
+ typedef mpl::int_<N> index;
+ typedef Seq sequence_type;
+
+ lazy_sequence_iterator(Seq& seq)
+ : seq_(seq) {}
+
+ Seq& seq_;
+
+ template<typename T>
+ struct value_of;
+
+ template<typename Sq>
+ struct value_of<lazy_sequence_iterator<Sq, N> >
+ : mpl::identity<typename boost::result_of<typename Seq::generator_type(mpl::int_<N>)>::type>
+ {};
+
+ template<typename T>
+ struct deref;
+
+ template <typename Sq, int N_>
+ struct deref<lazy_sequence_iterator<Sq, N_> >
+ {
+ typedef typename boost::result_of<typename Seq::generator_type(mpl::int_<N_>)>::type type;
+
+ static type
+ call(lazy_sequence_iterator<Sq, N_> const& iter)
+ {
+ return iter.seq_.generator(mpl::int_<N_>());
+ }
+ };
+
+ template<typename It>
+ struct next
+ {
+ typedef lazy_sequence_iterator<
+ typename It::sequence_type, It::index::value + 1> type;
+
+ static type call(It const& it)
+ {
+ return type(it.seq_);
+ }
+ };
+
+ template<typename It>
+ struct prior
+ {
+ typedef lazy_sequence_iterator<
+ typename It::sequence_type, It::index::value - 1> type;
+
+ static type call(It const& it)
+ {
+ return type(it.seq_);
+ }
+ };
+
+ template<typename It1, typename It2>
+ struct distance
+ {
+ typedef typename mpl::minus<typename It2::index, typename It1::index>::type type;
+
+ static type call(It1 const& it1, It2 const& it2)
+ {
+ return type();
+ }
+ };
+
+ template<typename It, typename M>
+ struct advance
+ {
+ typedef lazy_sequence_iterator<
+ typename It::sequence_type,
+ It::index::value + M::value> type;
+
+ static type call(It const& it)
+ {
+ return type(it.seq_);
+ }
+ };
+ };
+
+ template<typename Generator, int Size>
+ struct lazy_sequence
+ : fusion::sequence_facade<lazy_sequence<Generator, Size>, fusion::random_access_traversal_tag>
+ {
+ lazy_sequence()
+ : generator()
+ {}
+
+ lazy_sequence(const Generator &generator)
+ : generator(generator)
+ {}
+
+ template<typename Sq>
+ struct begin
+ {
+ typedef lazy_sequence_iterator<
+ Sq, 0> type;
+
+ static type call(Sq& sq)
+ {
+ return type(sq);
+ }
+ };
+
+ template<typename Sq>
+ struct end
+ {
+ typedef lazy_sequence_iterator<
+ Sq, Size> type;
+
+ static type call(Sq& sq)
+ {
+ return type(sq);
+ }
+ };
+
+ template<typename Sq>
+ struct size
+ : mpl::int_<Size>
+ {};
+
+ template<typename Sq, typename N>
+ struct value_at
+ {
+ typedef typename boost::result_of<Generator(N)>::type type;
+ };
+
+ template<typename Sq, typename N>
+ struct at
+ {
+ typedef typename boost::result_of<Generator(N)>::type type;
+
+ static type call(Sq& sq)
+ {
+ return sq.generator(N());
+ }
+ };
+
+ typedef Generator generator_type;
+ generator_type generator;
+ };
+
+ namespace result_of
+ {
+ template<typename G, typename Size>
+ struct make_lazy_sequence
+ {
+ typedef lazy_sequence<
+ typename
+ mpl::if_<
+ function_types::is_function<G>,
+ G *,
+ G
+ >::type,
+ Size::value
+ > type;
+ };
+ }
+
+ template<typename G, typename Size>
+ typename result_of::make_lazy_sequence<G, Size>::type make_lazy_sequence(const G &g, Size size)
+ {
+ return typename result_of::make_lazy_sequence<G, Size>::type(g);
+ }
+} }
+
+#endif
\ No newline at end of file

Modified: sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -140,6 +140,8 @@
                 089CDA940D832AD200731C70 /* tutorial.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tutorial.qbk; sourceTree = "<group>"; };
                 089CDAA90D8333CC00731C70 /* unary_operation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = unary_operation.hpp; sourceTree = "<group>"; };
                 089E78C20E132E220008C0BB /* dynamic_multi_port.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = dynamic_multi_port.hpp; sourceTree = "<group>"; };
+ 089F845A0E2CFAB900F6B668 /* lazy_sequence.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lazy_sequence.hpp; sourceTree = "<group>"; };
+ 089F845E0E2D032E00F6B668 /* test_lazy_sequence.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_lazy_sequence.cpp; sourceTree = "<group>"; };
                 08A0B20C0D21C4A90054AD32 /* cppgui_example.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cppgui_example.cpp; sourceTree = "<group>"; };
                 08A0B20D0D21C4A90054AD32 /* Jamfile.v2 */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Jamfile.v2; sourceTree = "<group>"; };
                 08A0B2AC0D21D88F0054AD32 /* blueprint_bank.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = blueprint_bank.cpp; sourceTree = "<group>"; };
@@ -218,6 +220,7 @@
                 08D2C7330D1DDE5C008388D7 /* Jamfile.v2 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Jamfile.v2; sourceTree = "<group>"; };
                 08D2C7390D1DDEB8008388D7 /* fltk_gui_example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fltk_gui_example.cpp; sourceTree = "<group>"; };
                 08DC14FC0C951C4800B96B2E /* Cone.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Cone.cxx; sourceTree = "<group>"; };
+ 08E180320E2C863D00F4BF04 /* test_vector_same_initialization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_vector_same_initialization.cpp; sourceTree = "<group>"; };
                 08EBA7590CFF8B6D0080E225 /* example.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = example.cpp; sourceTree = "<group>"; };
                 08EF045E0CEBF1AD002ABBBC /* port_t.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = port_t.hpp; sourceTree = "<group>"; };
                 08EF9B220C5D506A00D4D206 /* applicator.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = applicator.hpp; sourceTree = "<group>"; };
@@ -387,6 +390,7 @@
                 080DD7560C13908400EEB53D = {
                         isa = PBXGroup;
                         children = (
+ 089B78DE0E2C2E5900D09757 /* fusion */,
                                 08A2D5030E2A728A00D8FA04 /* glv */,
                                 08A439340E295B35009845FD /* build */,
                                 0800AC390C8CAAC300994538 /* boost-build.jam */,
@@ -435,6 +439,8 @@
                                 089AE5BC0D79CE5E00AB9DA8 /* test_bind_mem_fn.cpp */,
                                 08920DCE0D84514B00E148EF /* test_bind_mem_fn_overload.cpp */,
                                 08AD8AB50D84DF31008A9764 /* test_has_call_operator.cpp */,
+ 08E180320E2C863D00F4BF04 /* test_vector_same_initialization.cpp */,
+ 089F845E0E2D032E00F6B668 /* test_lazy_sequence.cpp */,
                         );
                         path = utility;
                         sourceTree = "<group>";
@@ -465,6 +471,23 @@
                         path = examples;
                         sourceTree = "<group>";
                 };
+ 089B78DE0E2C2E5900D09757 /* fusion */ = {
+ isa = PBXGroup;
+ children = (
+ 089B78DF0E2C2E5900D09757 /* container */,
+ );
+ name = fusion;
+ path = ../../../../boost/fusion;
+ sourceTree = SOURCE_ROOT;
+ };
+ 089B78DF0E2C2E5900D09757 /* container */ = {
+ isa = PBXGroup;
+ children = (
+ 089F845A0E2CFAB900F6B668 /* lazy_sequence.hpp */,
+ );
+ path = container;
+ sourceTree = "<group>";
+ };
                 089C08A30E0AFA5E00397123 /* managed */ = {
                         isa = PBXGroup;
                         children = (

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_example.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_example.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_example.cpp 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -32,7 +32,6 @@
     }
     void operator()(float x)
     {
- std::cout <<"val: " << x << std::endl;
         value(x, 0);
         out(x);
     }
@@ -52,7 +51,6 @@
     bool onEvent(glv::Event::t e, glv::GLV& glv)
     {
         bool response = glv::Slider::onEvent(e, glv);
- std::cout <<"preval: " << value(0) << std::endl;
         out(value(0));
         return response;
     }

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -36,17 +36,17 @@
     }
     void invoke()
     {
- if(m_consumer_port.connected())
+ if(port<0>().connected())
         {
- value(m_consumer_port.get(), 0);
- m_producer_port.set(m_consumer_port.get());
+ value(port<0>().get(), 0);
+ port<1>().set(port<0>().get());
         }
     }
     bool onEvent(glv::Event::t e, glv::GLV& glv)
     {
         bool response = glv::Button::onEvent(e, glv);
         std::cout <<"preval: " << value(0) << std::endl;
- m_producer_port.set(value(0));
+ port<1>().set(value(0));
         return response;
     }
 };
@@ -65,10 +65,48 @@
     }
     void invoke()
     {
- if(m_consumer_port.connected())
+ if(port<0>().connected())
         {
- m_producer_port.set(!m_consumer_port.get());
- value(m_producer_port.get(), 0);
+ port<1>().set(!port<0>().get());
+ value(port<1>().get(), 0);
+ }
+ }
+};
+
+// adder has two input ports and an output port.
+// invoking adds the two inputs into the output.
+class and_operation : public fusion_component<boost::mpl::vector<bool,bool>,bool>
+{
+public:
+ typedef fusion_component<boost::mpl::vector<bool,bool>,bool> base_type;
+
+ and_operation(df::managed::network &network)
+ : base_type(network)
+ {}
+ void invoke()
+ {
+ if(port<0>().connected())
+ {
+ port<2>().set(port<0>().get() && port<1>().get());
+ }
+ }
+};
+
+// adder has two input ports and an output port.
+// invoking adds the two inputs into the output.
+class or_operation : public fusion_component<boost::mpl::vector<bool,bool>,bool>
+{
+public:
+ typedef fusion_component<boost::mpl::vector<bool,bool>,bool> base_type;
+
+ or_operation(df::managed::network &network)
+ : base_type(network)
+ {}
+ void invoke()
+ {
+ if(port<0>().connected())
+ {
+ port<2>().set(port<0>().get() || port<1>().get());
         }
     }
 };
@@ -96,6 +134,8 @@
     {
         add_component<source>("src", boost::ref(m_network));
         add_component<not_operation>("not", boost::ref(m_network));
+ add_component<and_operation>("and", boost::ref(m_network));
+ add_component<or_operation>("or", boost::ref(m_network));
         add_component<update_network>("upd", boost::ref(m_network));
     }
 private:

Modified: sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/test_managed_port.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/test_managed_port.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/test_managed_port.cpp 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -19,8 +19,8 @@
     df::managed::network network;
     df::managed::fusion_component<bool> component(network);
         
- blueprint::port_t<df::managed::port<bool, df::ports::producer> &, df::managed::tag > source(component.producer_port());
- blueprint::port_t<df::managed::port<bool, df::ports::consumer>, df::managed::tag > sink(component.consumer_port());
+ blueprint::port_t<df::managed::port<bool, df::ports::producer> &, df::managed::tag > source(component.port<1>());
+ blueprint::port_t<df::managed::port<bool, df::ports::consumer>, df::managed::tag > sink(component.port<0>());
     
     BOOST_CHECK((df::is_complemented_port<df::managed::port<bool, df::ports::producer>, df::managed::tag>::value));
     BOOST_CHECK(source.is_complemented_port());

Modified: sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_fusion_component.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_fusion_component.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/managed/test_fusion_component.cpp 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -16,8 +16,11 @@
     df::managed::network network;
     df::managed::fusion_component<bool> c(network);
     
- BOOST_CHECK_EQUAL((&df::get_port<boost::mpl::int_<0>, df::managed::tag >(c)), &c.consumer_port());
- BOOST_CHECK_EQUAL((&df::get_port<boost::mpl::int_<1>, df::managed::tag >(c)), &c.producer_port());
+ df::get_port<boost::mpl::int_<0>, df::managed::tag >(c);
+ c.port<0>();
+
+ BOOST_CHECK_EQUAL((&df::get_port<boost::mpl::int_<0>, df::managed::tag >(c)), &c.port<0>());
+ BOOST_CHECK_EQUAL((&df::get_port<boost::mpl::int_<1>, df::managed::tag >(c)), &c.port<1>());
         
     return 0;
 } // int test_main(int, char* [])

Modified: sandbox/SOC/2007/signals/libs/dataflow/test/utility/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/test/utility/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/utility/Jamfile.v2 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -14,4 +14,6 @@
 run test_forced_sequence.cpp ;
 run test_bind_mem_fn.cpp ;
 run test_bind_mem_fn_overload.cpp ;
-run test_has_call_operator.cpp ;
\ No newline at end of file
+run test_has_call_operator.cpp ;
+run test_vector_same_initialization.cpp ;
+run test_lazy_sequence.cpp ;
\ No newline at end of file

Added: sandbox/SOC/2007/signals/libs/dataflow/test/utility/test_lazy_sequence.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/utility/test_lazy_sequence.cpp 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -0,0 +1,82 @@
+// Copyright Stjepan Rajko 2008. 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/fusion/container/lazy_sequence.hpp>
+
+#include <boost/fusion/sequence/intrinsic.hpp>
+#include <boost/fusion/iterator.hpp>
+
+#include <boost/fusion/support/category_of.hpp>
+#include <boost/mpl/assert.hpp>
+
+#include <boost/type_traits/is_const.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+template<typename T>
+struct singleton_functor
+{
+ typedef const T& result_type;
+
+ singleton_functor(const T& t)
+ : t(t) {}
+
+ template<typename Index>
+ result_type operator()(Index i)
+ { return t; }
+
+ T t;
+};
+
+template<typename T>
+struct index_plus_one
+{
+ typedef T result_type;
+
+ template<typename Index>
+ result_type operator()(Index i)
+ { return Index::value + 1; }
+};
+
+int one(int index)
+{
+ return 1;
+}
+
+int test_main(int, char* [])
+{
+ namespace fusion=boost::fusion;
+
+ typedef fusion::lazy_sequence<singleton_functor<int>,3> ones_triple_type;
+ ones_triple_type ones_triple(singleton_functor<int>(1));
+
+ BOOST_CHECK_EQUAL(*fusion::begin(ones_triple),1);
+ BOOST_CHECK_EQUAL(*fusion::next(fusion::begin(ones_triple)), 1);
+ BOOST_CHECK_EQUAL(*fusion::prior(fusion::end(ones_triple)), 1);
+ BOOST_CHECK_EQUAL(fusion::distance(fusion::begin(ones_triple), fusion::end(ones_triple)), 3);
+ BOOST_CHECK_EQUAL(fusion::size(ones_triple), 3);
+ BOOST_CHECK((boost::is_same<const int &, fusion::result_of::value_at_c<ones_triple_type, 0>::type >::value));
+ BOOST_CHECK((boost::is_same<const int &, fusion::result_of::value_at_c<ones_triple_type, 1>::type >::value));
+ BOOST_CHECK((boost::is_same<const int &, fusion::result_of::value_at_c<ones_triple_type, 2>::type >::value));
+
+ typedef fusion::lazy_sequence<index_plus_one<size_t>,4> index_shift_type;
+ index_shift_type index_shift;
+
+ BOOST_CHECK_EQUAL(fusion::at_c<0>(index_shift), 1u);
+ BOOST_CHECK_EQUAL(fusion::at_c<1>(index_shift), 2u);
+ BOOST_CHECK_EQUAL(fusion::at_c<2>(index_shift), 3u);
+ BOOST_CHECK_EQUAL(fusion::at_c<3>(index_shift), 4u);
+
+
+ BOOST_CHECK_EQUAL(fusion::at_c<0>(fusion::make_lazy_sequence(one, boost::mpl::int_<1>())), 1);
+
+ return 0;
+} // int test_main(int, char* [])
+
+
+
+

Added: sandbox/SOC/2007/signals/libs/dataflow/test/utility/test_vector_same_initialization.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/utility/test_vector_same_initialization.cpp 2008-07-16 13:09:21 EDT (Wed, 16 Jul 2008)
@@ -0,0 +1,33 @@
+// Copyright Stjepan Rajko 2008. 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/fusion/include/vector.hpp>
+#include <boost/fusion/container/lazy_sequence.hpp>
+#include <boost/fusion/include/at.hpp>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+int one(int index)
+{
+ return 1;
+}
+
+int test_main(int, char* [])
+{
+ using namespace boost::fusion;
+
+ vector<int, float, double> ones(make_lazy_sequence(one, boost::mpl::int_<3>()));
+
+ BOOST_CHECK_EQUAL(at_c<0>(ones), 1);
+ BOOST_CHECK_EQUAL(at_c<1>(ones), 1.0f);
+ BOOST_CHECK_EQUAL(at_c<2>(ones), 1.0);
+
+ 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