Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r48760 - in sandbox/dataflow-rewrite: boost/dataflow/generic boost/dataflow/generic/framework_entity boost/dataflow/generic/port libs/dataflow/build/xcodeide/dataflow.xcodeproj libs/dataflow/test/generic
From: stipe_at_[hidden]
Date: 2008-09-12 18:04:30


Author: srajko
Date: 2008-09-12 18:04:29 EDT (Fri, 12 Sep 2008)
New Revision: 48760
URL: http://svn.boost.org/trac/boost/changeset/48760

Log:
added default_framework and framework_entity tests
Added:
   sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity/default_framework.hpp (contents, props changed)
   sandbox/dataflow-rewrite/boost/dataflow/generic/port/
   sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_default_framework.cpp (contents, props changed)
Text files modified:
   sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity.hpp | 3 ++-
   sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity/traits.hpp | 8 ++++----
   sandbox/dataflow-rewrite/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj | 4 ++++
   sandbox/dataflow-rewrite/libs/dataflow/test/generic/Jamfile | 3 ++-
   sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_framework.cpp | 9 ++++++++-
   sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_framework_entity.cpp | 20 +++++++++++++++++---
   6 files changed, 37 insertions(+), 10 deletions(-)

Modified: sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity.hpp
==============================================================================
--- sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity.hpp (original)
+++ sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity.hpp 2008-09-12 18:04:29 EDT (Fri, 12 Sep 2008)
@@ -10,6 +10,7 @@
 #define BOOST__DATAFLOW__GENERIC__FRAMEWORK_ENTITY_HPP
 
 
+#include <boost/dataflow/generic/framework_entity/default_framework.hpp>
 #include <boost/dataflow/generic/framework_entity/traits.hpp>
 #include <boost/dataflow/utility/enable_if_type.hpp>
 
@@ -22,7 +23,7 @@
 }
 
 /// Boolean Metafunction determining whether a type has traits.
-template<typename T, typename Framework=default_framework, typename Enable=detail::enable_guard>
+template<typename T, typename Framework=typename default_framework_of<T>::type, typename Enable=detail::enable_guard>
 struct is_framework_entity : public mpl::false_
 {
 #ifdef DOXYGEN_DOCS_BUILD

Added: sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity/default_framework.hpp
==============================================================================
--- (empty file)
+++ sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity/default_framework.hpp 2008-09-12 18:04:29 EDT (Fri, 12 Sep 2008)
@@ -0,0 +1,92 @@
+/*=================================---------------------------------------------
+ Copyright 2007,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__GENERIC__FRAMEWORK_ENTITY__DEFAULT_FRAMEWORK_HPP
+#define BOOST__DATAFLOW__GENERIC__FRAMEWORK_ENTITY__DEFAULT_FRAMEWORK_HPP
+
+
+#include <boost/dataflow/generic/framework_entity/traits.hpp>
+
+
+namespace boost { namespace dataflow {
+
+/// Metafunction returing the default framework for a type.
+template<typename Entity, typename Enable=void>
+struct default_framework_of
+{
+ /// The Framework of the port.
+ typedef default_framework type;
+};
+
+
+/// INTERNAL ONLY
+template<typename Entity>
+struct default_framework_of<Entity,
+ typename enable_if<
+ mpl::not_<mpl::is_sequence<typename Entity::dataflow_traits> >
+ >::type>
+{
+ /// INTERNAL ONLY
+ BOOST_MPL_ASSERT(( is_traits<typename Entity::dataflow_traits> ));
+ /// INTERNAL ONLY
+ typedef typename Entity::dataflow_traits::framework type;
+};
+
+/// Allows registration of the default framework for all cv-qualified versions of a type.
+template<typename Entity, typename Enable=void>
+struct register_default_framework
+{};
+
+/// INTERNAL ONLY
+template<typename Entity>
+struct default_framework_of<
+ Entity,
+ typename utility::enable_if_type<
+ typename register_default_framework<
+ typename remove_cv<Entity>::type
+ >::type
+ >::type
+>
+{
+ /// INTERNAL ONLY
+ typedef
+ typename register_default_framework<
+ typename remove_cv<Entity>::type
+ >::type type;
+};
+
+} } // namespace boost::dataflow
+
+/// Macro simplifying non-intrusive specification of a type's Traits.
+#define BOOST_DATAFLOW_DEFAULT_FRAMEWORK(Type,Framework) \
+namespace boost { namespace dataflow { \
+template<> \
+struct register_default_framework< \
+ Type \
+ > \
+{ \
+ typedef Framework type; \
+ BOOST_MPL_ASSERT(( is_framework<type> )); \
+}; \
+}}
+
+/// Macro simplifying non-intrusive specification of multiple types'
+/// Traits, using a boost::enable_if condition.
+#define BOOST_DATAFLOW_DEFAULT_FRAMEWORK_ENABLE_IF(Type,Cond,Framework) \
+namespace boost { namespace dataflow { \
+template<typename Type> \
+struct register_default_framework< \
+ Type, \
+ typename boost::enable_if< Cond >::type> \
+{ \
+ typedef Framework type; \
+ BOOST_MPL_ASSERT(( is_framework<Framework> )); \
+}; \
+}}
+
+#endif // BOOST__DATAFLOW__GENERIC__FRAMEWORK_ENTITY__DEFAULT_FRAMEWORK_HPP

Modified: sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity/traits.hpp
==============================================================================
--- sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity/traits.hpp (original)
+++ sandbox/dataflow-rewrite/boost/dataflow/generic/framework_entity/traits.hpp 2008-09-12 18:04:29 EDT (Fri, 12 Sep 2008)
@@ -128,12 +128,12 @@
 } } // namespace boost::dataflow
 
 /// Macro simplifying non-intrusive specification of a type's Traits.
-#define DATAFLOW_TRAITS(Type,Traits) \
+#define BOOST_DATAFLOW_TRAITS(Type,Traits) \
 namespace boost { namespace dataflow { \
 template<> \
 struct register_traits< \
     Type, \
- Traits::framework> \
+ Traits::framework> \
 { \
     typedef Traits type; \
     BOOST_MPL_ASSERT(( is_traits<type> )); \
@@ -142,12 +142,12 @@
 
 /// Macro simplifying non-intrusive specification of multiple types'
 /// Traits, using a boost::enable_if condition.
-#define DATAFLOW_TRAITS_ENABLE_IF(Type,Cond,Traits) \
+#define BOOST_DATAFLOW_TRAITS_ENABLE_IF(Type,Cond,Traits) \
 namespace boost { namespace dataflow { \
 template<typename Type> \
 struct register_traits< \
     Type, \
- typename Traits::framework, \
+ typename Traits::framework, \
     typename boost::enable_if< Cond >::type> \
 { \
     typedef Traits type; \

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-09-12 18:04:29 EDT (Fri, 12 Sep 2008)
@@ -76,6 +76,7 @@
 /* End PBXAggregateTarget section */
 
 /* Begin PBXFileReference section */
+ 08058A0F0E7B0D4600926321 /* default_framework.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = default_framework.hpp; sourceTree = "<group>"; };
                 08A77AB30E4F91AA00B8793E /* Jamroot */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Jamroot; path = ../../../../Jamroot; sourceTree = SOURCE_ROOT; };
                 08A77AB40E4F91AB00B8793E /* LICENSE_1_0.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE_1_0.txt; path = ../../../../LICENSE_1_0.txt; sourceTree = SOURCE_ROOT; };
                 08A77ADC0E4FB06600B8793E /* framework.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = framework.hpp; sourceTree = "<group>"; };
@@ -89,6 +90,7 @@
                 08B8F1BE0E512E72000545B8 /* traits.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = traits.hpp; sourceTree = "<group>"; };
                 08B8F1C00E512F45000545B8 /* test_framework_entity_traits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_framework_entity_traits.cpp; sourceTree = "<group>"; };
                 08B8F1D00E513569000545B8 /* test_framework.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_framework.cpp; sourceTree = "<group>"; };
+ 08DD9D3E0E7B12CE008DC46A /* test_default_framework.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_default_framework.cpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXGroup section */
@@ -157,6 +159,7 @@
                                 08B8F1D00E513569000545B8 /* test_framework.cpp */,
                                 08B8F1B60E512DA3000545B8 /* test_framework_entity.cpp */,
                                 08B8F1C00E512F45000545B8 /* test_framework_entity_traits.cpp */,
+ 08DD9D3E0E7B12CE008DC46A /* test_default_framework.cpp */,
                         );
                         path = generic;
                         sourceTree = "<group>";
@@ -166,6 +169,7 @@
                         children = (
                                 08B8F1BE0E512E72000545B8 /* traits.hpp */,
                                 08B8F1AC0E512CF7000545B8 /* traits_sequence_intrusive_registration.hpp */,
+ 08058A0F0E7B0D4600926321 /* default_framework.hpp */,
                         );
                         path = framework_entity;
                         sourceTree = "<group>";

Modified: sandbox/dataflow-rewrite/libs/dataflow/test/generic/Jamfile
==============================================================================
--- sandbox/dataflow-rewrite/libs/dataflow/test/generic/Jamfile (original)
+++ sandbox/dataflow-rewrite/libs/dataflow/test/generic/Jamfile 2008-09-12 18:04:29 EDT (Fri, 12 Sep 2008)
@@ -9,4 +9,5 @@
 
 run test_framework.cpp ;
 run test_framework_entity.cpp ;
-run test_framework_entity_traits.cpp ;
\ No newline at end of file
+run test_framework_entity_traits.cpp ;
+run test_default_framework.cpp ;

Added: sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_default_framework.cpp
==============================================================================
--- (empty file)
+++ sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_default_framework.cpp 2008-09-12 18:04:29 EDT (Fri, 12 Sep 2008)
@@ -0,0 +1,77 @@
+/*=================================---------------------------------------------
+ Copyright 2007,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/generic/framework_entity/default_framework.hpp>
+
+#include <boost/preprocessor/comma.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+
+namespace df = boost::dataflow;
+
+struct my_framework : public df::framework
+{};
+
+struct no_traits
+{};
+
+typedef df::traits<df::default_framework> default_traits;
+typedef df::traits<my_framework> my_traits;
+
+struct default_entity_intrusive
+{
+ typedef default_traits dataflow_traits;
+};
+
+struct my_entity_intrusive
+{
+ typedef my_traits dataflow_traits;
+};
+
+struct my_entity_nonintrusive
+{
+};
+
+BOOST_DATAFLOW_DEFAULT_FRAMEWORK(my_entity_nonintrusive, my_framework)
+
+struct my_entity_nonintrusive_enabled
+{
+};
+
+BOOST_DATAFLOW_DEFAULT_FRAMEWORK_ENABLE_IF(
+ T,
+ is_same<T BOOST_PP_COMMA() my_entity_nonintrusive_enabled>,
+ my_framework)
+
+
+BOOST_AUTO_TEST_CASE( test )
+{
+ BOOST_CHECK((boost::is_same<
+ df::default_framework_of<no_traits>::type,
+ df::default_framework>::value
+ ));
+ BOOST_CHECK((boost::is_same<
+ df::default_framework_of<default_entity_intrusive>::type,
+ df::default_framework>::value
+ ));
+ BOOST_CHECK((boost::is_same<
+ df::default_framework_of<my_entity_intrusive>::type,
+ my_framework>::value
+ ));
+ BOOST_CHECK((boost::is_same<
+ df::default_framework_of<my_entity_nonintrusive>::type,
+ my_framework>::value
+ ));
+ BOOST_CHECK((boost::is_same<
+ df::default_framework_of<my_entity_nonintrusive_enabled>::type,
+ my_framework>::value
+ ));
+}

Modified: sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_framework.cpp
==============================================================================
--- sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_framework.cpp (original)
+++ sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_framework.cpp 2008-09-12 18:04:29 EDT (Fri, 12 Sep 2008)
@@ -12,11 +12,18 @@
 #define BOOST_TEST_MAIN
 #include <boost/test/unit_test.hpp>
 
-
 namespace df = boost::dataflow;
 
+struct not_framework
+{};
+
+struct my_framework : public df::framework
+{};
+
 BOOST_AUTO_TEST_CASE( test )
 {
+ BOOST_CHECK((df::is_framework<my_framework>::value));
+ BOOST_CHECK((!df::is_framework<not_framework>::value));
 }
 
 

Modified: sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_framework_entity.cpp
==============================================================================
--- sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_framework_entity.cpp (original)
+++ sandbox/dataflow-rewrite/libs/dataflow/test/generic/test_framework_entity.cpp 2008-09-12 18:04:29 EDT (Fri, 12 Sep 2008)
@@ -15,9 +15,18 @@
 
 namespace df = boost::dataflow;
 
-typedef df::traits<df::default_framework> my_traits;
+struct my_framework : public df::framework
+{};
 
-struct framework_entity
+typedef df::traits<df::default_framework> default_traits;
+typedef df::traits<my_framework> my_traits;
+
+struct default_entity
+{
+ typedef default_traits dataflow_traits;
+};
+
+struct my_entity
 {
     typedef my_traits dataflow_traits;
 };
@@ -25,5 +34,10 @@
 BOOST_AUTO_TEST_CASE( test )
 {
     BOOST_CHECK(df::is_traits<my_traits>::value);
- BOOST_CHECK(df::is_framework_entity<framework_entity>::value);
+ BOOST_CHECK((df::is_framework_entity<default_entity, df::default_framework>::value));
+ BOOST_CHECK((df::is_framework_entity<my_entity, my_framework>::value));
+ BOOST_CHECK((!df::is_framework_entity<default_entity, my_framework>::value));
+ BOOST_CHECK((!df::is_framework_entity<my_entity, df::default_framework>::value));
+ BOOST_CHECK(df::is_framework_entity<default_entity>::value);
+ BOOST_CHECK(df::is_framework_entity<my_entity>::value);
 }


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