Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50254 - in sandbox/dataflow-rewrite: boost/dataflow/blueprint boost/dataflow/utility libs/dataflow/build/xcodeide/dataflow.xcodeproj libs/dataflow/test/blueprint libs/dataflow/test/utility
From: stipe_at_[hidden]
Date: 2008-12-12 18:00:30


Author: srajko
Date: 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
New Revision: 50254
URL: http://svn.boost.org/trac/boost/changeset/50254

Log:
framework_entity_adapter now uses Dereferencable semantics for underlying object, added containing_ptr
Added:
   sandbox/dataflow-rewrite/boost/dataflow/utility/containing_ptr.hpp (contents, props changed)
   sandbox/dataflow-rewrite/libs/dataflow/test/utility/test_containing_ptr.cpp (contents, props changed)
Text files modified:
   sandbox/dataflow-rewrite/boost/dataflow/blueprint/factory.hpp | 5 +++--
   sandbox/dataflow-rewrite/boost/dataflow/blueprint/framework_entity_adapter.hpp | 26 +++++++++++++-------------
   sandbox/dataflow-rewrite/boost/dataflow/blueprint/static_vector_adapter.hpp | 2 +-
   sandbox/dataflow-rewrite/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj | 4 ++++
   sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/my_blueprint_ports.hpp | 17 +++++++++++++++--
   sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/my_blueprint_static_vector.hpp | 9 ++++++++-
   sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/test_factory.cpp | 5 +++--
   sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/test_framework_entity.cpp | 9 +++++----
   sandbox/dataflow-rewrite/libs/dataflow/test/utility/Jamfile | 1 +
   9 files changed, 53 insertions(+), 25 deletions(-)

Modified: sandbox/dataflow-rewrite/boost/dataflow/blueprint/factory.hpp
==============================================================================
--- sandbox/dataflow-rewrite/boost/dataflow/blueprint/factory.hpp (original)
+++ sandbox/dataflow-rewrite/boost/dataflow/blueprint/factory.hpp 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -11,6 +11,7 @@
 
 
 #include <boost/dataflow/blueprint/port_adapter.hpp>
+#include <boost/dataflow/utility/containing_ptr.hpp>
 
 #include <boost/bind.hpp>
 #include <boost/function.hpp>
@@ -91,12 +92,12 @@
     template<typename T>
     void add_port(const std::string &s)
     {
- m_components[s] = boost::bind(boost::factory<port_adapter<BlueprintFramework, T> *>(), _1);
+ m_components[s] = boost::bind(boost::factory<port_adapter<BlueprintFramework, utility::containing_ptr<T> > *>(), _1);
     }
     template<typename T, typename T0>
     void add_port(const std::string &s, const T0 &t0)
     {
- m_components[s] = boost::bind(boost::factory<port_adapter<BlueprintFramework, T> *>(), _1, t0);
+ m_components[s] = boost::bind(boost::factory<port_adapter<BlueprintFramework, utility::containing_ptr<T> > *>(), _1, t0);
     }
     void add_entity(const std::string &s, const function_type &f)
     {

Modified: sandbox/dataflow-rewrite/boost/dataflow/blueprint/framework_entity_adapter.hpp
==============================================================================
--- sandbox/dataflow-rewrite/boost/dataflow/blueprint/framework_entity_adapter.hpp (original)
+++ sandbox/dataflow-rewrite/boost/dataflow/blueprint/framework_entity_adapter.hpp 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -15,48 +15,48 @@
 #include <boost/dataflow/utility/is_type.hpp>
 #include <boost/type_traits/remove_reference.hpp>
 #include <boost/utility/enable_if.hpp>
-
+#include <boost/pointee.hpp>
 
 namespace boost { namespace dataflow { namespace blueprint {
 
-template<typename BlueprintFramework, typename EntityOrRef, typename Base=framework_entity<BlueprintFramework>, typename Enable=void >
+template<typename BlueprintFramework, typename Dereferencable, typename Base=framework_entity<BlueprintFramework>, typename Enable=void >
 class framework_entity_adapter : public Base
 {
 public:
- typedef typename remove_reference<EntityOrRef>::type entity_type;
+ typedef typename pointee<Dereferencable>::type entity_type;
     
     framework_entity_adapter(blueprint::framework_context<BlueprintFramework> &fo)
- : Base(fo, typeid(m_entity))
+ : Base(fo, typeid(*m_entity))
     {}
     template<typename T>
     framework_entity_adapter(blueprint::framework_context<BlueprintFramework> &fo, const T &t)
- : Base(fo, typeid(m_entity))
+ : Base(fo, typeid(*m_entity))
         , m_entity(t)
     {}
     template<typename T>
     framework_entity_adapter(blueprint::framework_context<BlueprintFramework> &fo, T &t)
- : Base(fo, typeid(m_entity))
+ : Base(fo, typeid(*m_entity))
         , m_entity(t)
     {}
 
     entity_type &entity()
     {
- return m_entity;
+ return *m_entity;
     }
     const entity_type &entity() const
     {
- return m_entity;
+ return *m_entity;
     }
 private:
     virtual void *get_ptr()
     {
- return &m_entity;
+ return &*m_entity;
     };
- EntityOrRef m_entity;
+ Dereferencable m_entity;
 };
 
-template<typename BlueprintFramework, typename EntityOrRef, typename Base>
-class framework_entity_adapter<BlueprintFramework, EntityOrRef, Base,
+/*template<typename BlueprintFramework, typename Dereferencable, typename Base>
+class framework_entity_adapter<BlueprintFramework, Dereferencable, Base,
     typename enable_if<typename BlueprintFramework::framework_has_object>::type>
     : public Base
 {
@@ -107,7 +107,7 @@
         return &m_entity;
     };
     EntityOrRef m_entity;
-};
+};*/
 
 } } } // namespace boost::dataflow::blueprint
 

Modified: sandbox/dataflow-rewrite/boost/dataflow/blueprint/static_vector_adapter.hpp
==============================================================================
--- sandbox/dataflow-rewrite/boost/dataflow/blueprint/static_vector_adapter.hpp (original)
+++ sandbox/dataflow-rewrite/boost/dataflow/blueprint/static_vector_adapter.hpp 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -75,7 +75,7 @@
         template<typename Entity>
         void operator()(Entity &entity) const
         {
- m_ports.push_back(new port_adapter<BlueprintFramework, Entity &>(m_fo, entity));
+ m_ports.push_back(new port_adapter<BlueprintFramework, Entity *>(m_fo, &entity));
         }
         ptr_vector<port<BlueprintFramework> > &m_ports;
         framework_context<BlueprintFramework> &m_fo;

Added: sandbox/dataflow-rewrite/boost/dataflow/utility/containing_ptr.hpp
==============================================================================
--- (empty file)
+++ sandbox/dataflow-rewrite/boost/dataflow/utility/containing_ptr.hpp 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -0,0 +1,68 @@
+/*=================================---------------------------------------------
+ Copyright 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)
+-----------------------------------------------===============================*/
+
+#ifndef BOOST__DATAFLOW__UTILITY__CONTAINING_PTR_HPP
+#define BOOST__DATAFLOW__UTILITY__CONTAINING_PTR_HPP
+
+#include <boost/pointee.hpp>
+
+namespace boost { namespace dataflow {
+
+namespace utility
+{
+
+ template<typename T>
+ class containing_ptr
+ {
+ public:
+ containing_ptr()
+ {}
+ template<typename T0>
+ containing_ptr(T0 &t0)
+ : t(t0)
+ {}
+ template<typename T0>
+ containing_ptr(const T0 &t0)
+ : t(t0)
+ {}
+ template<typename T0, typename T1>
+ containing_ptr(const T0 &t0, const T1 &t1)
+ : t(t0, t1)
+ {}
+ T *operator->()
+ {
+ return &t;
+ }
+ const T *operator->() const
+ {
+ return &t;
+ }
+ T &operator*()
+ {
+ return t;
+ }
+ const T &operator*() const
+ {
+ return t;
+ }
+ private:
+ T t;
+ };
+} // namespace utility
+
+} // namespace dataflow
+
+ template <class T>
+ struct pointee<dataflow::utility::containing_ptr<T> >
+ {
+ typedef T type;
+ };
+
+} // namespace boost
+
+#endif // BOOST__DATAFLOW__UTILITY__CONTAINING_PTR_HPP

Modified: sandbox/dataflow-rewrite/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj
==============================================================================
--- sandbox/dataflow-rewrite/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj (original)
+++ sandbox/dataflow-rewrite/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -139,6 +139,8 @@
                 089F03530EE9615200C88FE5 /* shared_ptr_to_element.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = shared_ptr_to_element.hpp; sourceTree = "<group>"; };
                 089F03570EE96BA800C88FE5 /* test_shared_ptr_to_element.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_shared_ptr_to_element.cpp; sourceTree = "<group>"; };
                 089F03590EE96BEB00C88FE5 /* Jamfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.jam; path = Jamfile; sourceTree = "<group>"; };
+ 089F59B70EF313E90088D651 /* containing_ptr.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = containing_ptr.hpp; sourceTree = "<group>"; };
+ 089F59D90EF317D30088D651 /* test_containing_ptr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_containing_ptr.cpp; sourceTree = "<group>"; };
                 08A0FF8A0E8B4012000F0F8F /* file_template.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = file_template.py; sourceTree = "<group>"; };
                 08A227910EAE417000F70466 /* Jamfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.jam; path = Jamfile; sourceTree = "<group>"; };
                 08A227930EAE417C00F70466 /* Jamfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.jam; path = Jamfile; sourceTree = "<group>"; };
@@ -301,6 +303,7 @@
                         isa = PBXGroup;
                         children = (
                                 089F03570EE96BA800C88FE5 /* test_shared_ptr_to_element.cpp */,
+ 089F59D90EF317D30088D651 /* test_containing_ptr.cpp */,
                                 089F03590EE96BEB00C88FE5 /* Jamfile */,
                         );
                         path = utility;
@@ -393,6 +396,7 @@
                                 0826E33A0EA53F4C0090AB4E /* all_of.hpp */,
                                 089F03530EE9615200C88FE5 /* shared_ptr_to_element.hpp */,
                                 08A48FC20EE9D64B002D6374 /* export_symbols.hpp */,
+ 089F59B70EF313E90088D651 /* containing_ptr.hpp */,
                         );
                         path = utility;
                         sourceTree = "<group>";

Modified: sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/my_blueprint_ports.hpp
==============================================================================
--- sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/my_blueprint_ports.hpp (original)
+++ sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/my_blueprint_ports.hpp 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -8,10 +8,23 @@
 
 
 #include <boost/dataflow/blueprint/port_adapter.hpp>
+#include <boost/dataflow/utility/containing_ptr.hpp>
 
 #include "my_blueprint_framework.hpp"
 #include "../generic/my_ports.hpp"
 
+typedef
+ df::blueprint::port_adapter
+ <
+ my_blueprint_framework,
+ df::utility::containing_ptr<my_port_producer>
+ >
+ my_blueprint_port_producer;
 
-typedef df::blueprint::port_adapter<my_blueprint_framework, my_port_producer> my_blueprint_port_producer;
-typedef df::blueprint::port_adapter<my_blueprint_framework, my_port_consumer> my_blueprint_port_consumer;
+typedef
+ df::blueprint::port_adapter
+ <
+ my_blueprint_framework,
+ df::utility::containing_ptr<my_port_consumer>
+ >
+ my_blueprint_port_consumer;

Modified: sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/my_blueprint_static_vector.hpp
==============================================================================
--- sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/my_blueprint_static_vector.hpp (original)
+++ sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/my_blueprint_static_vector.hpp 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -9,7 +9,14 @@
 
 #include "my_blueprint_framework.hpp"
 #include "../generic/my_static_vector.hpp"
+#include <boost/dataflow/utility/containing_ptr.hpp>
 
 #include <boost/dataflow/blueprint/static_vector_adapter.hpp>
 
-typedef df::blueprint::static_vector_adapter<my_blueprint_framework, my_static_vector> my_blueprint_static_vector;
\ No newline at end of file
+typedef
+ df::blueprint::static_vector_adapter
+ <
+ my_blueprint_framework,
+ boost::dataflow::utility::containing_ptr<my_static_vector>
+ >
+ my_blueprint_static_vector;
\ No newline at end of file

Modified: sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/test_factory.cpp
==============================================================================
--- sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/test_factory.cpp (original)
+++ sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/test_factory.cpp 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -36,7 +36,7 @@
 {
     factory_int_type::produced_type *operator()(factory_int_type::framework_context_type &c, int x) const
     {
- return new df::blueprint::port_adapter<my_blueprint_framework, my_port_producer>(c);
+ return new df::blueprint::port_adapter<my_blueprint_framework, df::utility::containing_ptr<my_port_producer> >(c);
     }
 };
 
@@ -46,5 +46,6 @@
     factory.add_entity("my_port_producer_int", constructor_int());
     
     df::blueprint::framework_context<my_blueprint_framework> fo;
- df::blueprint::framework_entity<my_blueprint_framework> *entity = factory["my_port_producer_int"](fo, 1);
+ df::blueprint::framework_entity<my_blueprint_framework> * entity = factory["my_port_producer_int"](fo, 1);
+ entity->type_info();
 }
\ No newline at end of file

Modified: sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/test_framework_entity.cpp
==============================================================================
--- sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/test_framework_entity.cpp (original)
+++ sandbox/dataflow-rewrite/libs/dataflow/test/blueprint/test_framework_entity.cpp 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -9,6 +9,7 @@
 
 #include <boost/dataflow/blueprint/framework_entity.hpp>
 #include <boost/dataflow/blueprint/framework_entity_adapter.hpp>
+#include <boost/dataflow/utility/containing_ptr.hpp>
 
 #include "my_blueprint_framework.hpp"
 #include "../generic/my_ports.hpp"
@@ -25,8 +26,8 @@
     my_blueprint_framework_context fo;
 
     my_port_producer p;
- df::blueprint::framework_entity_adapter<my_blueprint_framework, my_port_producer &> ref_entity(fo, p);
- df::blueprint::framework_entity_adapter<my_blueprint_framework, my_port_producer> composition_entity(fo);
+ df::blueprint::framework_entity_adapter<my_blueprint_framework, my_port_producer *> ref_entity(fo, &p);
+ df::blueprint::framework_entity_adapter<my_blueprint_framework, df::utility::containing_ptr<my_port_producer> > composition_entity(fo);
     
     BOOST_CHECK(ref_entity.type_info() == typeid(p));
     BOOST_CHECK_EQUAL(&ref_entity.entity(), &p);
@@ -37,7 +38,7 @@
     my_port_with_context pwc(context);
     
     // test copy construction
- df::blueprint::framework_entity_adapter<my_blueprint_framework_with_context, my_port_with_context> context_copy_construction(fcc, pwc);
+ df::blueprint::framework_entity_adapter<my_blueprint_framework_with_context, df::utility::containing_ptr<my_port_with_context> > context_copy_construction(fcc, pwc);
     // test copy construction
- df::blueprint::framework_entity_adapter<my_blueprint_framework_with_context, my_port_with_context> context_const_copy_construction(fcc, my_port_with_context(fcc.object()));
+ df::blueprint::framework_entity_adapter<my_blueprint_framework_with_context, df::utility::containing_ptr<my_port_with_context> > context_const_copy_construction(fcc, my_port_with_context(fcc.object()));
 }

Modified: sandbox/dataflow-rewrite/libs/dataflow/test/utility/Jamfile
==============================================================================
--- sandbox/dataflow-rewrite/libs/dataflow/test/utility/Jamfile (original)
+++ sandbox/dataflow-rewrite/libs/dataflow/test/utility/Jamfile 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -12,3 +12,4 @@
     ;
 
 run test_shared_ptr_to_element.cpp ;
+run test_containing_ptr.cpp ;
\ No newline at end of file

Added: sandbox/dataflow-rewrite/libs/dataflow/test/utility/test_containing_ptr.cpp
==============================================================================
--- (empty file)
+++ sandbox/dataflow-rewrite/libs/dataflow/test/utility/test_containing_ptr.cpp 2008-12-12 18:00:28 EST (Fri, 12 Dec 2008)
@@ -0,0 +1,36 @@
+/*=================================---------------------------------------------
+ Copyright 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)
+-----------------------------------------------===============================*/
+
+
+#include <boost/dataflow/utility/containing_ptr.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+struct t
+{
+ void method()
+ {};
+};
+
+BOOST_AUTO_TEST_CASE( test )
+{
+ using namespace boost;
+ using boost::dataflow::utility::containing_ptr;
+
+ containing_ptr<int> five(5);
+
+ BOOST_CHECK((is_same<pointee<containing_ptr<int> >::type, int>::value));
+
+ BOOST_CHECK_EQUAL(*five, 5);
+
+ containing_ptr<t> to;
+ to->method();
+}


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