Boost logo

Boost-Commit :

From: oryol_at_[hidden]
Date: 2007-09-11 22:26:57


Author: jeremypack
Date: 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
New Revision: 39200
URL: http://svn.boost.org/trac/boost/changeset/39200

Log:
API Fixes for new extension interface, plus new reflection interface

Text files modified:
   sandbox/boost/extension/convenience.hpp | 39 ++
   sandbox/boost/extension/extension.hpp | 9
   sandbox/boost/extension/factory_map.hpp | 16
   sandbox/boost/extension/shared_library.hpp | 56 +++
   sandbox/boost/reflection/constructor.hpp | 38 +
   sandbox/boost/reflection/function.hpp | 89 ++---
   sandbox/boost/reflection/instance.hpp | 15
   sandbox/boost/reflection/reflection.hpp | 613 +++------------------------------------
   sandbox/boost/reflection/reflector.hpp | 157 +++++-----
   sandbox/libs/extension/examples/hello_world.cpp | 5
   sandbox/libs/extension/examples/info/im/im_main.cpp | 15
   sandbox/libs/extension/examples/info/im/network_parameters.hpp | 14
   sandbox/libs/extension/examples/info/im/plugins.cpp | 20
   sandbox/libs/extension/examples/info/multilanguage_hello_world.cpp | 31 +
   sandbox/libs/extension/examples/info/multilanguage_main.cpp | 10
   sandbox/libs/extension/examples/info/word_description.hpp | 6
   sandbox/libs/extension/examples/main.cpp | 6
   sandbox/libs/extension/examples/multiple_inheritance/boat.cpp | 4
   sandbox/libs/extension/examples/multiple_inheritance/car.cpp | 4
   sandbox/libs/extension/examples/multiple_inheritance/car_of_the_future.cpp | 28
   sandbox/libs/extension/examples/multiple_inheritance/computer.cpp | 5
   sandbox/libs/extension/examples/multiple_inheritance/flying_car.cpp | 13
   sandbox/libs/extension/examples/multiple_inheritance/main_mi.cpp | 16
   sandbox/libs/extension/examples/multiple_inheritance/plane.cpp | 6
   sandbox/libs/extension/examples/multiple_inheritance/vehicle.cpp | 3
   sandbox/libs/extension/examples/parameters/lots_of_parameters.cpp | 6
   sandbox/libs/extension/examples/parameters/main_lp.cpp | 10
   sandbox/libs/extension/examples/registry/registry_library.cpp | 2
   sandbox/libs/extension/examples/versioning/hello_world_versions.cpp | 5
   sandbox/libs/extension/examples/versioning/main_versions.cpp | 14
   sandbox/libs/extension/examples/versioning/salute.cpp | 5
   sandbox/libs/extension/test/Jamfile.v2 | 21
   sandbox/libs/extension/test/factory_test.cpp | 49 +-
   sandbox/libs/extension/test/fruit.hpp | 11
   sandbox/libs/extension/test/hello_world_test.cpp | 21
   sandbox/libs/extension/test/lib_caching_test.cpp | 42 +-
   sandbox/libs/extension/test/multiple_inheritance_test.cpp | 118 +++---
   sandbox/libs/extension/test/parameters_test.cpp | 13
   sandbox/libs/extension/test/versions_test.cpp | 12
   sandbox/libs/extension/test/zone_test.cpp | 32 +-
   sandbox/libs/reflection/test/Jamfile.v2 | 1
   sandbox/libs/reflection/test/basic_test.cpp | 40 +-
   42 files changed, 627 insertions(+), 993 deletions(-)

Modified: sandbox/boost/extension/convenience.hpp
==============================================================================
--- sandbox/boost/extension/convenience.hpp (original)
+++ sandbox/boost/extension/convenience.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -0,0 +1,39 @@
+/*
+ * Boost.Extension / convenience functions:
+ * for now only one to load a library and register it in the factory
+ * map.
+ *
+ * (C) Copyright Jeremy Pack 2007
+ * 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)
+ *
+ * See http://www.boost.org/ for latest version.
+ */
+
+#ifndef BOOST_EXTENSION_CONVENIENCE_HPP
+#define BOOST_EXTENSION_CONVENIENCE_HPP
+
+#include <boost/extension/factory_map.hpp>
+
+namespace boost{namespace extensions{
+
+inline void load_single_library(factory_map & current_factory_map,
+ const char * library_path,
+ const char * external_function_name) {
+ shared_library lib(library_path);
+ if (!lib.open()) {
+ return;
+ }
+ void (*func)(factory_map &) =
+ lib.get<void, factory_map &>(external_function_name);
+ if (!func) {
+ return;
+ }
+ (*func)(current_factory_map);
+}
+}}
+
+
+
+#endif

Modified: sandbox/boost/extension/extension.hpp
==============================================================================
--- sandbox/boost/extension/extension.hpp (original)
+++ sandbox/boost/extension/extension.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -13,12 +13,5 @@
 #ifndef BOOST_EXTENSION_EXTENSION_HPP
 #define BOOST_EXTENSION_EXTENSION_HPP
 
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
-# define BOOST_EXTENSION_EXPORT_DECL __declspec(dllexport)
-# define BOOST_EXTENSION_IMPORT_DECL __declspec(dllimport)
-#else
-# define BOOST_EXTENSION_EXPORT_DECL
-# define BOOST_EXTENSION_IMPORT_DECL
-#endif
-
+#include <boost/extension/impl/decl.hpp>
 #endif

Modified: sandbox/boost/extension/factory_map.hpp
==============================================================================
--- sandbox/boost/extension/factory_map.hpp (original)
+++ sandbox/boost/extension/factory_map.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -50,12 +50,24 @@
             BOOST_PP_ENUM_PARAMS(N, Param)> > * >(holder); \
 }
 
-
+#define BOOST_EXTENSION_FACTORY_MAP_CONVERT_FUNCTION(Z, N, _) \
+template <class Interface, class Info \
+BOOST_PP_COMMA_IF(N) \
+BOOST_PP_ENUM_PARAMS(N, class Param) > \
+operator std::map<Info, \
+factory<Interface BOOST_PP_COMMA_IF(N) \
+BOOST_PP_ENUM_PARAMS(N, Param)> >() { \
+ return get<Interface, Info BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)>(); \
+}
+
 template <class TypeInfo>
 class basic_factory_map {
 public:
 BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
                 BOOST_EXTENSION_FACTORY_MAP_GET_FUNCTION, _)
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+ BOOST_EXTENSION_FACTORY_MAP_CONVERT_FUNCTION, _)
   ~basic_factory_map() {
     for (typename std::map<TypeInfo, generic_map_holder*>
          ::iterator it =maps_.begin();
@@ -77,5 +89,5 @@
 }}
 
 #undef BOOST_EXTENSION_FACTORY_MAP_GET_FUNCTION
-
+#undef BOOST_EXTENSION_FACTORY_MAP_CONVERT_FUNCTION
 #endif
\ No newline at end of file

Modified: sandbox/boost/extension/shared_library.hpp
==============================================================================
--- sandbox/boost/extension/shared_library.hpp (original)
+++ sandbox/boost/extension/shared_library.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -0,0 +1,56 @@
+/*
+ * Boost.Extension / shared_library:
+ * functions for shared_library loading
+ *
+ * (C) Copyright Jeremy Pack 2007
+ * 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)
+ *
+ * See http://www.boost.org/ for latest version.
+ */
+
+#ifndef BOOST_EXTENSION_SHARED_LIBRARY_HPP
+#define BOOST_EXTENSION_SHARED_LIBRARY_HPP
+#include <string>
+#include <boost/extension/impl/library_impl.hpp>
+#include <boost/extension/common.hpp>
+namespace boost { namespace extensions {
+
+#define BOOST_EXTENSION_SHARED_LIBRARY_GET_FUNCTION(Z, N, _) \
+template <class ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, class Param) > \
+ReturnValue (*get(const char * name))(BOOST_PP_ENUM_PARAMS(N, Param)) { \
+ return reinterpret_cast<ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))> \
+ (get_function(handle_, name)); \
+}
+
+
+class shared_library
+{
+public:
+ bool is_open(){return handle_ != 0;}
+ bool open() {
+ return (handle_ = load_shared_library(location_.c_str())) != 0;
+ }
+ bool close() {
+ return close_shared_library(handle_);
+ }
+ shared_library(const char * location, bool auto_close = false)
+ :location_(location), handle_(0), auto_close_(auto_close) {
+ }
+
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+ BOOST_EXTENSION_SHARED_LIBRARY_GET_FUNCTION, _)
+
+protected:
+ std::string location_;
+ library_handle handle_;
+ bool auto_close_;
+};
+}}
+#endif // BOOST_EXTENSION_SHARED_LIBRARY_HPP
+
+
+
+

Modified: sandbox/boost/reflection/constructor.hpp
==============================================================================
--- sandbox/boost/reflection/constructor.hpp (original)
+++ sandbox/boost/reflection/constructor.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -11,21 +11,29 @@
 #define BOOST_EXTENSION_CONSTRUCTOR_HPP
 #include <boost/reflection/instance.hpp>
 namespace boost {namespace reflections {
-class constructor {
-public:
- constructor(instance (*func)() = 0)
- : func_(func)
- {
- }
- instance call() {
- return (*func_)();
- }
- instance operator()() {
- return call();
- }
- bool valid() {return func_ != 0;}
-private:
- instance (*func_)();
+template <BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_INC(\
+ BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), class Param, void)>
+class constructor;
+
+#define BOOST_REFLECTION_CONSTRUCTOR_CLASS(Z, N, _) \
+template <BOOST_PP_ENUM_PARAMS(N, class Param)> \
+class constructor<BOOST_PP_ENUM_PARAMS(N, Param)> { \
+public: \
+ constructor(instance (*func)(BOOST_PP_ENUM_PARAMS(N, Param)) = 0) \
+ : func_(func) { \
+ } \
+ instance call(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ return (*func_)(BOOST_PP_ENUM_PARAMS(N, p)); \
+ } \
+ instance operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ return (*func_)(BOOST_PP_ENUM_PARAMS(N, p)); \
+ } \
+ bool valid() {return func_ != 0;} \
+ private: \
+ instance (*func_)(BOOST_PP_ENUM_PARAMS(N, Param)); \
 };
+
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_CONSTRUCTOR_CLASS, _)
 }}
 #endif
\ No newline at end of file

Modified: sandbox/boost/reflection/function.hpp
==============================================================================
--- sandbox/boost/reflection/function.hpp (original)
+++ sandbox/boost/reflection/function.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -15,54 +15,47 @@
 namespace boost {namespace reflections {
 
 typedef void (instance::*MemberFunctionPtr)();
-template <class ReturnValue>
-class function {
-public:
- function(ReturnValue (*func)(void *, MemberFunctionPtr) = 0,
- MemberFunctionPtr member_function = 0)
- : func_(func),
- member_function_(member_function) {
- }
- ReturnValue call(instance & inst) {
- return (*func_)(inst.val_, member_function_);
- }
- ReturnValue operator()(instance & inst) {
- return (*func_)(inst.val_, member_function_);
- }
- bool valid() {
- return member_function_ != 0 && func_ != 0;
- }
-private:
- ReturnValue (*func_)(void *, MemberFunctionPtr);
- MemberFunctionPtr member_function_;
+template <class ReturnValue = void
+ BOOST_PP_COMMA_IF(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS)
+ BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_INC
+ (BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), class Param, void)>
+class function;
+
+#define BOOST_REFLECTION_FUNCTION_CLASS(Z, N, _) \
+template <class ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, class Param)> \
+class function<ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)> { \
+public: \
+ function(ReturnValue (*func)(void *, MemberFunctionPtr \
+ BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)) = 0, \
+ MemberFunctionPtr member_function = 0) \
+ : func_(func), \
+ member_function_(member_function) { \
+ } \
+ ReturnValue call(instance & inst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ return (*func_)(inst.val_, member_function_ BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, p)); \
+ } \
+ ReturnValue operator()(instance & inst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ return (*func_)(inst.val_, member_function_ BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, p)); \
+ } \
+ bool valid() { \
+ return member_function_ != 0 && func_ != 0; \
+ } \
+private: \
+ ReturnValue (*func_)(void *, MemberFunctionPtr \
+ BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)); \
+ MemberFunctionPtr member_function_; \
 };
-/*template <class T>
-class generic_function {
- virtual ~generic_function() {}
- virtual void call(void ** params) = 0;
-};
-template <class T, class ReturnValue = void>
-class function : public generic_function<T> {
-public:
- function(ReturnValue (T::*func)())
- : func_(func) {}
- virtual void call(T * obj, void ** params) {
- *static_cast<ReturnValue*>(params[0]) =
- (obj->*func_)();
- }
-private:
- ReturnValue (T::*func_)();
-};
-template <class T>
-class function<T, void> : public generic_function<T> {
-public:
- function(void (T::*func)())
- : func_(func) {}
- virtual void call(T * obj, void ** params) {
- (obj->*func_)();
- }
-private:
- void (T::*func_)();
-}; */
+
+
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_FUNCTION_CLASS, _)
 }}
 #endif
\ No newline at end of file

Modified: sandbox/boost/reflection/instance.hpp
==============================================================================
--- sandbox/boost/reflection/instance.hpp (original)
+++ sandbox/boost/reflection/instance.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -1,11 +1,11 @@
 /*
  * Copyright Jeremy Pack 2007
  * 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)
- *
- * See http://www.boost.org/ for latest version.
- */
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * See http://www.boost.org/ for latest version.
+ */
 
 #ifndef BOOST_EXTENSION_INSTANCE_HPP
 #define BOOST_EXTENSION_INSTANCE_HPP
@@ -38,7 +38,10 @@
     return *this;
   }
 private:
- template <class ReturnValue>
+ template <class ReturnValue
+ BOOST_PP_COMMA_IF(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS)
+ BOOST_PP_ENUM_PARAMS(BOOST_PP_INC
+ (BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), class Param)>
   friend class function;
   mutable void * val_;
   void (*destructor_)(void *);

Modified: sandbox/boost/reflection/reflection.hpp
==============================================================================
--- sandbox/boost/reflection/reflection.hpp (original)
+++ sandbox/boost/reflection/reflection.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -19,7 +19,53 @@
 
 
 namespace boost {namespace reflections {
+#define BOOST_REFLECTION_REFLECTION_GET_CONSTRUCTOR_FUNCTION(Z, N, _) \
+template <class ParamFirst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, class Param)> \
+constructor<ParamFirst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)> get_constructor() { \
+ TypeInfo t = extensions::type_info_handler<TypeInfo, \
+ instance (*)(ParamFirst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param))>::get_class_type(); \
+ typename std::map<TypeInfo, FunctionPtr>::iterator it = \
+ constructors_.find(t); \
+ if (it == constructors_.end()) { \
+ return constructor<ParamFirst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)>(); \
+ } else { \
+ return reinterpret_cast<instance (*)(ParamFirst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param))> \
+ (it->second); \
+ } \
+}
 
+#define BOOST_REFLECTION_REFLECTION_GET_FUNCTION_FUNCTION(Z, N, _) \
+template <class ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, class Param)> \
+function<ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)> get_function(Info info) { \
+ function_info f(extensions::type_info_handler<TypeInfo, \
+ ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))> \
+ ::get_class_type(), info); \
+ typename std::map<function_info, \
+ std::pair<MemberFunctionPtr, \
+ FunctionPtr> >::iterator it = \
+ functions_.find(f); \
+ if (it == functions_.end()) { \
+ return function<ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)>(); \
+ } else { \
+ return function<ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)> \
+ (reinterpret_cast<ReturnValue (*)(void *, MemberFunctionPtr \
+ BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param))> \
+ (it->second.second), it->second.first); \
+ } \
+}
+
+
+
 typedef void (*FunctionPtr)();
 template<class Info, class TypeInfo>
 struct basic_function_info {
@@ -48,34 +94,21 @@
 public:
   template <class Q, class R, class S>
   friend class reflector;
- constructor get_constructor() {
+ BOOST_PP_REPEAT(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS, \
+ BOOST_REFLECTION_REFLECTION_GET_CONSTRUCTOR_FUNCTION, _)
+ constructor<> get_constructor() {
     TypeInfo t = extensions::type_info_handler<TypeInfo,
     instance (*)()>::get_class_type();
     typename std::map<TypeInfo, FunctionPtr>::iterator it =
       constructors_.find(t);
     if (it == constructors_.end()) {
- return constructor();
+ return constructor<>();
     } else {
       return reinterpret_cast<instance (*)()>(it->second);
     }
   }
- template <class ReturnValue>
- function<ReturnValue> get_function(Info info) {
- function_info f(extensions::type_info_handler<TypeInfo,
- ReturnValue (*)()>::get_class_type(), info);
- std::cout << "\nGetting: " << f.type_info_;
- typename std::map<function_info,
- std::pair<MemberFunctionPtr,
- FunctionPtr> >::iterator it =
- functions_.find(f);
- if (it == functions_.end()) {
- return function<ReturnValue>();
- } else {
- return function<ReturnValue>
- (reinterpret_cast<ReturnValue (*)(void *, MemberFunctionPtr)>
- (it->second.second), it->second.first);
- }
- }
+ BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_REFLECTION_GET_FUNCTION_FUNCTION, _)
 private:
   typedef basic_function_info<Info, TypeInfo> function_info;
   std::map<TypeInfo, FunctionPtr> constructors_;
@@ -84,546 +117,4 @@
 };
 typedef basic_reflection<> reflection;
 }}
-
-#if 0
- template<class Info>
- class reflection
- {
- public:
- reflection(Info info) : info_(info) {}
- class generic_method_container
- {
- public:
- template <class ReturnValue, class Param1, class Param2, class Param3,
- class Param4, class Param5, class Param6>
- ReturnValue call(Param1 p1, Param2 p2, Param3 p3, Param4 p4,
- Param5 p5, Param6 p6) {
- ReturnValue val;
- call_virtual(static_cast<void*>(&p1),
- static_cast<void*>(&p2),
- static_cast<void*>(&p3),
- static_cast<void*>(&p4),
- static_cast<void*>(&p5),
- static_cast<void*>(&p6));
- get_return_value(static_cast<void*>(&val));
- return val;
- }
- template <class Param1, class Param2, class Param3,
- class Param4, class Param5, class Param6>
- void call_void(Param1 p1, Param2 p2, Param3 p3, Param4 p4,
- Param5 p5, Param6 p6) {
- call_virtual(static_cast<void*>(&p1),
- static_cast<void*>(&p2),
- static_cast<void*>(&p3),
- static_cast<void*>(&p4),
- static_cast<void*>(&p5),
- static_cast<void*>(&p6));
- }
- template <class ReturnValue, class Param1, class Param2, class Param3,
- class Param4, class Param5>
- ReturnValue call(Param1 p1, Param2 p2, Param3 p3, Param4 p4,
- Param5 p5) {
- ReturnValue val;
- call_virtual(static_cast<void*>(&p1),
- static_cast<void*>(&p2),
- static_cast<void*>(&p3),
- static_cast<void*>(&p4),
- static_cast<void*>(&p5));
- get_return_value(static_cast<void*>(&val));
- return val;
- }
- template <class Param1, class Param2, class Param3,
- class Param4, class Param5>
- void call_void(Param1 p1, Param2 p2, Param3 p3, Param4 p4,
- Param5 p5) {
- call_virtual(static_cast<void*>(&p1),
- static_cast<void*>(&p2),
- static_cast<void*>(&p3),
- static_cast<void*>(&p4),
- static_cast<void*>(&p5));
- }
- template <class ReturnValue, class Param1, class Param2, class Param3,
- class Param4>
- ReturnValue call(Param1 p1, Param2 p2, Param3 p3, Param4 p4) {
- ReturnValue val;
- call_virtual(static_cast<void*>(&p1),
- static_cast<void*>(&p2),
- static_cast<void*>(&p3),
- static_cast<void*>(&p4));
- get_return_value(static_cast<void*>(&val));
- return val;
- }
- template <class Param1, class Param2, class Param3,
- class Param4>
- void call_void(Param1 p1, Param2 p2, Param3 p3, Param4 p4) {
- call_virtual(static_cast<void*>(&p1),
- static_cast<void*>(&p2),
- static_cast<void*>(&p3),
- static_cast<void*>(&p4));
- }
- template <class ReturnValue, class Param1, class Param2, class Param3>
- ReturnValue call(Param1 p1, Param2 p2, Param3 p3) {
- ReturnValue val;
- call_virtual(static_cast<void*>(&p1),
- static_cast<void*>(&p2),
- static_cast<void*>(&p3));
- get_return_value(static_cast<void*>(&val));
- return val;
- }
- template <class Param1, class Param2, class Param3>
- void call_void(Param1 p1, Param2 p2, Param3 p3) {
- call_virtual(static_cast<void*>(&p1),
- static_cast<void*>(&p2),
- static_cast<void*>(&p3));
- }
- template <class ReturnValue, class Param1, class Param2>
- ReturnValue call(Param1 p1, Param2 p2) {
- ReturnValue val;
- call_virtual(static_cast<void*>(&p1),
- static_cast<void*>(&p2));
- get_return_value(static_cast<void*>(&val));
- return val;
- }
- template <class Param1, class Param2>
- void call_void(Param1 p1, Param2 p2) {
- call_virtual(static_cast<void*>(&p1),
- static_cast<void*>(&p2));
- }
- template <class ReturnValue, class Param1>
- ReturnValue call(Param1 p1) {
- ReturnValue val;
- call_virtual(static_cast<void*>(&p1));
- get_return_value(static_cast<void*>(&val));
- return val;
- }
- template <class Param1>
- void call_void(Param1 p1) {
- call_virtual(static_cast<void*>(&p1));
- }
- template <class ReturnValue>
- ReturnValue call() {
- ReturnValue val;
- call_virtual();
- get_return_value(static_cast<void*>(&val));
- return val;
- }
- void call_void() {
- call_virtual();
- }
-
- virtual ~generic_method_container(){}
- protected:
- virtual void get_return_value(void * val) = 0;
- virtual void call_virtual(void * p1 = 0, void * p2 = 0, void * p3 = 0,
- void * p4 = 0, void * p5 = 0, void * p6 = 0)
- = 0;
- };
- template <class Object, class ReturnValue, class Param1 = void,
- class Param2 = void, class Param3 = void,
- class Param4 = void, class Param5 = void,
- class Param6 = void>
- class method_container : public virtual_method_container {
- public:
- virtual void get_return_value(void * val) {
- *static_cast<ReturnValue*>(val) = return_value_;
- }
- virtual void call_virtual(void * p1 = 0, void * p2 = 0,
- void * p3 = 0, void * p4 = 0,
- void * p5 = 0, void * p6 = 0) {
-
- }
- private:
- ReturnValue
- ReturnValue return_value_;
- };
- /*template <class MethodID, class MethodReturnValue,
- class MethodParam0 = void, class MethodParamID0 = void,
- class MethodParam1 = void, class MethodParamID1 = void>*/
-
- /*class method_container
- : public std::list<method_info<Implementation, MethodID,
- MethodReturnValue,
- MethodParam0, MethodParamID0,
- MethodParam1, MethodParamID1> >,
- public generic_method_container
- {
- public:
- method_container() {}
- virtual ~method_container(){}
- };*/
-
-
- typedef std::list<generic_method_container *> MethodList;
- MethodList methods_;
-
-#ifdef BOOST_EXTENSION_USE_PP
-
-
-#ifndef BOOST_EXTENSION_REFLECTION_PARAMS
-#define BOOST_EXTENSION_REFLECTION_PARAMS(z, n, dummy) \
- BOOST_PP_CAT(MethodParam,n),BOOST_PP_CAT(MethodParamID,n)
-#endif
-
-#ifndef BOOST_EXTENSION_REFLECTION_CLASS_PARAMS
-#define BOOST_EXTENSION_REFLECTION_CLASS_PARAMS(z, n, dummy) \
- BOOST_PP_CAT(class MethodParam,n),BOOST_PP_CAT(class MethodParamID,n)
-#endif
-
-#define BOOST_EXTENSION_REFLECTION_FIND_METHOD(Z, N, _) \
-template<class MethodID, class MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_CLASS_PARAMS, dummy) > \
-typename reflection::MethodList::iterator find_method(MethodID id) \
-{ \
- typename MethodList::iterator it = methods_.begin(); \
-\
- for(; it != methods_.end(); ++it) { \
- method_container<MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) \
- > *mc = \
- dynamic_cast< method_container<MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) \
- > * >(*it); \
- if(mc == NULL) { \
- continue; \
- } \
-\
- if(mc->begin()->get_id() == id) { \
- return it; \
- } \
- } \
- return methods_.end(); \
-}
-/**/
-
-
-#define BOOST_EXTENSION_REFLECTION_GET_METHOD(Z, N, _) \
-template<class MethodID, class MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_CLASS_PARAMS, dummy) > \
-std::list<method_info<Implementation, MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > > & \
-get(MethodID id) \
-{ \
- typename MethodList::iterator it = \
- find_method<MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > (id); \
-\
- if(it == methods_.end()) { \
- method_container<MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > \
- * ret = new method_container<MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > \
- (); \
- methods_.push_back(ret); \
- return *ret; \
- } else { \
- return static_cast<method_container<MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > \
- &> (*(*it)); \
- } \
-}
-/**/
-
-
-#define BOOST_EXTENSION_REFLECTION_ADD_METHOD(Z, N, _) \
-template<class MethodID, class MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_CLASS_PARAMS, dummy) > \
-void add( BOOST_PP_CAT(boost::function, BOOST_PP_ADD(N,1) ) \
- <MethodReturnValue, Implementation * \
- BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, MethodParam) > \
- method, MethodID method_id BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_BINARY_PARAMS(N, MethodParamID, method_param_id) ) \
-{ \
- typedef std::list<method_info<Implementation, MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > > \
- ListType; \
-\
- ListType & s = this->get<MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > \
- (method_id); \
-\
- method_info<Implementation, MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > \
- m(method_id, method); \
- s.push_back(m); \
-}
-/**/
-
-#define BOOST_EXTENSION_REFLECTION_CALL_METHOD(Z, N, _) \
-template<class MethodID, class MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_CLASS_PARAMS, dummy) > \
-MethodReturnValue call(Implementation *imp_ptr, MethodID method_id \
-BOOST_PP_COMMA_IF(N) \
-BOOST_PP_ENUM_BINARY_PARAMS(N, MethodParam, p) ) \
-{ \
- typename MethodList::iterator it = find_method<MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > \
- (method_id); \
-\
- method_container<MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > \
- &s = \
- static_cast<method_container<MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > \
- &>(*(*it)); \
-\
- if(s.begin() == s.end()) { \
- std::cerr << "Not Found: " << method_id << std::endl; \
- std::exit(-1); \
- } \
-\
- method_info<Implementation, MethodID, MethodReturnValue \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM(N, BOOST_EXTENSION_REFLECTION_PARAMS, dummy) > \
- mi = *(s.begin()); \
-\
- return mi.call(imp_ptr BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, p)); \
-}
-/**/
-
-
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_REFLECTION_FIND_METHOD, _)
-
-
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_REFLECTION_GET_METHOD, _)
-
-
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_REFLECTION_ADD_METHOD, _)
-
-
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_REFLECTION_CALL_METHOD, _)
-
-
-#undef BOOST_EXTENSION_REFLECTION_FIND_METHOD
-#undef BOOST_EXTENSION_REFLECTION_GET_METHOD
-#undef BOOST_EXTENSION_REFLECTION_ADD_METHOD
-#undef BOOST_EXTENSION_REFLECTION_CALL_METHOD
-
-#else
- template<class MethodID, class MethodReturnValue,
- class MethodParam1, class MethodParam1ID>
- typename reflection::MethodList::iterator find_method(MethodID id)
- {
- typename MethodList::iterator it = methods_.begin();
-
- for(; it != methods_.end(); ++it) {
- method_container<MethodID, MethodReturnValue,
- MethodParam1, MethodParam1ID> *mc =
- dynamic_cast< method_container<MethodID, MethodReturnValue,
- MethodParam1, MethodParam1ID> *>(*it);
-
- if(mc == NULL) {
- // if the cast failed it means that this element of the list
- // it isn't of the expected type, so we skip it.
- continue;
- }
-
- // now we check if the id is correct (knowing that the parameters
- // types are correct)
- if(mc->begin()->get_id() == id) {
- return it;
- }
- }
- return methods_.end();
- }
-
-
- template<class MethodID, class MethodReturnValue>
- typename reflection::MethodList::iterator find_method(MethodID id)
- {
- typename MethodList::iterator it = methods_.begin();
-
- for(; it != methods_.end(); ++it) {
- method_container<MethodID, MethodReturnValue> *mc =
- dynamic_cast< method_container<MethodID,
- MethodReturnValue> *>(*it);
-
- if(mc == NULL) {
- // if the cast failed it means that this element of the list
- // it isn't of the expected type, so we skip it.
- continue;
- }
-
- // now we check if the id is correct (knowing that the parameters
- // types are correct)
- if(mc->begin()->get_id() == id) {
- return it;
- }
- }
-
- return methods_.end();
- }
-
-
-
-
- template<class MethodID, class MethodReturnValue>
- std::list<method_info<Implementation, MethodID, MethodReturnValue> > &
- get(MethodID id)
- {
- typename MethodList::iterator it =
- find_method<MethodID, MethodReturnValue>(id);
-
- if(it == methods_.end()) {
- // FIXME: free
- method_container<MethodID, MethodReturnValue> * ret = new
- method_container<MethodID, MethodReturnValue>();
-
- methods_.push_back(ret);
- return *ret;
- } else {
- // Change to dynamic if this fails
- return static_cast<method_container<MethodID, MethodReturnValue> &>
- (*(*it));
- }
- }
-
-
- template<class MethodID, class MethodReturnValue,
- class MethodParam1, class MethodParam1ID>
- std::list<method_info<Implementation, MethodID,
- MethodReturnValue, MethodParam1, MethodParam1ID> > &
- get(MethodID id)
- {
- typename MethodList::iterator it =
- find_method<MethodID, MethodReturnValue,
- MethodParam1, MethodParam1ID>(id);
-
- if(it == methods_.end()) {
- // FIXME: free
- method_container<MethodID, MethodReturnValue,
- MethodParam1, MethodParam1ID> * ret = new
- method_container<MethodID, MethodReturnValue,
- MethodParam1, MethodParam1ID>();
-
- methods_.push_back(ret);
- return *ret;
- } else {
- // Change to dynamic if this fails
- return static_cast<method_container<MethodID, MethodReturnValue,
- MethodParam1, MethodParam1ID> &> (*(*it));
- }
- }
-
-
- template<class MethodID, class MethodReturnValue, class MethodParam1,
- class MethodParam1ID>
- void add(boost::function2<MethodReturnValue, Implementation *,
- MethodParam1> method, MethodID method_id,
- MethodParam1ID method_param1_id)
- {
- typedef std::list<method_info<Implementation, MethodID,
- MethodReturnValue,
- MethodParam1, MethodParam1ID> > ListType;
-
- ListType & s = this->get<MethodID, MethodReturnValue, MethodParam1,
- MethodParam1ID>(method_id);
-
- method_info<Implementation, MethodID, MethodReturnValue,
- MethodParam1, MethodParam1ID> m(method_id, method);
- s.push_back(m);
- }
-
-
- template<class MethodID, class MethodReturnValue>
- void add(boost::function1<MethodReturnValue, Implementation *> method,
- MethodID method_id)
- {
- typedef std::list<method_info<Implementation, MethodID,
- MethodReturnValue> > ListType;
-
- ListType & s = this->get<MethodID, MethodReturnValue>(method_id);
-
- method_info<Implementation, MethodID, MethodReturnValue> m(method_id,
- method);
- s.push_back(m);
- }
-
-
- template<class MethodID, class MethodReturnValue, class MethodParam1,
- class MethodParam1ID>
- MethodReturnValue call(Implementation *imp_ptr, MethodID method_id,
- MethodParam1 p1)
- {
- typename MethodList::iterator it = find_method<MethodID,
- MethodReturnValue, MethodParam1, MethodParam1ID>(method_id);
-
- method_container<MethodID, MethodReturnValue, MethodParam1,
- MethodParam1ID> &s =
- static_cast<method_container<MethodID, MethodReturnValue,
- MethodParam1, MethodParam1ID> &>(*(*it));
-
- // FIXME: see if it is useful having a list here instead of the
- // plain method_info.
- if(s.begin() == s.end()) {
- std::cerr << "Not Found: " << method_id << std::endl;
- std::exit(-1);
- }
- method_info<Implementation, MethodID, MethodReturnValue, MethodParam1,
- MethodParam1ID> mi = *(s.begin());
-
- return mi.call(imp_ptr, p1);
- }
-
-
- template<class MethodID, class MethodReturnValue>
- MethodReturnValue call(Implementation *imp_ptr, MethodID method_id)
- {
- typename MethodList::iterator it = find_method<MethodID,
- MethodReturnValue>(method_id);
-
- method_container<MethodID, MethodReturnValue> &s =
- static_cast<method_container<MethodID, MethodReturnValue> &>(*(*it));
-
- // FIXME: see if it is useful having a list here instead of the
- // plain method_info.
- if(s.begin() == s.end()) {
- std::cerr << "Not Found: " << method_id << std::endl;
- std::exit(-1);
- }
- method_info<Implementation, MethodID, MethodReturnValue> mi =
- *(s.begin());
-
- return mi.call(imp_ptr);
- }
-#endif // BOOST_EXTENSION_USE_PP
-
- // FIXME: boost.any return value
- template<class MethodID>
- void call(MethodID method_id, const parameter_map &pm) const
- {
- // find the corresponding method
- // iterate each parameter and search for it in the parameter map
- }
-
- Info &get_info(void) { return info_; }
-
- private:
- Info info_;
- };
-
- } // extension
-} // boost
-#endif
 #endif // BOOST_EXTENSION_REFLECTION_HPP

Modified: sandbox/boost/reflection/reflector.hpp
==============================================================================
--- sandbox/boost/reflection/reflector.hpp (original)
+++ sandbox/boost/reflection/reflector.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -10,26 +10,76 @@
 #ifndef BOOST_EXTENSION_REFLECTOR_HPP
 #define BOOST_EXTENSION_REFLECTOR_HPP
 
+#include <boost/extension/common.hpp>
 #include <boost/reflection/factory.hpp>
 #include <boost/reflection/function.hpp>
 #include <boost/reflection/constructor.hpp>
 #include <boost/reflection/instance.hpp>
 #include <boost/reflection/reflection.hpp>
-namespace boost {namespace reflections {
-
 
+namespace boost {namespace reflections {
   
-/* template <class Info = std::string,
- class TypeInfo = extensions::default_type_info>
- class generic_reflector
-{
-public:
- typedef basic_function_info<Info, TypeInfo> function_info;
- virtual ~generic_reflector() {}
-
-protected:
-
-};*/
+#define BOOST_REFLECTION_REFLECTOR_REFLECT_CONSTRUCTOR_FUNCTION(Z, N, _) \
+ template <class ParamFirst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, class Param)> \
+void reflect_constructor() { \
+ add_constructor<ParamFirst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)>(&construct); \
+}
+#define BOOST_REFLECTION_REFLECTOR_REFLECT_FUNCTION(Z, N, _) \
+template <class ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, class Param)> \
+void reflect(ReturnValue (T::*func)(BOOST_PP_ENUM_PARAMS(N, Param)), \
+ Info info) { \
+ function_info f(extensions::type_info_handler<TypeInfo, \
+ ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, Param))> \
+ ::get_class_type(), info); \
+ ReturnValue (*f2)(void *, MemberFunctionPtr BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)) = \
+ &call_member<ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)>; \
+ std::pair<MemberFunctionPtr, FunctionPtr> \
+ p(reinterpret_cast<MemberFunctionPtr>(func), \
+ reinterpret_cast<FunctionPtr>(f2)); \
+ std::pair<function_info, std::pair<MemberFunctionPtr, FunctionPtr> > \
+ p2(f, p); \
+ reflection_->functions_.insert(p2); \
+}
+#define BOOST_REFLECTION_REFLECTOR_ADD_CONSTRUCTOR_FUNCTION(Z, N, _) \
+template <class ParamFirst BOOST_PP_COMMA_IF(N) \
+BOOST_PP_ENUM_PARAMS(N, class Param)> \
+void add_constructor(instance (*func)(ParamFirst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param))) { \
+ reflection_->constructors_.insert(std::make_pair<TypeInfo, FunctionPtr>( \
+ extensions::type_info_handler \
+ <TypeInfo, instance (*)(ParamFirst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param))> \
+ ::get_class_type(), \
+ reinterpret_cast<FunctionPtr>(func))); \
+}
+#define BOOST_REFLECTION_REFLECTOR_CONSTRUCT_FUNCTION(Z, N, _) \
+template <class ParamFirst BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, class Param)> \
+static instance construct(ParamFirst pf BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ return instance(static_cast<void*>(new T(pf BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, p))), \
+ &destruct); \
+}
+#define BOOST_REFLECTION_REFLECTOR_CALL_MEMBER_FUNCTION(Z, N, _) \
+template <class ReturnValue BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, class Param)> \
+static ReturnValue call_member(void * val, \
+ MemberFunctionPtr member_function \
+ BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ T * actual = static_cast<T*>(val); \
+ ReturnValue (T::*func)(BOOST_PP_ENUM_PARAMS(N, Param)) = \
+ reinterpret_cast<ReturnValue (T::*)(BOOST_PP_ENUM_PARAMS(N, Param))> \
+ (member_function); \
+ return (actual->*func)(BOOST_PP_ENUM_PARAMS(N, p)); \
+}
+
 template <class T, class Info = std::string,
           class TypeInfo = extensions::default_type_info>
 class reflector
@@ -44,7 +94,9 @@
   void reflect_constructor() {
     add_constructor(&construct);
   }
- template <class ReturnValue>
+ BOOST_PP_REPEAT(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS, \
+ BOOST_REFLECTION_REFLECTOR_REFLECT_CONSTRUCTOR_FUNCTION, _)
+ /* template <class ReturnValue>
   void reflect(ReturnValue (T::*func)(), Info info) {
     function_info f(extensions::type_info_handler<TypeInfo,
                     ReturnValue (*)()>::get_class_type(), info);
@@ -55,90 +107,37 @@
     std::pair<function_info, std::pair<MemberFunctionPtr, FunctionPtr> >
       p2(f, p);
     reflection_->functions_.insert(p2);
- }
+ }*/
+ BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_REFLECTOR_REFLECT_FUNCTION, _)
 private:
   void add_constructor(instance (*func)()) {
     reflection_->constructors_.insert(std::make_pair<TypeInfo, FunctionPtr>(
       extensions::type_info_handler<TypeInfo, instance (*)()>::get_class_type(),
       reinterpret_cast<FunctionPtr>(func)));
   }
+ BOOST_PP_REPEAT(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS, \
+ BOOST_REFLECTION_REFLECTOR_ADD_CONSTRUCTOR_FUNCTION, _)
   static instance construct() {
     return instance(static_cast<void*>(new T()), &destruct);
   }
- template <class ReturnValue>
+ BOOST_PP_REPEAT(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS, \
+ BOOST_REFLECTION_REFLECTOR_CONSTRUCT_FUNCTION, _)
+ /* template <class ReturnValue>
   static ReturnValue call_member(void * val,
                                  MemberFunctionPtr member_function) {
     T * actual = static_cast<T*>(val);
     ReturnValue (T::*func)() =
       reinterpret_cast<ReturnValue (T::*)()>(member_function);
     return (actual->*func)();
- }
+ }*/
+ BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+ BOOST_REFLECTION_REFLECTOR_CALL_MEMBER_FUNCTION, _)
   static void destruct(void * val) {
     delete static_cast<T*>(val);
   }
   basic_reflection<Info, TypeInfo> * reflection_;
 };
- /*
-template <class TypeInfo, class Info>
-class function_info
-{
-public:
- TypeInfo type_info_;
- Info info_;
- bool operator<(function_info & second) {
- return type_info_ < second.type_info_ ||
- (type_info_ == second.type_info_ &&
- info_ < second.type_info_);
- }
-};
-template <class Info = std::string,
- class TypeInfo = extensions::default_type_info>
-class generic_reflector
-{
-public:
-
-};
-template <class T, class Info = std::string,
- class TypeInfo = extensions::default_type_info>
-class reflector : public generic_reflector<Info, TypeInfo>
-{
-public:
- void reflect_constructor() {
- constructors_.insert(std::pair<TypeInfo, generic_constructor*>
- (type_info_handler::get_class_type<TypeInfo, constructor>,
- new constructor()));
- }
- template <class ReturnValue>
- void reflect(ReturnValue (T::*func)(), Info info) {
- functions_.insert(std::pair<std::pair<TypeInfo, Info>, generic_function*>
- (std::pair<TypeInfo, Info>
- (type_info_handler::get_class_type<function<ReturnValue> >, info),
- (new function<ReturnValue>(func))));
- }
- ~reflector() {
- for (ConstructorIterator it = contructors_.begin();
- it != constructors_.end(); ++it) {
- delete it->second;
- }
- for (FactoryIterator it = factories_.begin();
- it != factories_.end(); ++it) {
- delete it->second;
- }
- for (FunctionIterator it = functions_.begin();
- it != functions_.end(); ++it) {
- delete it->second;
- }
- }
-private:
- typedef std::map<TypeInfo, generic_constructor<T>*>::iterator
- ConstructorIterator;
- typedef std::map<function_info<TypeInfo, Info>,
- generic_constructor<T>*>::iterator FactoryIterator;
- typedef std::map<function_info<TypeInfo, Info>,
- generic_function<T>*>::iterator FunctionIterator;
- std::map<TypeInfo, generic_constructor<T>*> constructors_;
- std::map<function_info<TypeInfo, Info>, generic_constructor<T>*> factories_;
- std::map<function_info<TypeInfo, Info>, generic_function<T>*> functions_;
-};*/
+#undef BOOST_REFLECTION_REFLECTOR_REFLECT_CONSTRUCTOR_FUNCTION
 }}
 #endif
\ No newline at end of file

Modified: sandbox/libs/extension/examples/hello_world.cpp
==============================================================================
--- sandbox/libs/extension/examples/hello_world.cpp (original)
+++ sandbox/libs/extension/examples/hello_world.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -10,6 +10,7 @@
  */
 
 #include "word.hpp"
+#include <boost/extension/extension.hpp>
 #include <boost/extension/factory_map.hpp>
 
 class world : public word
@@ -26,6 +27,6 @@
 void BOOST_EXTENSION_EXPORT_DECL
 extension_export_word(boost::extensions::factory_map & fm)
 {
- fm.add<hello, word, int>(1);
- fm.add<world, word, int>(2);
+ fm.get<word, int>()[1].set<hello>();
+ fm.get<word, int>()[2].set<world>();
 }

Modified: sandbox/libs/extension/examples/info/im/im_main.cpp
==============================================================================
--- sandbox/libs/extension/examples/info/im/im_main.cpp (original)
+++ sandbox/libs/extension/examples/info/im/im_main.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -34,7 +34,7 @@
                       "extension_export_plugins");
 
   // get a reference to the list of constructors for protocols
- std::list< factory<protocol, boost::shared_ptr<network_parameters> > > &
+ std::map<boost::shared_ptr<network_parameters>, factory<protocol> > &
     factory_list = fm.get<protocol, boost::shared_ptr<network_parameters> >();
 
   if (factory_list.size() < 2) {
@@ -42,20 +42,19 @@
     return 1;
   }
 
- std::list<factory< protocol,
- boost::shared_ptr<network_parameters> > >::iterator current_plugin =
- factory_list.begin();
+ std::map<boost::shared_ptr<network_parameters>, factory<protocol> >
+ ::iterator current_plugin = factory_list.begin();
 
   // MSN plugin
- std::auto_ptr<protocol> MSN_ptr(current_plugin->create());
+ std::auto_ptr<protocol> MSN_ptr(current_plugin->second.create());
   boost::shared_ptr<network_parameters> msn_parameters =
- current_plugin->get_info();
+ current_plugin->first;
   current_plugin++;
 
   // Jabber plugin
- std::auto_ptr<protocol> Jabber_ptr(current_plugin->create());
+ std::auto_ptr<protocol> Jabber_ptr(current_plugin->second.create());
   boost::shared_ptr<network_parameters> jabber_parameters =
- current_plugin->get_info();
+ current_plugin->first;
 
   // server
   std::cout << "MSN hostname: " << msn_parameters->hostname() << std::endl;

Modified: sandbox/libs/extension/examples/info/im/network_parameters.hpp
==============================================================================
--- sandbox/libs/extension/examples/info/im/network_parameters.hpp (original)
+++ sandbox/libs/extension/examples/info/im/network_parameters.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -16,9 +16,9 @@
 class network_parameters
 {
  public:
- virtual std::string hostname(void) = 0;
- virtual std::string port(void) = 0;
- virtual void set_http_mode(void)= 0;
+ virtual const char * hostname(void) const = 0;
+ virtual const char * port(void) const = 0;
+ virtual void set_http_mode(void) = 0;
 
   virtual ~network_parameters(void) {};
 };
@@ -28,8 +28,8 @@
 class MSN_network_parameters : public network_parameters
 {
  public:
- virtual std::string hostname(void) { return "msn.messenger.com"; }
- virtual std::string port(void) { return "1863"; }
+ virtual const char * hostname(void) const { return "msn.messenger.com"; }
+ virtual const char * port(void) const { return "1863"; }
 
   virtual void set_http_mode(void) {
     std::cout << "http mode set" << std::endl;
@@ -44,8 +44,8 @@
 class Jabber_network_parameters : public network_parameters
 {
  public:
- virtual std::string hostname(void) { return "jabber.org"; }
- virtual std::string port(void) { return "7063"; }
+ virtual const char * hostname(void) const { return "jabber.org"; }
+ virtual const char * port(void) const { return "7063"; }
 
   virtual void set_http_mode(void) {
     std::cout << "http mode not supported" << std::endl;

Modified: sandbox/libs/extension/examples/info/im/plugins.cpp
==============================================================================
--- sandbox/libs/extension/examples/info/im/plugins.cpp (original)
+++ sandbox/libs/extension/examples/info/im/plugins.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -9,7 +9,7 @@
  * See http://www.boost.org/ for latest version.
  */
 
-
+#include <boost/extension/extension.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/extension/factory_map.hpp>
 
@@ -60,13 +60,21 @@
         virtual ~Jabber(void) {}
 };
 
-
+inline bool operator<(const boost::shared_ptr<network_parameters> & first,
+ const boost::shared_ptr<network_parameters> & second) {
+ int comp = strcmp(first->hostname(), second->hostname());
+ if (!comp) {
+ return strcmp(first->port(), second->port()) < 0;
+ }
+ else return comp < 0;
+}
 
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export_plugins(boost::extensions::factory_map & fm)
 {
- fm.add< MSN, protocol, boost::shared_ptr<network_parameters> >
- (boost::shared_ptr<network_parameters>(new MSN_network_parameters));
- fm.add< Jabber, protocol, boost::shared_ptr<network_parameters> >
- (boost::shared_ptr<network_parameters>(new Jabber_network_parameters));
+ fm.get<protocol, boost::shared_ptr<network_parameters> >()
+ [boost::shared_ptr<network_parameters>(new MSN_network_parameters)].set<MSN>();
+ fm.get<protocol, boost::shared_ptr<network_parameters> >()
+ [boost::shared_ptr<network_parameters>(new Jabber_network_parameters)]
+ .set<Jabber>();
 }

Modified: sandbox/libs/extension/examples/info/multilanguage_hello_world.cpp
==============================================================================
--- sandbox/libs/extension/examples/info/multilanguage_hello_world.cpp (original)
+++ sandbox/libs/extension/examples/info/multilanguage_hello_world.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -8,7 +8,7 @@
  *
  * See http://www.boost.org/ for latest version.
  */
-
+#include <boost/extension/extension.hpp>
 #include "word_description.hpp"
 #include <boost/extension/factory_map.hpp>
 
@@ -66,16 +66,21 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export_multilanguage_word(boost::extensions::factory_map & fm)
 {
- fm.add<hola, word, word_description>(word_description("spanish", "hello"));
- fm.add<mundo, word, word_description>(word_description("spanish", "world!"));
-
- fm.add<bonjour, word, word_description>(word_description("french", "hello"));
- fm.add<monde, word, word_description>(word_description("french", "world!"));
-
- fm.add<buonasera, word, word_description>(word_description("italian",
- "hello"));
- fm.add<mondo, word, word_description>(word_description("italian", "world!"));
-
- fm.add<hello, word, word_description>(word_description("english", "hello"));
- fm.add<world, word, word_description>(word_description("english", "world!"));
+ fm.get<word, word_description>()[word_description("spanish", "hello")]
+ .set<hola>();
+ fm.get<word, word_description>()[word_description("spanish", "world!")]
+ .set<mundo>();
+
+ fm.get<word, word_description>()[word_description("french", "hello")]
+ .set<bonjour>();
+ fm.get<word, word_description>()[word_description("french", "world!")]
+ .set<monde>();
+ fm.get<word, word_description>()[word_description("italian", "hello")]
+ .set<buonasera>();
+ fm.get<word, word_description>()[word_description("italian", "world!")]
+ .set<mondo>();
+ fm.get<word, word_description>()[word_description("english", "hello")]
+ .set<hello>();
+ fm.get<word, word_description>()[word_description("english", "world!")]
+ .set<world>();
 }

Modified: sandbox/libs/extension/examples/info/multilanguage_main.cpp
==============================================================================
--- sandbox/libs/extension/examples/info/multilanguage_main.cpp (original)
+++ sandbox/libs/extension/examples/info/multilanguage_main.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -28,7 +28,7 @@
   load_single_library(fm, "libMultilanguageHelloWorld.extension",
                       "extension_export_multilanguage_word");
   // Get a reference to the list of constructors for words.
- std::list<factory<word, word_description> > & factory_list =
+ std::map<word_description, factory<word> > & factory_list =
     fm.get<word, word_description>();
   
   if (factory_list.size() < 4+4) {
@@ -37,17 +37,17 @@
     return 1;
   }
 
- for (std::list<factory<word, word_description> >::iterator current_word =
+ for (std::map<word_description, factory<word> >::iterator current_word =
          factory_list.begin(); current_word != factory_list.end();
        ++current_word) {
       // Using auto_ptr to avoid needing delete. Using smart_ptrs
       // is recommended.
       // Note that this has a zero argument constructor - currently
       // constructors with up to six arguments can be used.
- std::auto_ptr<word> word_ptr(current_word->create());
+ std::auto_ptr<word> word_ptr(current_word->second.create());
       std::cout << word_ptr->get_val() << " is "
- << current_word->get_info().english_translation
- << " in " << current_word->get_info().language
+ << current_word->first.english_translation
+ << " in " << current_word->first.language
                 << std::endl;
   }
   std::cout << std::endl;

Modified: sandbox/libs/extension/examples/info/word_description.hpp
==============================================================================
--- sandbox/libs/extension/examples/info/word_description.hpp (original)
+++ sandbox/libs/extension/examples/info/word_description.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -21,3 +21,9 @@
   word_description(std::string language, std::string english_translation)
     : language(language), english_translation(english_translation) {}
 };
+inline bool operator<(const word_description & first,
+ const word_description & second) {
+ return first.language < second.language ||
+ (first.language == second.language &&
+ first.english_translation < second.english_translation);
+}

Modified: sandbox/libs/extension/examples/main.cpp
==============================================================================
--- sandbox/libs/extension/examples/main.cpp (original)
+++ sandbox/libs/extension/examples/main.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -25,10 +25,10 @@
   load_single_library(fm, "libHelloWorldLib.extension",
                       "extension_export_word");
   // Get a reference to the list of constructors for words.
- std::list<factory<word, int> > & factory_list = fm.get<word, int>();
+ std::map<int, factory<word> > & factory_list = fm.get<word, int>();
   if (factory_list.size() < 2)
     std::cout << "Error - the classes were not found.";
- for (std::list<factory<word, int> >::iterator current_word =
+ for (std::map<int, factory<word> >::iterator current_word =
          factory_list.begin(); current_word != factory_list.end();
        ++current_word)
   {
@@ -36,7 +36,7 @@
     // recommended.
     // Note that this has a zero argument constructor - currently constructors
     // with up to six arguments can be used.
- std::auto_ptr<word> word_ptr(current_word->create());
+ std::auto_ptr<word> word_ptr(current_word->second.create());
     std::cout << word_ptr->get_val() << " ";
   }
   std::cout << "\n";

Modified: sandbox/libs/extension/examples/multiple_inheritance/boat.cpp
==============================================================================
--- sandbox/libs/extension/examples/multiple_inheritance/boat.cpp (original)
+++ sandbox/libs/extension/examples/multiple_inheritance/boat.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -33,6 +33,6 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export(boost::extensions::factory_map & z)
 {
- z.add<boat, vehicle, std::string>("A boat exported as a vehicle");
- z.add<boat, boat, std::string>("A boat exported as a boat");
+ z.get<vehicle, std::string>()["A boat exported as a vehicle"].set<boat>();
+ z.get<boat, std::string>()["A boat exported as a boat"].set<boat>();
 }

Modified: sandbox/libs/extension/examples/multiple_inheritance/car.cpp
==============================================================================
--- sandbox/libs/extension/examples/multiple_inheritance/car.cpp (original)
+++ sandbox/libs/extension/examples/multiple_inheritance/car.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -34,6 +34,6 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export(boost::extensions::factory_map & z)
 {
- z.add<car, vehicle, std::string>("A car exported as a vehicle");
- z.add<car, car, std::string>("A car exported as a car");
+ z.get<vehicle, std::string>()["A car exported as a vehicle"].set<car>();
+ z.get<car, std::string>()["A car exported as a car"].set<car>();
 }

Modified: sandbox/libs/extension/examples/multiple_inheritance/car_of_the_future.cpp
==============================================================================
--- sandbox/libs/extension/examples/multiple_inheritance/car_of_the_future.cpp (original)
+++ sandbox/libs/extension/examples/multiple_inheritance/car_of_the_future.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -34,18 +34,18 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export(boost::extensions::factory_map & z)
 {
- z.add<car_of_the_future, vehicle, std::string>
- ("A car of the future exported as a vehicle");
- z.add<car_of_the_future, car, std::string>
- ("A car of the future exported as a car");
- z.add<car_of_the_future, plane, std::string>
- ("A car of the future exported as a plane");
- z.add<car_of_the_future, flying_car, std::string>
- ("A car of the future exported as a flying car");
- z.add<car_of_the_future, boat, std::string>
- ("A car of the future exported as a boat");
- z.add<car_of_the_future, computer, std::string>
- ("A car of the future exported as a computer");
- z.add<car_of_the_future, car_of_the_future, std::string>
- ("A car of the future exported as a car of the future");
+ z.get<vehicle, std::string>()
+ ["A car of the future exported as a vehicle"].set<car_of_the_future>();
+ z.get<car, std::string>()
+ ["A car of the future exported as a car"].set<car_of_the_future>();
+ z.get<plane, std::string>()
+ ["A car of the future exported as a plane"].set<car_of_the_future>();
+ z.get<flying_car, std::string>()
+ ["A car of the future exported as a flying car"].set<car_of_the_future>();
+ z.get<boat, std::string>()
+ ["A car of the future exported as a boat"].set<car_of_the_future>();
+ z.get<computer, std::string>()
+ ["A car of the future exported as a computer"].set<car_of_the_future>();
+ z.get<car_of_the_future, std::string>()
+ ["A car of the future exported as a car of the future"].set<car_of_the_future>();
 }

Modified: sandbox/libs/extension/examples/multiple_inheritance/computer.cpp
==============================================================================
--- sandbox/libs/extension/examples/multiple_inheritance/computer.cpp (original)
+++ sandbox/libs/extension/examples/multiple_inheritance/computer.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -33,6 +33,7 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export(boost::extensions::factory_map & z)
 {
- z.add<computer, computer,
- std::string>("\nA computer exported as a computer");
+ z.get<computer,
+ std::string>()["\nA computer exported as a computer"]
+ .set<computer>();
 }

Modified: sandbox/libs/extension/examples/multiple_inheritance/flying_car.cpp
==============================================================================
--- sandbox/libs/extension/examples/multiple_inheritance/flying_car.cpp (original)
+++ sandbox/libs/extension/examples/multiple_inheritance/flying_car.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -35,10 +35,11 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export(boost::extensions::factory_map & z)
 {
- z.add<flying_car, vehicle,
- std::string>("A flying car exported as a vehicle");
- z.add<flying_car, plane, std::string>("A flying car exported as a plane");
- z.add<flying_car, car, std::string>("A flying car exported as a car");
- z.add<flying_car, flying_car,
- std::string>("A flying car exported as a flying car");
+ z.get<vehicle,
+ std::string>()["A flying car exported as a vehicle"].set<flying_car>();
+ z.get<plane, std::string>()["A flying car exported as a plane"]
+ .set<flying_car>();
+ z.get<car, std::string>()["A flying car exported as a car"].set<flying_car>();
+ z.get<flying_car,
+ std::string>()["A flying car exported as a flying car"].set<flying_car>();
 }

Modified: sandbox/libs/extension/examples/multiple_inheritance/main_mi.cpp
==============================================================================
--- sandbox/libs/extension/examples/multiple_inheritance/main_mi.cpp (original)
+++ sandbox/libs/extension/examples/multiple_inheritance/main_mi.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -42,20 +42,20 @@
   // can be copied from the factory_map object into a different data
   // structure, and the factory_map can be destroyed.
   std::cout << "\n>>>>>>>>>>>>\nComputers:\n>>>>>>>>>>>>>>>>>>>";
- std::list<factory<computer, std::string> > & factory_list =
+ std::map<std::string, factory<computer> > & factory_list =
     twilight.get<computer, std::string>();
   if (factory_list.size() < 1)
     std::cout << "Error - no computers were found.";
- for (std::list<factory<computer, std::string> >::iterator comp =
+ for (std::map<std::string, factory<computer> >::iterator comp =
          factory_list.begin(); comp != factory_list.end(); ++comp)
   {
     // Using auto_ptr to avoid needing delete. Using smart_ptrs is
     // recommended.
     // Note that this has a zero argument constructor - currently constructors
     // with up to six arguments can be used.
- std::auto_ptr<computer> computer_ptr(comp->create());
+ std::auto_ptr<computer> computer_ptr(comp->second.create());
     std::cout << "\n--------\nLoaded the class described as: ";
- std::cout << comp->get_info();
+ std::cout << comp->first;
     std::cout << "\n\nIt claims the following capabilities: ";
     std::cout << computer_ptr->list_capabilities() << "\n";
   }
@@ -64,20 +64,20 @@
   
   
   std::cout << "\n>>>>>>>>>>>>\nVehicles:\n>>>>>>>>>>>>>>>>>>>";
- std::list<factory<vehicle, std::string> > & factory_list2 =
+ std::map<std::string, factory<vehicle> > & factory_list2 =
     twilight.get<vehicle, std::string>();
   if (factory_list2.size() < 1)
     std::cout << "Error - no vehicles were found.";
- for (std::list<factory<vehicle, std::string> >::iterator comp =
+ for (std::map<std::string, factory<vehicle> >::iterator comp =
          factory_list2.begin(); comp != factory_list2.end(); ++comp)
   {
     // Using auto_ptr to avoid needing delete. Using smart_ptrs is
     // recommended.
     // Note that this has a zero argument constructor - currently constructors
     // with up to six arguments can be used.
- std::auto_ptr<vehicle> computer_ptr(comp->create());
+ std::auto_ptr<vehicle> computer_ptr(comp->second.create());
     std::cout << "\n--------\nLoaded the class described as: ";
- std::cout << comp->get_info();
+ std::cout << comp->first;
     std::cout << "\n\nIt claims the following capabilities: ";
     std::cout << computer_ptr->list_capabilities() << "\n";
   }

Modified: sandbox/libs/extension/examples/multiple_inheritance/plane.cpp
==============================================================================
--- sandbox/libs/extension/examples/multiple_inheritance/plane.cpp (original)
+++ sandbox/libs/extension/examples/multiple_inheritance/plane.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -33,6 +33,8 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export(boost::extensions::factory_map & z)
 {
- z.add<plane, vehicle, std::string>("A plane exported as a vehicle");
- z.add<plane, plane, std::string>("A plane exported as a plane");
+ z.get<vehicle, std::string>()["A plane exported as a vehicle"]
+ .set<plane>();
+ z.get<plane, std::string>()["A plane exported as a plane"]
+ .set<plane>();
 }

Modified: sandbox/libs/extension/examples/multiple_inheritance/vehicle.cpp
==============================================================================
--- sandbox/libs/extension/examples/multiple_inheritance/vehicle.cpp (original)
+++ sandbox/libs/extension/examples/multiple_inheritance/vehicle.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -32,5 +32,6 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export(boost::extensions::factory_map & z)
 {
- z.add<vehicle, vehicle, std::string>("A vehicle exported as a vehicle");
+ z.get<vehicle, std::string>()["A vehicle exported as a vehicle"]
+ .set<vehicle>();
 }

Modified: sandbox/libs/extension/examples/parameters/lots_of_parameters.cpp
==============================================================================
--- sandbox/libs/extension/examples/parameters/lots_of_parameters.cpp (original)
+++ sandbox/libs/extension/examples/parameters/lots_of_parameters.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -10,6 +10,7 @@
  */
 
 #include "lots_of_parameters_iface.hpp"
+#include <boost/extension/extension.hpp>
 #include <boost/extension/factory_map.hpp>
 
 #include <iostream>
@@ -39,6 +40,7 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export(boost::extensions::factory_map & fm)
 {
- fm.add< six_parameters, lots_of_parameters_interface, int, bool,
- unsigned int, char, std::string, A, boost::shared_ptr<A> >(6);
+ fm.get< lots_of_parameters_interface, int, bool,
+ unsigned int, char, std::string, A, boost::shared_ptr<A> >()[6]
+ .set<six_parameters>();
 }

Modified: sandbox/libs/extension/examples/parameters/main_lp.cpp
==============================================================================
--- sandbox/libs/extension/examples/parameters/main_lp.cpp (original)
+++ sandbox/libs/extension/examples/parameters/main_lp.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -27,20 +27,20 @@
   // load the shared library with
   load_single_library(fm, "libParametersLib.extension", "extension_export");
 
- std::list<factory<lots_of_parameters_interface, int, bool, unsigned int,
+ std::map<int, factory<lots_of_parameters_interface, bool, unsigned int,
     char, std::string, A, boost::shared_ptr<A> > > & factory_list =
- fm.get<lots_of_parameters_interface, int, bool, unsigned int, char,
- std::string, A, boost::shared_ptr<A> >();
+ fm.get<lots_of_parameters_interface, int, bool, unsigned int, char,
+ std::string, A, boost::shared_ptr<A> >();
   if (factory_list.size() != 1) {
     std::cout << "Error - the class was not found.";
     return 1;
   }
 
- std::list< factory<lots_of_parameters_interface, int, bool, unsigned int,
+ std::map<int, factory<lots_of_parameters_interface, bool, unsigned int,
     char, std::string, A, boost::shared_ptr<A> > >::iterator par =
     factory_list.begin();
   std::auto_ptr< lots_of_parameters_interface >
- par_ptr(par->create(true, 4, 'c', "test", A(2),
+ par_ptr(par->second.create(true, 4, 'c', "test", A(2),
                         boost::shared_ptr<A>(new A(15))));
 
   return 0;

Modified: sandbox/libs/extension/examples/registry/registry_library.cpp
==============================================================================
--- sandbox/libs/extension/examples/registry/registry_library.cpp (original)
+++ sandbox/libs/extension/examples/registry/registry_library.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -45,5 +45,5 @@
   // 5 is just an identifier - not used in this example.
   // Arbitrary information (not just an int) can be stored
   // with the factory.
- fm.add<counting_word, word, int>(5);
+ fm.get<word, int>[5].set<counting_word>();
 }

Modified: sandbox/libs/extension/examples/versioning/hello_world_versions.cpp
==============================================================================
--- sandbox/libs/extension/examples/versioning/hello_world_versions.cpp (original)
+++ sandbox/libs/extension/examples/versioning/hello_world_versions.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -11,6 +11,7 @@
 
 
 #include "../word.hpp"
+#include <boost/extension/extension.hpp>
 #include <boost/extension/factory_map.hpp>
 
 class world : public word
@@ -26,6 +27,6 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export_word(boost::extensions::factory_map & fm)
 {
- fm.add<hello, word, int>(21); // int could be used as version (v2 word 1)
- fm.add<world, word, int>(22); // int could be used as version (v2 word 2)
+ fm.get<word, int>()[21].set<hello>(); // int could be used as version (v2 word 1)
+ fm.get<word, int>()[22].set<world>(); // int could be used as version (v2 word 2)
 }

Modified: sandbox/libs/extension/examples/versioning/main_versions.cpp
==============================================================================
--- sandbox/libs/extension/examples/versioning/main_versions.cpp (original)
+++ sandbox/libs/extension/examples/versioning/main_versions.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -9,7 +9,7 @@
  * See http://www.boost.org/ for latest version.
  */
 
-
+#include <boost/extension/extension.hpp>
 #include <boost/extension/factory_map.hpp>
 #include <boost/extension/shared_library.hpp>
 #include <boost/extension/convenience.hpp>
@@ -44,7 +44,7 @@
   load_single_library(fm, "libSaluteLib.extension", "extension_export_salute");
 
   // Get a reference to the list of constructors for words.
- std::list<factory<word, int> > & factory_list = fm.get<word, int>();
+ std::map<int, factory<word> > & factory_list = fm.get<word, int>();
 
   if (factory_list.size() < 6) {
     std::cout << "Error - the classes were not found ("
@@ -53,7 +53,7 @@
   }
 
   std::cout << "words: " << std::endl;
- for (std::list<factory<word, int> >::iterator current_word =
+ for (std::map<int, factory<word> >::iterator current_word =
          factory_list.begin();
        current_word != factory_list.end(); ++current_word)
     {
@@ -62,13 +62,13 @@
       // Note that this has a zero argument constructor - currently
       // constructors
       // with up to six arguments can be used.
- std::auto_ptr<word> word_ptr(current_word->create());
+ std::auto_ptr<word> word_ptr(current_word->second.create());
       std::cout << word_ptr->get_val() << " ";
     }
   std::cout << std::endl << std::endl;
 
   // Get a reference to the list of constructors for salutes.
- std::list<factory<salute, int> > & salute_factory_list =
+ std::map<int, factory<salute> > & salute_factory_list =
     fm.get<salute, int>();
 
   if (salute_factory_list.size() < 2) {
@@ -78,7 +78,7 @@
   }
 
   std::cout << "salutes: " << std::endl;
- for (std::list<factory<salute, int> >::iterator current_salute =
+ for (std::map<int, factory<salute> >::iterator current_salute =
          salute_factory_list.begin();
        current_salute != salute_factory_list.end(); ++current_salute)
     {
@@ -87,7 +87,7 @@
       // Note that this has a zero argument constructor - currently
       // constructors
       // with up to six arguments can be used.
- std::auto_ptr<salute> salute_ptr(current_salute->create());
+ std::auto_ptr<salute> salute_ptr(current_salute->second.create());
       std::cout << salute_ptr->say() << " ";
     }
   std::cout << std::endl;

Modified: sandbox/libs/extension/examples/versioning/salute.cpp
==============================================================================
--- sandbox/libs/extension/examples/versioning/salute.cpp (original)
+++ sandbox/libs/extension/examples/versioning/salute.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -10,6 +10,7 @@
  */
 
 #include "salute.hpp"
+#include <boost/extension/extension.hpp>
 #include <boost/extension/factory_map.hpp>
 
 class hello : public salute
@@ -28,6 +29,6 @@
 extern "C" void BOOST_EXTENSION_EXPORT_DECL
 extension_export_salute(boost::extensions::factory_map & fm)
 {
- fm.add<hello, salute, int>(1);
- fm.add<bye, salute, int>(2);
+ fm.get<salute, int>()[1].set<hello>();
+ fm.get<salute, int>()[2].set<bye>();
 }

Modified: sandbox/libs/extension/test/Jamfile.v2
==============================================================================
--- sandbox/libs/extension/test/Jamfile.v2 (original)
+++ sandbox/libs/extension/test/Jamfile.v2 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -28,19 +28,20 @@
 
 test-suite extension_tests_all
 :
- # [ run factory_test.cpp ]
- # [ run zone_test.cpp ]
+ [ run factory_test.cpp ]
+ [ run zone_test.cpp ]
   [ run construction.cpp ]
   [ run single_param_test.cpp ]
   [ run double_param_test.cpp ]
   [ run mixed_param_test.cpp ]
- # [ run hello_world_test.cpp ]
- # [ run lib_caching_test.cpp ]
- # [ run versions_test.cpp ]
- # [ run parameters_test.cpp ]
- # [ run multiple_inheritance_test.cpp ]
- # [ run extension_test.cpp ]
- # [ run counted_factory_test.cpp ]
- # [ run registry_test.cpp ]
+ [ run shared_library_test.cpp ]
+ [ run hello_world_test.cpp ]
+ # [ run lib_caching_test.cpp ]
+ # [ run versions_test.cpp ]
+ [ run parameters_test.cpp ]
+ [ run multiple_inheritance_test.cpp ]
+ [ run extension_test.cpp ]
+ # [ run counted_factory_test.cpp ]
+ # [ run registry_test.cpp ]
 :
 ;

Modified: sandbox/libs/extension/test/factory_test.cpp
==============================================================================
--- sandbox/libs/extension/test/factory_test.cpp (original)
+++ sandbox/libs/extension/test/factory_test.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -20,56 +20,53 @@
 using namespace boost::extensions;
 void setup_zone(factory_map & z)
 {
- z.add<apple, fruit, std::string, int, int>("round fruit");
- z.add<banana, fruit, std::string, int, int>("long fruit");
- z.add<nectarine, fruit, std::string, int, int>("small fruit");
+ z.get<fruit, std::string, int, int>()["round fruit"].set<apple>();
+ z.get<fruit, std::string, int, int>()["long fruit"].set<banana>();
+ z.get<fruit, std::string, int, int>()["small fruit"].set<nectarine>();
   
 }
 BOOST_AUTO_TEST_CASE(construct_from_zone)
 {
   factory_map z;
   setup_zone(z);
- std::vector<factory<fruit, std::string, int, int> >
+ std::vector<std::pair<std::string, factory<fruit, int, int> > >
           f1(z.get<fruit, std::string, int, int>().begin(),
              z.get<fruit, std::string, int, int>().end());
 
- std::list<factory<fruit, std::string, int, int> >
+ std::vector<std::pair<std::string, factory<fruit, int, int> > >
           f2(z.get<fruit, std::string, int, int>().begin(),
              z.get<fruit, std::string, int, int>().end());
- std::list<factory<fruit, std::string, int, int> > f3(z);
- std::list<factory<fruit, std::string, int, int> > f4 = z;
+ std::map<std::string, factory<fruit, int, int> > m1(z);
+ //std::vector<std::pair<std::string, factory<fruit, int, int> > > f3(m1);
+ //std::vector<std::pair<std::string, factory<fruit, int, int> > > f4 = m1;
   BOOST_CHECK_EQUAL(f1.size(), f2.size());
- BOOST_CHECK_EQUAL(f1.size(), f3.size());
- BOOST_CHECK_EQUAL(f2.size(), f4.size());
+ // BOOST_CHECK_EQUAL(f1.size(), f3.size());
+ // BOOST_CHECK_EQUAL(f2.size(), f4.size());
   BOOST_CHECK_EQUAL(f1.size(), size_t(3));
 }
 BOOST_AUTO_TEST_CASE(factory_construction)
 {
   factory_map z;
   setup_zone(z);
- std::vector<factory<fruit, std::string, int, int> >
+ std::vector<std::pair<std::string, factory<fruit, int, int> > >
           f1(z.get<fruit, std::string, int, int>().begin(),
              z.get<fruit, std::string, int, int>().end());
- std::vector<factory<fruit, std::string, int, int> >::iterator
+ std::vector<std::pair<std::string, factory<fruit, int, int> > >::iterator
           it = f1.begin();
-
- std::auto_ptr<fruit> first(it->create(0, 1));
- std::auto_ptr<fruit> second((++it)->create(0, 1));
- std::auto_ptr<fruit> third((++it)->create(0, 1));
- BOOST_CHECK_EQUAL((first->get_cost()), 21);
- BOOST_CHECK_EQUAL((second->get_cost()), 7);
+ // Since our TypeInfo is string, they will be created
+ // in alphabetical order by TypeInfo ("round fruit" etc.), yielding
+ // banana, apple, nectarine
+ std::auto_ptr<fruit> first(it->second.create(0, 1));
+ std::auto_ptr<fruit> second((++it)->second.create(0, 1));
+ std::auto_ptr<fruit> third((++it)->second.create(0, 1));
+ BOOST_CHECK_EQUAL((first->get_cost()), 7);
+ BOOST_CHECK_EQUAL((second->get_cost()), 21);
   BOOST_CHECK_EQUAL((third->get_cost()), 18);
   BOOST_CHECK_EQUAL(typeid(*first.get()).name(),
- typeid(apple).name());
- BOOST_CHECK_EQUAL(typeid(*second.get()).name(), typeid(banana).name());
+ typeid(banana).name());
+ BOOST_CHECK_EQUAL(typeid(*second.get()).name(), typeid(apple).name());
   BOOST_CHECK_EQUAL(typeid(*third.get()).name(), typeid(nectarine).name());
   BOOST_CHECK(typeid(*third.get()).name() != typeid(banana).name());
   BOOST_CHECK(typeid(*third.get()).name() != typeid(banana).name());
- //factory<fruit> f;
-
-}
-BOOST_AUTO_TEST_CASE(extension_construction)
-{
- //extension e;
-
 }
+

Modified: sandbox/libs/extension/test/fruit.hpp
==============================================================================
--- sandbox/libs/extension/test/fruit.hpp (original)
+++ sandbox/libs/extension/test/fruit.hpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -70,8 +70,15 @@
 public:
   vegetable_info(const char * name, int calories)
     :name_(name), num_calories_(calories){}
- int get_calories(){return num_calories_;}
- const char * get_name(){return name_.c_str();}
+ int get_calories() const {return num_calories_;}
+ const char * get_name() const {return name_.c_str();}
+ friend inline bool
+ operator<(const vegetable_info & first,
+ const vegetable_info & second) {
+ return first.name_ < second.name_ ||
+ (first.name_ == second.name_ &&
+ first.num_calories_ < second.num_calories_);
+ }
   
 };
 #endif

Modified: sandbox/libs/extension/test/hello_world_test.cpp
==============================================================================
--- sandbox/libs/extension/test/hello_world_test.cpp (original)
+++ sandbox/libs/extension/test/hello_world_test.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -8,7 +8,7 @@
  *
  * See http://www.boost.org/ for latest version.
  */
-
+#include <boost/extension/extension.hpp>
 #include <boost/extension/factory_map.hpp>
 #include <boost/extension/factory.hpp>
 #include <boost/extension/shared_library.hpp>
@@ -24,33 +24,34 @@
 BOOST_AUTO_TEST_CASE(hello_world_example)
 {
   // check if the library can be loaded
- shared_library l((std::string("../bin/libHelloWorldLib") + ".extension").c_str());
+ shared_library l((std::string("../bin/libHelloWorldLib") + ".extension")
+ .c_str());
   BOOST_CHECK_EQUAL( l.open(), true );
 
   // check if the factory can return the functor
   factory_map fm;
- functor<void, factory_map &> load_func =
- l.get_functor<void, factory_map &>("extension_export_word");
- BOOST_CHECK_EQUAL( load_func.is_valid(), true );
+ void (*load_func)(factory_map &) =
+ l.get<void, factory_map &>("extension_export_word");
+ BOOST_CHECK(load_func != 0);
 
- load_func(fm);
+ (*load_func)(fm);
 
   // check if we can get the word list
- std::list<factory<word, int> > & factory_list = fm.get<word, int>();
+ std::map<int, factory<word> > & factory_list = fm.get<word, int>();
   BOOST_CHECK_EQUAL( factory_list.size(), 2U );
 
   // iterate trough the classes and execute get_val method
   // to obtain the correct words
- std::list<factory<word, int> >::iterator current_word = factory_list.begin();
+ std::map<int, factory<word> >::iterator current_word = factory_list.begin();
 
- std::auto_ptr<word> hello_word_ptr(current_word->create());
+ std::auto_ptr<word> hello_word_ptr(current_word->second.create());
   BOOST_CHECK_EQUAL( !hello_word_ptr.get(), 0 );
 
   BOOST_CHECK_EQUAL( hello_word_ptr->get_val(), "hello");
 
   ++current_word;
 
- std::auto_ptr<word> world_word_ptr(current_word->create());
+ std::auto_ptr<word> world_word_ptr(current_word->second.create());
   BOOST_CHECK_EQUAL( !world_word_ptr.get(), 0 );
 
   BOOST_CHECK_EQUAL( world_word_ptr->get_val(), "world!");

Modified: sandbox/libs/extension/test/lib_caching_test.cpp
==============================================================================
--- sandbox/libs/extension/test/lib_caching_test.cpp (original)
+++ sandbox/libs/extension/test/lib_caching_test.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -50,19 +50,19 @@
 
       // check if the factory can return the functor
       factory_map fm;
- functor<void, factory_map &> load_func = l.get_functor<void,
+ void (*load_func)(factory_map &) = l.get<void,
         factory_map &>("extension_export_word");
- BOOST_CHECK_EQUAL( load_func.is_valid(), true );
+ BOOST_CHECK(load_func != 0);
           
- load_func(fm);
+ (*load_func)(fm);
 
- std::list<factory<word, int> > & factory_list = fm.get<word, int>();
+ std::map<int, factory<word> > & factory_list = fm.get<word, int>();
       BOOST_CHECK_EQUAL( factory_list.size(), 2U );
 
- std::list<factory<word, int> >::iterator current_word =
+ std::map<int, factory<word> >::iterator current_word =
         factory_list.begin();
 
- std::auto_ptr<word> hello_word_ptr(current_word->create());
+ std::auto_ptr<word> hello_word_ptr(current_word->second.create());
       BOOST_CHECK_EQUAL( !hello_word_ptr.get(), 0 );
 
       BOOST_CHECK_EQUAL( hello_word_ptr->get_val(), "hello");
@@ -70,7 +70,7 @@
 
       ++current_word;
 
- std::auto_ptr<word> world_word_ptr(current_word->create());
+ std::auto_ptr<word> world_word_ptr(current_word->second.create());
       BOOST_CHECK_EQUAL( !world_word_ptr.get(), 0 );
 
       BOOST_CHECK_EQUAL( world_word_ptr->get_val(), "world!");
@@ -96,22 +96,22 @@
     {
       // check if the factory can return the functor
       factory_map fm;
- functor<void, factory_map &> load_func = l.get_functor<void,
+ void (*load_func)(factory_map &) = l.get<void,
         factory_map &>("extension_export_word");
- BOOST_CHECK_EQUAL( load_func.is_valid(), true );
+ BOOST_CHECK(load_func != 0);
 
- load_func(fm);
+ (*load_func)(fm);
 
       // check if we can get the word list
- std::list<factory<word, int> > & factory_list = fm.get<word, int>();
+ std::map<int, factory<word> > & factory_list = fm.get<word, int>();
       BOOST_CHECK_EQUAL( factory_list.size(), 2U );
           
       // iterate trough the classes and execute get_val method
       // to obtain the correct words
- std::list<factory<word, int> >::iterator current_word =
+ std::map<int, factory<word> >::iterator current_word =
         factory_list.begin();
           
- std::auto_ptr<word> hello_word_ptr(current_word->create());
+ std::auto_ptr<word> hello_word_ptr(current_word->second.create());
       BOOST_CHECK_EQUAL( !hello_word_ptr.get(), 0 );
 
       BOOST_CHECK_EQUAL( hello_word_ptr->get_val(), "| v2 hello");
@@ -119,7 +119,7 @@
 
       ++current_word;
 
- std::auto_ptr<word> world_word_ptr(current_word->create());
+ std::auto_ptr<word> world_word_ptr(current_word->second.create());
       BOOST_CHECK_EQUAL( !world_word_ptr.get(), 0 );
 
       BOOST_CHECK_EQUAL( world_word_ptr->get_val(), "world! v2");
@@ -137,22 +137,22 @@
     {
       // check if the factory can return the functor
       factory_map fm;
- functor<void, factory_map &> load_func = l.get_functor<void,
+ void (*load_func)(factory_map &) = l.get<void,
         factory_map &>("extension_export_word");
- BOOST_CHECK_EQUAL( load_func.is_valid(), true );
+ BOOST_CHECK(load_func != 0);
 
- load_func(fm);
+ (*load_func)(fm);
 
       // check if we can get the word list
- std::list<factory<word, int> > & factory_list = fm.get<word, int>();
+ std::map<int, factory<word> > & factory_list = fm.get<word, int>();
       BOOST_CHECK_EQUAL( factory_list.size(), 2U );
           
       // iterate trough the classes and execute get_val method
       // to obtain the correct words
- std::list<factory<word, int> >::iterator current_word =
+ std::map<int, factory<word> >::iterator current_word =
         factory_list.begin();
           
- std::auto_ptr<word> hello_word_ptr(current_word->create());
+ std::auto_ptr<word> hello_word_ptr(current_word->second.create());
       BOOST_CHECK_EQUAL( !hello_word_ptr.get(), 0 );
 
       BOOST_CHECK_EQUAL( hello_word_ptr->get_val(), "| v2 hello");
@@ -163,7 +163,7 @@
       boost::filesystem::remove(BOOST_EXTENSION_LIBS_DIRECTORY
                                 "libHelloWorldCache.extension");
 
- std::auto_ptr<word> world_word_ptr(current_word->create());
+ std::auto_ptr<word> world_word_ptr(current_word->second.create());
       BOOST_CHECK_EQUAL( !world_word_ptr.get(), 0 );
 
       BOOST_CHECK_EQUAL( world_word_ptr->get_val(), "world! v2");

Modified: sandbox/libs/extension/test/multiple_inheritance_test.cpp
==============================================================================
--- sandbox/libs/extension/test/multiple_inheritance_test.cpp (original)
+++ sandbox/libs/extension/test/multiple_inheritance_test.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -63,27 +63,27 @@
   BOOST_CHECK_EQUAL( libPlane.open(), true );
 
   // check if the factory can return the functor for each library
- functor<void, factory_map &> load_func_vehicle =
- libVehicle.get_functor<void, factory_map &>("extension_export");
- functor<void, factory_map &> load_func_car =
- libCar.get_functor<void, factory_map &>("extension_export");
- functor<void, factory_map &> load_func_computer =
- libComputer.get_functor<void, factory_map &>("extension_export");
- functor<void, factory_map &> load_func_boat =
- libBoat.get_functor<void, factory_map &>("extension_export");
- functor<void, factory_map &> load_func_flyingcar =
- libFlyingCar.get_functor<void, factory_map &>("extension_export");
- functor<void, factory_map &> load_func_carofthefuture =
- libCarOfTheFuture.get_functor<void, factory_map &>("extension_export");
- functor<void, factory_map &> load_func_plane =
- libPlane.get_functor<void, factory_map &>("extension_export");
- BOOST_CHECK_EQUAL( load_func_vehicle.is_valid(), true );
- BOOST_CHECK_EQUAL( load_func_car.is_valid(), true );
- BOOST_CHECK_EQUAL( load_func_computer.is_valid(), true );
- BOOST_CHECK_EQUAL( load_func_boat.is_valid(), true );
- BOOST_CHECK_EQUAL( load_func_flyingcar.is_valid(), true );
- BOOST_CHECK_EQUAL( load_func_carofthefuture.is_valid(), true );
- BOOST_CHECK_EQUAL( load_func_plane.is_valid(), true );
+ void (*load_func_vehicle)(factory_map&) =
+ libVehicle.get<void, factory_map &>("extension_export");
+ void (*load_func_car)(factory_map&) =
+ libCar.get<void, factory_map &>("extension_export");
+ void (*load_func_computer)(factory_map&) =
+ libComputer.get<void, factory_map &>("extension_export");
+ void (*load_func_boat)(factory_map&) =
+ libBoat.get<void, factory_map &>("extension_export");
+ void (*load_func_flyingcar)(factory_map&) =
+ libFlyingCar.get<void, factory_map &>("extension_export");
+ void (*load_func_carofthefuture)(factory_map&) =
+ libCarOfTheFuture.get<void, factory_map &>("extension_export");
+ void (*load_func_plane)(factory_map&) =
+ libPlane.get<void, factory_map &>("extension_export");
+ BOOST_CHECK( load_func_vehicle != 0 );
+ BOOST_CHECK( load_func_car != 0 );
+ BOOST_CHECK( load_func_computer != 0 );
+ BOOST_CHECK( load_func_boat != 0 );
+ BOOST_CHECK( load_func_flyingcar != 0 );
+ BOOST_CHECK( load_func_carofthefuture != 0 );
+ BOOST_CHECK( load_func_plane != 0 );
   load_func_vehicle(twilight);
   load_func_car(twilight);
   load_func_computer(twilight);
@@ -94,73 +94,73 @@
 
 
   // Computer test: we test if we obtain the computer implementation
- std::list<factory<computer, std::string> > & factory_list =
+ std::map<std::string, factory<computer> > & factory_list =
     twilight.get<computer, std::string>();
   BOOST_CHECK_EQUAL( factory_list.size(), 2U );
 
- std::list<factory<computer, std::string> >::iterator comp =
+ std::map<std::string, factory<computer> >::iterator comp =
     factory_list.begin();
 
- std::auto_ptr<computer> computer_ptr(comp->create());
+ std::auto_ptr<computer> computer_ptr(comp->second.create());
   BOOST_CHECK_EQUAL( !computer_ptr.get(), 0 );
 
- BOOST_CHECK_EQUAL( comp->get_info(), "\nA computer exported as a computer" );
+ BOOST_CHECK_EQUAL( comp->first, "\nA computer exported as a computer" );
   BOOST_CHECK_EQUAL( computer_ptr->list_capabilities(), "\nIt computes.");
 
   // Vehicles test: we test if we obtain the different vehicles implementation
- std::list<factory<vehicle, std::string> > & factory_list2 =
+ std::map<std::string, factory<vehicle> > & factory_list2 =
     twilight.get<vehicle, std::string>();
   BOOST_CHECK_EQUAL( factory_list2.size(), 6U );
 
- std::list<factory<vehicle, std::string> >::iterator v =
+ std::map<std::string, factory<vehicle> >::iterator v =
     factory_list2.begin();
-
- // vehicle as a vehicle
- std::auto_ptr<vehicle> v1_ptr(v->create());
- BOOST_CHECK_EQUAL( v->get_info(), "A vehicle exported as a vehicle" );
- BOOST_CHECK_EQUAL( v1_ptr->list_capabilities(),
- "\nIt is some sort of vehicle." );
-
- ++v;
-
- // car as a vehicle
- std::auto_ptr<vehicle> v2_ptr(v->create());
- BOOST_CHECK_EQUAL( v->get_info(), "A car exported as a vehicle" );
- BOOST_CHECK_EQUAL( v2_ptr->list_capabilities(), "\nIt travels on roads." );
-
- ++v;
-
+
   // boat as a vehicle
- std::auto_ptr<vehicle> v3_ptr(v->create());
- BOOST_CHECK_EQUAL( v->get_info(), "A boat exported as a vehicle" );
+ std::auto_ptr<vehicle> v3_ptr(v->second.create());
+ BOOST_CHECK_EQUAL( v->first, "A boat exported as a vehicle" );
   BOOST_CHECK_EQUAL( v3_ptr->list_capabilities(), "\nIt floats on water." );
-
+
   ++v;
-
- // flying car as a vehicle
- std::auto_ptr<vehicle> v4_ptr(v->create());
- BOOST_CHECK_EQUAL( v->get_info(), "A flying car exported as a vehicle");
- BOOST_CHECK_EQUAL( v4_ptr->list_capabilities(),
- "\nIt travels on roads.\nIt flies in the air.\n"
- "It takes off from your driveway" );
+
+ // car as a vehicle
+ std::auto_ptr<vehicle> v2_ptr(v->second.create());
+ BOOST_CHECK_EQUAL( v->first, "A car exported as a vehicle" );
+ BOOST_CHECK_EQUAL( v2_ptr->list_capabilities(), "\nIt travels on roads." );
 
   ++v;
-
+
   // a car of the future as a vehicle
- std::auto_ptr<vehicle> v5_ptr(v->create());
- BOOST_CHECK_EQUAL( v->get_info(), "A car of the future exported as "
+ std::auto_ptr<vehicle> v5_ptr(v->second.create());
+ BOOST_CHECK_EQUAL( v->first, "A car of the future exported as "
                      "a vehicle" );
   BOOST_CHECK_EQUAL( v5_ptr->list_capabilities(), "\nIt floats on water.\n"
                      "It travels on roads.\nIt flies in the air.\n"
                      "It takes off from your driveway\nIt computes.\n"
                      "Costs an arm and a leg" );
+
+ ++v;
+
+ // flying car as a vehicle
+ std::auto_ptr<vehicle> v4_ptr(v->second.create());
+ BOOST_CHECK_EQUAL( v->first, "A flying car exported as a vehicle");
+ BOOST_CHECK_EQUAL( v4_ptr->list_capabilities(),
+ "\nIt travels on roads.\nIt flies in the air.\n"
+ "It takes off from your driveway" );
 
   ++v;
 
   // a plane as a vehicle
- std::auto_ptr<vehicle> v6_ptr(v->create());
- BOOST_CHECK_EQUAL( v->get_info(), "A plane exported as a vehicle" );
+ std::auto_ptr<vehicle> v6_ptr(v->second.create());
+ BOOST_CHECK_EQUAL( v->first, "A plane exported as a vehicle" );
   BOOST_CHECK_EQUAL( v6_ptr->list_capabilities(), "\nIt flies in the air.");
-
+
+ ++v;
+
+ // vehicle as a vehicle
+ std::auto_ptr<vehicle> v1_ptr(v->second.create());
+ BOOST_CHECK_EQUAL( v->first, "A vehicle exported as a vehicle" );
+ BOOST_CHECK_EQUAL( v1_ptr->list_capabilities(),
+ "\nIt is some sort of vehicle." );
+
   // all tests done
 }

Modified: sandbox/libs/extension/test/parameters_test.cpp
==============================================================================
--- sandbox/libs/extension/test/parameters_test.cpp (original)
+++ sandbox/libs/extension/test/parameters_test.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -12,6 +12,7 @@
 #include <boost/extension/factory_map.hpp>
 #include <boost/extension/factory.hpp>
 #include <boost/extension/shared_library.hpp>
+#include <boost/function.hpp>
 #define BOOST_TEST_MAIN
 #define BOOST_TEST_DYN_LINK 1
 #include <boost/test/unit_test.hpp>
@@ -29,26 +30,26 @@
 
   // check if the factory can return the functor
   factory_map fm;
- functor<void, factory_map &> load_func = l.get_functor<void,
+ void (*load_func)(factory_map &) = l.get<void,
     factory_map &>("extension_export");
- BOOST_CHECK_EQUAL( load_func.is_valid(), true );
+ BOOST_CHECK(load_func != 0);
 
- load_func(fm);
+ (*load_func)(fm);
 
   // check if we can get the parameter list
- std::list<factory<lots_of_parameters_interface, int, bool, unsigned int,
+ std::map<int, factory<lots_of_parameters_interface, bool, unsigned int,
     char, std::string, A, boost::shared_ptr<A> > > & factory_list =
           fm.get<lots_of_parameters_interface, int, bool, unsigned int, char,
     std::string, A, boost::shared_ptr<A> >();
   BOOST_CHECK_EQUAL( factory_list.size(), 1U );
 
   // get the interface and construct it
- std::list<factory<lots_of_parameters_interface, int, bool, unsigned int,
+ std::map<int, factory<lots_of_parameters_interface, bool, unsigned int,
     char, std::string, A, boost::shared_ptr<A> > >::iterator params =
           factory_list.begin();
 
   std::auto_ptr<lots_of_parameters_interface>
- params_ptr(params->create(true, 4, 'c', "test", A(2),
+ params_ptr(params->second.create(true, 4, 'c', "test", A(2),
                               boost::shared_ptr<A>(new A(15))));
   BOOST_CHECK_EQUAL( !params_ptr.get(), 0 );
 

Modified: sandbox/libs/extension/test/versions_test.cpp
==============================================================================
--- sandbox/libs/extension/test/versions_test.cpp (original)
+++ sandbox/libs/extension/test/versions_test.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -48,7 +48,7 @@
   load_single_library(fm, "libSaluteLib.extension", "extension_export_salute");
 
   // Get a reference to the list of constructors for words.
- std::list<factory<word, int> > & factory_list = fm.get<word, int>();
+ std::map<int, factory<word> > & factory_list = fm.get<word, int>();
 
   // the point here is to check if six classes were loaded
   // (two for each one of the first three libraries)
@@ -64,20 +64,20 @@
   words.push_back("world! v2");
 
   std::vector<std::string>::const_iterator expected_word = words.begin();
- for (std::list<factory<word, int> >::iterator current_word =
+ for (std::map<int, factory<word> >::iterator current_word =
          factory_list.begin(); current_word != factory_list.end();
        ++current_word)
     {
       /// check that the pointer is OK and the word is the one that
       /// we're expecting
- std::auto_ptr<word> word_ptr(current_word->create());
+ std::auto_ptr<word> word_ptr(current_word->second.create());
       BOOST_CHECK_EQUAL( !word_ptr.get(), 0 );
       BOOST_CHECK_EQUAL( word_ptr->get_val(), *expected_word);
       ++expected_word;
     }
 
   // Get a reference to the list of constructors for salutes.
- std::list<factory<salute, int> > & salute_factory_list = fm.get<salute,
+ std::map<int, factory<salute> > & salute_factory_list = fm.get<salute,
     int>();
 
   // the point here is to check if only two classes were loaded
@@ -90,13 +90,13 @@
 
   std::vector<std::string>::const_iterator expected_salute = salutes.begin();
 
- for (std::list<factory<salute, int> >::iterator current_salute =
+ for (std::map<int, factory<salute> >::iterator current_salute =
          salute_factory_list.begin();
        current_salute != salute_factory_list.end(); ++current_salute)
     {
       /// check that the pointer is OK and the salute is the one that
       /// we're expecting
- std::auto_ptr<salute> salute_ptr(current_salute->create());
+ std::auto_ptr<salute> salute_ptr(current_salute->second.create());
       BOOST_CHECK_EQUAL( !salute_ptr.get(), 0 );
       BOOST_CHECK_EQUAL( salute_ptr->say(), *expected_salute);
       ++expected_salute;

Modified: sandbox/libs/extension/test/zone_test.cpp
==============================================================================
--- sandbox/libs/extension/test/zone_test.cpp (original)
+++ sandbox/libs/extension/test/zone_test.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -22,22 +22,22 @@
 {
   factory_map z;
   BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(0));
- z.add<apple, fruit, std::string, int, int>("A round fruit");
+ z.get<fruit, std::string, int, int>()["A round fruit"].set<apple>();
   BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(1));
   BOOST_CHECK_EQUAL((z.get<apple, std::string, int, int>().size()), size_t(0));
-
 }
 BOOST_AUTO_TEST_CASE(add_multiple)
 {
   factory_map z;
   BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(0));
- z.add<apple, fruit, std::string, int, int>("A round fruit");
+ z.get<fruit, std::string, int, int>()["A round fruit"].set<apple>();
   BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(1));
   BOOST_CHECK_EQUAL((z.get<apple, std::string, int, int>().size()), size_t(0));
- z.add<banana, fruit, std::string, int, int>("A fruit that is not round");
+ z.get<fruit, std::string, int, int>()["A fruit that is not round"]
+ .set<banana>();
   BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(2));
   BOOST_CHECK_EQUAL((z.get<apple, std::string, int, int>().size()), size_t(0));
- z.add<apple, apple, std::string, int, int>("A round fruit");
+ z.get<apple, std::string, int, int>()["A round fruit"].set<apple>();
   BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(2));
   BOOST_CHECK_EQUAL((z.get<apple, std::string, int, int>().size()), size_t(1));
 }
@@ -45,14 +45,14 @@
 {
   factory_map z;
   BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(0));
- z.add<apple, fruit, std::string, int, int>("A round fruit");
+ z.get<fruit, std::string, int, int>()["A round fruit"].set<apple>();
   BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(1));
   BOOST_CHECK_EQUAL((z.get<apple, std::string, int, int>().size()), size_t(0));
- z.add<apple, fruit, std::string, int, int>("A round fruit");
- BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(2));
+ z.get<fruit, std::string, int, int>()["A round fruit"].set<apple>();
+ BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(1));
   BOOST_CHECK_EQUAL((z.get<apple, std::string, int, int>().size()), size_t(0));
- z.add<apple, apple, std::string, int, int>("A round fruit");
- BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(2));
+ z.get<apple, std::string, int, int>()["A round fruit"].set<apple>();
+ BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(1));
   BOOST_CHECK_EQUAL((z.get<apple, std::string, int, int>().size()), size_t(1));
   
 }
@@ -61,15 +61,15 @@
   factory_map z;
   BOOST_CHECK_EQUAL((z.get<vegetable, vegetable_info, float>().size()),
                     size_t(0));
- z.add<apple, fruit, std::string, int, int>("A round fruit");
- z.add<tomato, fruit, std::string, int,
- int>("A round fruit that isn't very sweet");
- z.add<tomato, vegetable, vegetable_info, float>(vegetable_info("Tomato",
- 112));
+ z.get<fruit, std::string, int, int>()["A round fruit"].set<apple>();
+ z.get<fruit, std::string, int,
+ int>()["A round fruit that isn't very sweet"].set<tomato>();
+ z.get<vegetable, vegetable_info, float>()
+ [vegetable_info("Tomato", 112)].set<tomato>();
   BOOST_CHECK_EQUAL((z.get<fruit, std::string, int, int>().size()), size_t(2));
   BOOST_CHECK_EQUAL((z.get<vegetable, vegetable_info, float>().size()),
                     size_t(1));
   BOOST_CHECK_EQUAL((z.get<vegetable, vegetable_info,
- float>().begin()->get_info().get_calories()), 112);
+ float>().begin()->first.get_calories()), 112);
 }
 

Modified: sandbox/libs/reflection/test/Jamfile.v2
==============================================================================
--- sandbox/libs/reflection/test/Jamfile.v2 (original)
+++ sandbox/libs/reflection/test/Jamfile.v2 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -27,5 +27,6 @@
 
 test-suite reflection_tests_all
 : [ run basic_test.cpp ]
+ [ run single_param_test.cpp ]
 :
 ;

Modified: sandbox/libs/reflection/test/basic_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/basic_test.cpp (original)
+++ sandbox/libs/reflection/test/basic_test.cpp 2007-09-11 22:26:52 EDT (Tue, 11 Sep 2007)
@@ -26,22 +26,23 @@
     return 3;
   }
 };
+using namespace boost::reflections;
 BOOST_AUTO_TEST_CASE(argless)
 {
- boost::reflections::reflection car_reflection;
- boost::reflections::reflector<car> car_reflector(&car_reflection);
+ reflection car_reflection;
+ reflector<car> car_reflector(&car_reflection);
   car_reflector.reflect_constructor();
   car_reflector.reflect<int>(&car::start, "start");
 // Check for argless constructor
   BOOST_CHECK(car_reflection.get_constructor().valid());
- boost::reflections::instance car_instance =
+ instance car_instance =
     car_reflection.get_constructor().call();
   BOOST_CHECK(car_reflection.get_function<int>("start").valid());
   // Make sure it doesn't have this undeclared method
   BOOST_CHECK(!car_reflection.get_function<int>("stop").valid());
   BOOST_CHECK_EQUAL
     (car_reflection.get_function<int>("start").call(car_instance), 3);
- boost::reflections::function<int> f =
+ function<int> f =
     car_reflection.get_function<int>("start");
   BOOST_CHECK_EQUAL(f(car_instance), 3);
 }
@@ -59,22 +60,25 @@
 };
 BOOST_AUTO_TEST_CASE(single_arg)
 {
- /*
- boost::reflections::reflector<porsche> * car_reflector =
- new boost::reflections::reflector<porsche>();
- boost::reflections::reflection car_reflection(car_reflector);
- car_reflector->reflect_constructor<int>();
- car_reflector->reflect(&car::start, "start");
+ reflection car_reflection;
+ reflector<porsche> car_reflector(&car_reflection);
+ car_reflector.reflect_constructor<int>();
+ car_reflector.reflect(&porsche::start, "start");
+ car_reflector.reflect(&porsche::get_year, "get_year");
   // Check for argless constructor
- BOOST_CHECK(car_reflection.has_constructor<int>());
- BOOST_CHECK(!car_reflection.has_constructor());
- boost::reflections::instance car_instance = car_reflection.construct(1987);
- BOOST_CHECK(car_reflection.has_method<void, float>("start"));
+ BOOST_CHECK(car_reflection.get_constructor<int>().valid());
+ BOOST_CHECK(!car_reflection.get_constructor().valid());
+ boost::reflections::instance car_instance =
+ car_reflection.get_constructor<int>()(1987);
+ function<void, float> f1(car_reflection.get_function<void, float>("start"));
+ BOOST_CHECK(f1.valid());
   // Make sure it doesn't have this undeclared method
- BOOST_CHECK(!car_reflection.has_method("stop"));
- car_reflection.call(car_instance, "start");
- BOOST_CHECK_EQUAL(car_reflection.call(car_instance, "get_year"), 1987);
- */
+ BOOST_CHECK(!car_reflection.get_function<void>("stop").valid());
+ f1(car_instance, 21.0f);
+ function<int> f2 = car_reflection.get_function<int>("get_year");
+ BOOST_CHECK(f2.valid());
+ int year = f2(car_instance);
+ BOOST_CHECK_EQUAL(year, 1987);
 }
 porsche * get_porsche(float year) {
   return new porsche(static_cast<int>(year));


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