Boost logo

Boost-Commit :

From: sixtrillion_at_[hidden]
Date: 2007-09-04 23:56:50


Author: sixtrillion
Date: 2007-09-04 23:56:48 EDT (Tue, 04 Sep 2007)
New Revision: 39124
URL: http://svn.boost.org/trac/boost/changeset/39124

Log:
This includes the initial changes to the Boost.Extension interfaces.

They all require Boost.Preprocessor now, though a non-Preprocessor version may be created in the future.

Most of the unit tests have been disabled temporarily, as I work to change their usage of the API.

The shared_library API will still be changed.

Added:
   sandbox/boost/extension/common.hpp (contents, props changed)
Removed:
   sandbox/boost/extension/counted_factory.hpp
Text files modified:
   sandbox/boost/extension/convenience.hpp | 44 ---
   sandbox/boost/extension/factory.hpp | 476 +++++----------------------------------
   sandbox/boost/extension/factory_map.hpp | 470 ++++-----------------------------------
   sandbox/boost/extension/registry.hpp | 104 --------
   sandbox/boost/extension/shared_library.hpp | 377 -------------------------------
   sandbox/libs/extension/test/Jamfile.v2 | 21 +
   sandbox/libs/extension/test/construction.cpp | 120 +++++++++
   7 files changed, 235 insertions(+), 1377 deletions(-)

Added: sandbox/boost/extension/common.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/extension/common.hpp 2007-09-04 23:56:48 EDT (Tue, 04 Sep 2007)
@@ -0,0 +1,25 @@
+/*
+ * Boost.Extension / common:
+ * common include files
+ *
+ * (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_COMMON_HPP
+#define BOOST_EXTENSION_COMMON_HPP
+
+#include <boost/preprocessor/arithmetic/inc.hpp>
+#include <boost/preprocessor/if.hpp>
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+#include <boost/preprocessor/repetition.hpp>
+
+#ifndef BOOST_EXTENSION_MAX_FUNCTOR_PARAMS
+#define BOOST_EXTENSION_MAX_FUNCTOR_PARAMS 6
+#endif // BOOST_EXTENSION_MAX_FUNCTOR_PARAMS
+
+#endif // BOOST_EXTENSION_COMMON_HPP

Modified: sandbox/boost/extension/convenience.hpp
==============================================================================
--- sandbox/boost/extension/convenience.hpp (original)
+++ sandbox/boost/extension/convenience.hpp 2007-09-04 23:56:48 EDT (Tue, 04 Sep 2007)
@@ -1,44 +0,0 @@
-/*
- * 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_zone,
- const char * library_path,
- const char * external_function_name)
-{
- shared_library lib(library_path);
- if (!lib.open())
- {
- return;
- }
- functor<void, factory_map &> load_func =
- lib.get_functor<void, factory_map &>(external_function_name);
-
- if (!load_func.is_valid())
- {
- return;
- }
- load_func(current_zone);
-}
-
-}}
-
-
-
-#endif

Deleted: sandbox/boost/extension/counted_factory.hpp
==============================================================================
--- sandbox/boost/extension/counted_factory.hpp 2007-09-04 23:56:48 EDT (Tue, 04 Sep 2007)
+++ (empty file)
@@ -1,727 +0,0 @@
-/*
- * Boost.Extension / counted factory:
- * factory to register the implementations and create them
- * (with a reference count)
- *
- * (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_COUNTED_FACTORY_HPP
-#define BOOST_EXTENSION_COUNTED_FACTORY_HPP
-#include <string>
-
-#ifdef BOOST_EXTENSION_USE_PP
-
-#include <boost/preprocessor/arithmetic/inc.hpp>
-#include <boost/preprocessor/if.hpp>
-#include <boost/preprocessor/punctuation/comma_if.hpp>
-#include <boost/preprocessor/repetition.hpp>
-
-#ifndef BOOST_EXTENSION_MAX_FUNCTOR_PARAMS
-#define BOOST_EXTENSION_MAX_FUNCTOR_PARAMS 6
-#endif
-
-#endif
-
-namespace boost{namespace extensions{
-
-#ifdef BOOST_EXTENSION_USE_PP
-
-/// Declaration of functor class template.
-template <class Interface, class Info,
- BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_INC(\
- BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- class Param, void)>\
- class counted_factory;
-/**/
-
-
-#define BOOST_EXTENSION_COUNTED_FACTORY_CLASS(Z, N, _) \
-template<class Interface, class Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, class Param) > \
-class counted_factory<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > { \
-protected: \
- int * counter_; \
- std::string library_; \
- class generic_factory_function \
- { \
- public: \
- virtual ~generic_factory_function(){} \
- virtual Interface * operator()(int * counter \
- BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, Param) ) = 0; \
- virtual generic_factory_function * copy() const = 0; \
- }; \
- template <class T> \
- class factory_function : public generic_factory_function \
- { \
- public: \
- class counted_object : public T \
- { \
- private: \
- int * counter_; \
- public: \
- counted_object(int * counter BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) \
- : T(BOOST_PP_ENUM_PARAMS(N, p)), \
- counter_(counter) \
- { \
- ++(*counter_); \
- } \
- ~counted_object() \
- { \
- --(*counter_); \
- } \
- }; \
- virtual ~factory_function(){} \
- virtual Interface * operator() \
- (int * counter BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) \
- { \
- return static_cast<Interface*>(new counted_object(counter \
- BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N,p)));} \
- virtual generic_factory_function * copy() const { \
- return new factory_function<T>; \
- } \
- }; \
- std::auto_ptr<generic_factory_function> factory_func_ptr_; \
- Info info_; \
-public: \
- void set_library(const char * library_name) \
- { \
- library_ = library_name; \
- } \
- void set_counter(int * counter) \
- { \
- counter_ = counter; \
- } \
- const char * library() \
- { \
- return library_.c_str(); \
- } \
- template <class Actual> \
- void set_type_special(Actual *){ \
- factory_func_ptr_.reset(new factory_function<Actual>());} \
- template <class Actual> \
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();} \
- counted_factory(Info info) \
- :factory_func_ptr_(0), \
- info_(info) \
- {} \
- counted_factory(const counted_factory & first) \
- :counter_(first.counter_), \
- library_(first.library_), \
- factory_func_ptr_(first.factory_func_ptr_->copy()), \
- info_(first.info_) \
- {} \
- Interface * operator()(int * counter BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) \
- {return create(counter BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, p));} \
- Interface * create(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
- return (*factory_func_ptr_) (counter_ BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, p)); \
- } \
- Info & get_info(){return info_;} \
-};
-/**/
-
-/// Functor template specializations.
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_COUNTED_FACTORY_CLASS, _)
-
-
-#undef BOOST_EXTENSION_COUNTED_FACTORY_CLASS
-#else
- template <class Interface, class Info, class Param1 = void,
- class Param2 = void, class Param3 = void, class Param4 = void,
- class Param5 = void, class Param6 = void>
-class counted_factory
-{
-protected:
- int * counter_;
- std::string library_;
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(int * counter, Param1, Param2, Param3,
- Param4, Param5, Param6) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- class counted_object : public T
- {
- private:
- int * counter_;
- public:
- counted_object(int * counter, Param1 p1, Param2 p2, Param3 p3,
- Param4 p4, Param5 p5, Param6 p6)
- : T(p1, p2, p3, p4, p5, p6),
- counter_(counter)
- {
- ++(*counter_);
- }
- ~counted_object()
- {
- --(*counter_);
- }
- };
- virtual ~factory_function(){}
- virtual Interface * operator()
- (int * counter, Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5,
- Param6 p6)
- { // A compilation error here usually indicates that the
- // class you are adding is not derived from the base class
- // that you indicated.
- return static_cast<Interface*>(new counted_object(counter, p1, p2, p3,
- p4, p5, p6));}
- virtual generic_factory_function * copy() const
- {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- void set_library(const char * library_name)
- {
- library_ = library_name;
- }
- void set_counter(int * counter)
- {
- counter_ = counter;
- }
- const char * library()
- {
- return library_.c_str();
- }
- template <class Actual>
- void set_type_special(Actual *) {
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- counted_factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- counted_factory(const counted_factory & first)
- :counter_(first.counter_),
- library_(first.library_),
- factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(int * counter, Param1 p1, Param2 p2, Param3 p3,
- Param4 p4, Param5 p5, Param6 p6)
- {return create(counter, p1, p2, p3, p4, p5, p6);}
- Interface * create(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5,
- Param6 p6){return (*factory_func_ptr_)
- (counter_, p1, p2, p3, p4, p5, p6);}
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info, class Param1, class Param2,
- class Param3, class Param4, class Param5>
-class counted_factory<Interface, Info, Param1, Param2, Param3, Param4, Param5>
-{
-protected:
- int * counter_;
- std::string library_;
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(int * counter, Param1, Param2, Param3,
- Param4, Param5) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- class counted_object : public T
- {
- private:
- int * counter_;
- public:
- counted_object(int * counter, Param1 p1, Param2 p2, Param3 p3,
- Param4 p4, Param5 p5) : T(p1, p2, p3, p4, p5),
- counter_(counter)
- {
- ++(*counter_);
- }
- ~counted_object()
- {
- --(*counter_);
- }
- };
- virtual ~factory_function(){}
- virtual Interface * operator()
- (int * counter, Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)
- { // A compilation error here usually indicates that the
- // class you are adding is not derived from the base class
- // that you indicated.
- return static_cast<Interface*>(new counted_object(counter, p1, p2, p3,
- p4, p5));}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- void set_library(const char * library_name)
- {
- library_ = library_name;
- }
- void set_counter(int * counter)
- {
- counter_ = counter;
- }
- const char * library()
- {
- return library_.c_str();
- }
- template <class Actual>
- void set_type_special(Actual *){
- factory_func_ptr_.reset(new factory_function<Actual>());}
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- counted_factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- counted_factory(const counted_factory & first)
- :counter_(first.counter_),
- library_(first.library_),
- factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(int * counter, Param1 p1, Param2 p2, Param3 p3,
- Param4 p4, Param5 p5)
- {return create(counter, p1, p2, p3, p4, p5);}
- Interface * create(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) {
- return (*factory_func_ptr_) (counter_, p1, p2, p3, p4, p5);
- }
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info, class Param1, class Param2,
- class Param3, class Param4>
-class counted_factory<Interface, Info, Param1, Param2, Param3, Param4>
-{
-protected:
- int * counter_;
- std::string library_;
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(int * counter, Param1, Param2, Param3,
- Param4) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- class counted_object : public T
- {
- private:
- int * counter_;
- public:
- counted_object(int * counter, Param1 p1, Param2 p2, Param3 p3,
- Param4 p4) : T(p1, p2, p3, p4),
- counter_(counter)
- {
- ++(*counter_);
- }
- ~counted_object()
- {
- --(*counter_);
- }
- };
- virtual ~factory_function(){}
- virtual Interface * operator()
- (int * counter, Param1 p1, Param2 p2, Param3 p3, Param4 p4)
- { // A compilation error here usually indicates that the
- // class you are adding is not derived from the base class
- // that you indicated.
- return static_cast<Interface*>(new counted_object(counter, p1, p2, p3,
- p4));}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- void set_library(const char * library_name)
- {
- library_ = library_name;
- }
- void set_counter(int * counter)
- {
- counter_ = counter;
- }
- const char * library()
- {
- return library_.c_str();
- }
- template <class Actual>
- void set_type_special(Actual *){
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- counted_factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- counted_factory(const counted_factory & first)
- :counter_(first.counter_),
- library_(first.library_),
- factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(int * counter, Param1 p1, Param2 p2, Param3 p3,
- Param4 p4)
- {return create(counter, p1, p2, p3, p4);}
- Interface * create(Param1 p1, Param2 p2, Param3 p3, Param4 p4) {
- return (*factory_func_ptr_) (counter_, p1, p2, p3, p4);
- }
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info, class Param1, class Param2,
- class Param3>
-class counted_factory<Interface, Info, Param1, Param2, Param3>
-{
-protected:
- int * counter_;
- std::string library_;
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(int * counter, Param1, Param2, Param3) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- class counted_object : public T
- {
- private:
- int * counter_;
- public:
- counted_object(int * counter, Param1 p1, Param2 p2, Param3 p3)
- : T(p1, p2, p3),
- counter_(counter)
- {
- ++(*counter_);
- }
- ~counted_object()
- {
- --(*counter_);
- }
- };
- virtual ~factory_function(){}
- virtual Interface * operator()
- (int * counter, Param1 p1, Param2 p2, Param3 p3)
- { // A compilation error here usually indicates that the
- // class you are adding is not derived from the base class
- // that you indicated.
- return static_cast<Interface*>(new counted_object(counter, p1, p2, p3));}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- void set_library(const char * library_name)
- {
- library_ = library_name;
- }
- void set_counter(int * counter)
- {
- counter_ = counter;
- }
- const char * library()
- {
- return library_.c_str();
- }
- template <class Actual>
- void set_type_special(Actual *){
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- counted_factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- counted_factory(const counted_factory & first)
- :counter_(first.counter_),
- library_(first.library_),
- factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(int * counter, Param1 p1, Param2 p2, Param3 p3)
- {return create(counter, p1, p2, p3);}
- Interface * create(Param1 p1, Param2 p2, Param3 p3){
- return (*factory_func_ptr_) (counter_, p1, p2, p3);
- }
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info, class Param1, class Param2>
-class counted_factory<Interface, Info, Param1, Param2>
-{
-protected:
- int * counter_;
- std::string library_;
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(int * counter, Param1, Param2) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- class counted_object : public T
- {
- private:
- int * counter_;
- public:
- counted_object(int * counter, Param1 p1, Param2 p2) : T(p1, p2),
- counter_(counter)
- {
- ++(*counter_);
- }
- ~counted_object()
- {
- --(*counter_);
- }
- };
- virtual ~factory_function(){}
- virtual Interface * operator()
- (int * counter, Param1 p1, Param2 p2)
- { // A compilation error here usually indicates that the
- // class you are adding is not derived from the base class
- // that you indicated.
- return static_cast<Interface*>(new counted_object(counter, p1, p2));}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- void set_library(const char * library_name)
- {
- library_ = library_name;
- }
- void set_counter(int * counter)
- {
- counter_ = counter;
- }
- const char * library()
- {
- return library_.c_str();
- }
- template <class Actual>
- void set_type_special(Actual *){
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- counted_factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- counted_factory(const counted_factory & first)
- :counter_(first.counter_),
- library_(first.library_),
- factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(int * counter, Param1 p1, Param2 p2)
- {return create(counter, p1, p2);}
- Interface * create(Param1 p1, Param2 p2){return (*factory_func_ptr_)
- (counter_, p1, p2);}
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info, class Param1>
-class counted_factory<Interface, Info, Param1>
-{
-protected:
- int * counter_;
- std::string library_;
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(int * counter, Param1) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- class counted_object : public T
- {
- private:
- int * counter_;
- public:
- counted_object(int * counter, Param1 p1) : T(p1),
- counter_(counter)
- {
- ++(*counter_);
- }
- ~counted_object()
- {
- --(*counter_);
- }
- };
- virtual ~factory_function(){}
- virtual Interface * operator()
- (int * counter, Param1 p1)
- { // A compilation error here usually indicates that the
- // class you are adding is not derived from the base class
- // that you indicated.
- return static_cast<Interface*>(new counted_object(counter, p1));}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- void set_library(const char * library_name)
- {
- library_ = library_name;
- }
- void set_counter(int * counter)
- {
- counter_ = counter;
- }
- const char * library()
- {
- return library_.c_str();
- }
- template <class Actual>
- void set_type_special(Actual *){
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- counted_factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- counted_factory(const counted_factory & first)
- :counter_(first.counter_),
- library_(first.library_),
- factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(int * counter, Param1 p1)
- {return create(counter, p1);}
- Interface * create(Param1 p1){return (*factory_func_ptr_)
- (counter_, p1);}
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info>
-class counted_factory<Interface, Info>
-{
-protected:
- int * counter_;
- std::string library_;
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(int * counter) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- class counted_object : public T
- {
- private:
- int * counter_;
- public:
- counted_object(int * counter) : T(),
- counter_(counter)
- {
- ++(*counter_);
- }
- ~counted_object()
- {
- --(*counter_);
- }
- };
- virtual ~factory_function(){}
- virtual Interface * operator()
- (int * counter)
- { // A compilation error here usually indicates that the
- // class you are adding is not derived from the base class
- // that you indicated.
- return static_cast<Interface*>(new counted_object(counter));}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- void set_library(const char * library_name)
- {
- library_ = library_name;
- }
- void set_counter(int * counter)
- {
- counter_ = counter;
- }
- const char * library()
- {
- return library_.c_str();
- }
- template <class Actual>
- void set_type_special(Actual *){
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- counted_factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- counted_factory(const counted_factory & first)
- :counter_(first.counter_),
- library_(first.library_),
- factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(int * counter)
- {return create(counter);}
- Interface * create(){return (*factory_func_ptr_)
- (counter_);}
- Info & get_info(){return info_;}
-};
-#endif // BOOST_EXTENSION_USE_PP
-}}
-#endif

Modified: sandbox/boost/extension/factory.hpp
==============================================================================
--- sandbox/boost/extension/factory.hpp (original)
+++ sandbox/boost/extension/factory.hpp 2007-09-04 23:56:48 EDT (Tue, 04 Sep 2007)
@@ -13,432 +13,76 @@
 #ifndef BOOST_EXTENSION_FACTORY_HPP
 #define BOOST_EXTENSION_FACTORY_HPP
 
-#include <string>
-
-#ifdef BOOST_EXTENSION_USE_PP
-
-#include <boost/preprocessor/arithmetic/inc.hpp>
-#include <boost/preprocessor/if.hpp>
-#include <boost/preprocessor/punctuation/comma_if.hpp>
-#include <boost/preprocessor/repetition.hpp>
-
-#ifndef BOOST_EXTENSION_MAX_FUNCTOR_PARAMS
-#define BOOST_EXTENSION_MAX_FUNCTOR_PARAMS 6
-#endif
-
-#endif
+#include <boost/extension/common.hpp>
 
 namespace boost{namespace extensions{
+template <class T, class D
+ 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 create_function;
+
+#define BOOST_EXTENSION_CREATE_FUNCTION_CLASS(Z, N, _) \
+template <class T, class D BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, \
+ class Param) > \
+class create_function<T, D BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, \
+ Param) > \
+{ \
+public: \
+ static T * create(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ return new D(BOOST_PP_ENUM_PARAMS(N, p)); \
+ } \
+};
 
-#ifdef BOOST_EXTENSION_USE_PP
-
-/// Declaration of functor class template.
-template <class Interface, class Info,
- BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_INC(\
- BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- class Param, void)> class factory;
-
-
+template <class T
+ 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 factory;
 
 #define BOOST_EXTENSION_FACTORY_CLASS(Z, N, _) \
-template<class Interface, class Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, \
- class Param) > \
-class factory<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > { \
- protected: \
- class generic_factory_function \
- { \
- public: \
- virtual ~generic_factory_function(){} \
- virtual Interface * operator()(BOOST_PP_ENUM_PARAMS(N, Param)) = 0;\
- virtual generic_factory_function * copy() const = 0; \
- }; \
- template <class T> \
- class factory_function : public generic_factory_function \
- { \
- public: \
- virtual ~factory_function(){} \
- virtual Interface * operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p))\
- { \
- return new T(BOOST_PP_ENUM_PARAMS(N, p)); \
- } \
- virtual generic_factory_function * copy() const \
- { \
- return new factory_function<T>; \
- } \
- }; \
- std::auto_ptr<generic_factory_function> factory_func_ptr_; \
- Info info_; \
- public: \
- template <class Actual> \
- void set_type_special(Actual *) { \
- factory_func_ptr_.reset(new factory_function<Actual>()); \
+template <class T BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, \
+ class Param) > \
+class factory <T BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, \
+ Param) > \
+{ \
+public: \
+ template <class D> \
+ void set() { \
+ func_ = &create_function<T, D BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, \
+ Param)>::create; \
   } \
- template <class Actual> \
- void set_type(){ \
- factory_func_ptr_ = new factory_function<Actual>(); \
- } \
- factory(Info info) :factory_func_ptr_(0), info_(info) {} \
- factory(const factory & first) \
- :factory_func_ptr_(first.factory_func_ptr_->copy()), info_(first.info_){} \
- Interface * operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) \
- { \
- return create(BOOST_PP_ENUM_PARAMS(N, p)); \
- } \
- Interface * create(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) \
- { \
- return (*factory_func_ptr_) (BOOST_PP_ENUM_PARAMS(N, p)); \
+ factory() : func_(0) {} \
+ factory(const factory<T> & first) : func_(first.func_) {} \
+ factory & operator=(const factory<T> & first) { \
+ func_ = first->func_; \
+ return *this; \
+ } \
+ bool is_valid() {return func_ != 0;} \
+ T * create(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
+ if (func_) { \
+ return func_(BOOST_PP_ENUM_PARAMS(N, p)); \
+ } else { \
+ return 0; \
     } \
- Info & get_info(){return info_;} \
+ } \
+private: \
+ T * (*func_)(BOOST_PP_ENUM_PARAMS(N, Param)); \
 };
-/**/
 
-
-/// Functor template specializations.
 BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_FACTORY_CLASS, _)
-
+ BOOST_EXTENSION_CREATE_FUNCTION_CLASS, _)
+BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
+ BOOST_EXTENSION_FACTORY_CLASS, _)
 #undef BOOST_EXTENSION_FACTORY_CLASS
-#else
-
- template <class Interface, class Info, class Param1 = void,
- class Param2 = void, class Param3 = void, class Param4 = void,
- class Param5 = void, class Param6 = void>
-class factory
-{
-protected:
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(Param1, Param2, Param3, Param4, Param5,
- Param6) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- virtual ~factory_function(){}
- virtual Interface * operator()
- (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)
- {return new T(p1, p2, p3, p4, p5, p6);}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- template <class Actual>
- void set_type_special(Actual *) {
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- factory(const factory & first)
- :factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(Param1 p1, Param2 p2, Param3 p3, Param4 p4,
- Param5 p5, Param6 p6)
- {return create(p1, p2, p3, p4, p5, p6);}
- Interface * create(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5,
- Param6 p6)
- {
- return (*factory_func_ptr_) (p1, p2, p3, p4, p5, p6);
- }
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info, class Param1, class Param2,
- class Param3, class Param4, class Param5>
-class factory<Interface, Info, Param1, Param2, Param3, Param4, Param5>
-{
-protected:
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(Param1, Param2, Param3, Param4, Param5) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- virtual ~factory_function(){}
- virtual Interface * operator()
- (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)
- {return new T(p1, p2, p3, p4, p5);}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- template <class Actual>
- void set_type_special(Actual *) {
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- factory(const factory & first)
- :factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)
- {return create(p1, p2, p3, p4, p5);}
- Interface * create(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) {
- return (*factory_func_ptr_) (p1, p2, p3, p4, p5);
- }
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info, class Param1, class Param2,
- class Param3, class Param4>
-class factory<Interface, Info, Param1, Param2, Param3, Param4>
-{
-protected:
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(Param1, Param2, Param3, Param4) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- virtual ~factory_function(){}
- virtual Interface * operator()
- (Param1 p1, Param2 p2, Param3 p3, Param4 p4)
- {return new T(p1, p2, p3, p4);}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- template <class Actual>
- void set_type_special(Actual *) {
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- factory(const factory & first)
- :factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(Param1 p1, Param2 p2, Param3 p3, Param4 p4)
- {return create(p1, p2, p3, p4);}
- Interface * create(Param1 p1, Param2 p2, Param3 p3, Param4 p4) {
- return (*factory_func_ptr_) (p1, p2, p3, p4);
- }
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info, class Param1, class Param2,
- class Param3>
-class factory<Interface, Info, Param1, Param2, Param3>
-{
-protected:
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(Param1, Param2, Param3) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- virtual ~factory_function(){}
- virtual Interface * operator()
- (Param1 p1, Param2 p2, Param3 p3)
- {return new T(p1, p2, p3);}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- template <class Actual>
- void set_type_special(Actual *) {
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- factory(const factory & first)
- :factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(Param1 p1, Param2 p2, Param3 p3)
- {return create(p1, p2, p3);}
- Interface * create(Param1 p1, Param2 p2, Param3 p3) {
- return (*factory_func_ptr_) (p1, p2, p3);
- }
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info, class Param1, class Param2>
-class factory<Interface, Info, Param1, Param2>
-{
-protected:
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(Param1, Param2) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- virtual ~factory_function(){}
- virtual Interface * operator()
- (Param1 p1, Param2 p2)
- {return new T(p1, p2);}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- template <class Actual>
- void set_type_special(Actual *) {
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- factory(const factory & first)
- :factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(Param1 p1, Param2 p2)
- {return create(p1, p2);}
- Interface * create(Param1 p1, Param2 p2){return (*factory_func_ptr_)
- (p1, p2);}
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info, class Param1>
-class factory<Interface, Info, Param1>
-{
-protected:
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()(Param1) = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- virtual ~factory_function(){}
- virtual Interface * operator()
- (Param1 p1)
- {return new T(p1);}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- template <class Actual>
- void set_type_special(Actual *) {
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- factory(const factory & first)
- :factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()(Param1 p1)
- {return create(p1);}
- Interface * create(Param1 p1){return (*factory_func_ptr_)
- (p1);}
- Info & get_info(){return info_;}
-};
-template <class Interface, class Info>
-class factory<Interface, Info>
-{
-protected:
- class generic_factory_function
- {
- public:
- virtual ~generic_factory_function(){}
- virtual Interface * operator()() = 0;
- virtual generic_factory_function * copy() const = 0;
- };
- template <class T>
- class factory_function : public generic_factory_function
- {
- public:
- virtual ~factory_function(){}
- virtual Interface * operator()
- ()
- {return new T();}
- virtual generic_factory_function * copy() const {
- return new factory_function<T>;
- }
- };
- std::auto_ptr<generic_factory_function> factory_func_ptr_;
- Info info_;
-public:
- template <class Actual>
- void set_type_special(Actual *) {
- factory_func_ptr_.reset(new factory_function<Actual>());
- }
- template <class Actual>
- void set_type(){factory_func_ptr_ = new factory_function<Actual>();}
- factory(Info info)
- :factory_func_ptr_(0),
- info_(info)
- {}
- factory(const factory & first)
- :factory_func_ptr_(first.factory_func_ptr_->copy()),
- info_(first.info_)
- {}
- Interface * operator()()
- {return create();}
- Interface * create(){return (*factory_func_ptr_)
- ();}
- Info & get_info(){return info_;}
-};
-#endif // BOOST_EXTENSION_USE_PP
+#undef BOOST_EXTENSION_CREATE_FUNCTION_CLASS
 }}
 
-
-#endif
+#endif // BOOST_EXTENSION_FACTORY_HPP

Modified: sandbox/boost/extension/factory_map.hpp
==============================================================================
--- sandbox/boost/extension/factory_map.hpp (original)
+++ sandbox/boost/extension/factory_map.hpp 2007-09-04 23:56:48 EDT (Tue, 04 Sep 2007)
@@ -12,436 +12,70 @@
 
 #ifndef BOOST_EXTENSION_FACTORY_MAP_HPP
 #define BOOST_EXTENSION_FACTORY_MAP_HPP
-#include <list>
-#include <memory>
 #include <map>
 #include <boost/extension/factory.hpp>
-#include <boost/extension/extension.hpp>
-#include <boost/extension/impl/typeinfo.hpp>
-
-#ifdef BOOST_EXTENSION_USE_PP
-
-#include <boost/preprocessor/arithmetic/inc.hpp>
-#include <boost/preprocessor/if.hpp>
-#include <boost/preprocessor/punctuation/comma_if.hpp>
-#include <boost/preprocessor/repetition.hpp>
-
-#ifndef BOOST_EXTENSION_MAX_FUNCTOR_PARAMS
-#define BOOST_EXTENSION_MAX_FUNCTOR_PARAMS 6
-#endif
-
-#endif
-
+#include <boost/extension/impl/typeinfo.hpp>
 
 namespace boost{namespace extensions{
 
-
-template <class TypeInfo>
-class basic_factory_map
-{
-protected:
- class generic_factory_container
- {
- public:
- virtual ~generic_factory_container(){}
- };
- template <class Interface, class Info, class Param1 = void,
- class Param2 = void, class Param3 = void, class Param4 = void,
- class Param5 = void, class Param6 = void>
- class factory_container : public std::list<factory<Interface, Info, Param1,
- Param2, Param3, Param4,
- Param5, Param6> >,
- public generic_factory_container
- {
- public:
- factory_container() {}
- // factory_container(basic_factory_map & z)
- // :std::list<factory<Interface, Info, Param1, Param2, Param3, Param4,
- // Param5, Param6> >(z.get<Interface, Param1, Param2, Param3, Param4,
- // Param5, Param6>()){}
- virtual ~factory_container(){}
-
- // factory_container() {}
- // factory_container(basic_factory_map & z)
- // :std::list<factory<Interface, Info, Param1, Param2, Param3, Param4,
- // Param5, Param6> >(z.get<Interface, Param1, Param2, Param3, Param4,
- // Param5, Param6>()){}
- //virtual ~factory_container(){}
- };
- typedef std::map<TypeInfo, generic_factory_container *> FactoryMap;
- FactoryMap factories_;
-public:
- ~basic_factory_map(){
- for(typename FactoryMap::iterator it = factories_.begin();
- it != factories_.end(); ++it)
- delete it->second;
- //TODO - test for memory leaks.
- }
-#ifdef BOOST_EXTENSION_USE_PP
-
-#define BOOST_EXTENSION_FACTORY_MAP_OPERATOR_LIST(Z, N, _) \
-template<class Interface, class Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, \
- class Param) > \
-operator std::list<factory<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > > & () { \
- return this->get<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) >(); \
-}
-/**/
-
-#define BOOST_EXTENSION_FACTORY_MAP_GET_METHOD(Z, N, _) \
-template <class Interface, class Info BOOST_PP_COMMA_IF(N) \
+#define BOOST_EXTENSION_FACTORY_MAP_GET_FUNCTION(Z, N, _) \
+template <class Interface, class Info \
+ BOOST_PP_COMMA_IF(N) \
           BOOST_PP_ENUM_PARAMS(N, class Param) > \
-std::list<factory<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > > & get() \
-{ \
- TypeInfo current_type = \
- type_info_handler<TypeInfo, factory<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > >::get_class_type(); \
- typename FactoryMap::iterator it = factories_.find(current_type); \
- if (it == factories_.end()) \
- { \
- factory_container<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > * ret = \
- new factory_container<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) >(); \
- factories_[current_type] = ret; \
- return *ret; \
- } \
- else \
- { \
- return static_cast<factory_container<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > &>(*(it->second)); \
+std::map<Info, \
+ factory<Interface BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)> > & get() { \
+ TypeInfo t = type_info_handler<TypeInfo, \
+ Interface *(*)(BOOST_PP_ENUM_PARAMS(N, Param))> \
+ ::get_class_type(); \
+ typename std::map<TypeInfo, generic_map_holder*>::iterator it = \
+ maps_.find(t); \
+ map_holder<std::map<Info, \
+ factory<Interface BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, Param)> > > \
+ * holder; \
+ if (it == maps_.end()) { \
+ holder = new map_holder<std::map<Info, \
+ factory<Interface BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, Param)> > >; \
+ it = maps_.insert(std::make_pair \
+ (t, holder)).first; \
+ } else { \
+ holder = \
+ static_cast<map_holder<std::map<Info, \
+ factory<Interface BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)> > > *> \
+ (it->second); \
   } \
+ return *static_cast<std::map<Info, \
+ factory<Interface BOOST_PP_COMMA_IF(N) \
+ BOOST_PP_ENUM_PARAMS(N, Param)> > * >(holder); \
 }
-/**/
-
-
-#define BOOST_EXTENSION_FACTORY_MAP_ADD_METHOD(Z, N, _) \
-template <class Actual, class Interface, class Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, class Param) > \
-void add(Info info) \
-{ \
- typedef std::list<factory<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > > ListType; \
- ListType & s = this->get<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) >(); \
- factory<Interface, Info BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > f(info); \
- f.set_type_special((Actual*)0); \
- s.push_back(f); \
-}
-/**/
-
-
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_FACTORY_MAP_OPERATOR_LIST, _)
-
-
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_FACTORY_MAP_GET_METHOD, _)
-
 
+
+template <class TypeInfo>
+class basic_factory_map {
+public:
 BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_FACTORY_MAP_ADD_METHOD, _)
-
-
-#undef BOOST_EXTENSION_FACTORY_MAP_OPERATOR_LIST
-#undef BOOST_EXTENSION_FACTORY_MAP_GET_METHOD
-#undef BOOST_EXTENSION_FACTORY_MAP_ADD_METHOD
-#else
- template <class Interface, class Info>
-operator std::list<factory<Interface, Info> > & ()
- {return this->get<Interface, Info>();}
- template <class Interface, class Info>
-std::list<factory<Interface, Info> > & get()
- {
- TypeInfo current_type =
- type_info_handler<TypeInfo,
- factory<Interface, Info> >::get_class_type();
- typename FactoryMap::iterator it = factories_.find(current_type);
-
- if (it == factories_.end())
- {
- factory_container<Interface, Info> * ret =
- new factory_container<Interface, Info>();
- factories_[current_type] = ret;
- return *ret;
- }
- else
- {
- // Change to dynamic if this fails
- return static_cast<factory_container<Interface,
- Info> &>(*(it->second));
- }
- }
-template <class Actual, class Interface, class Info>
-void add(Info info)
- {
- typedef std::list<factory<Interface, Info> > ListType;
- ListType & s = this->get<Interface, Info>();
- factory<Interface, Info> f(info);
- //f.set_type<Actual>();
- f.set_type_special((Actual*)0);
- s.push_back(f);
- //it->set_type<Actual>();
- }
- template <class Interface, class Info, class Param1>
-operator std::list<factory<Interface, Info, Param1> > & ()
- {return this->get<Interface, Info, Param1>();}
- template <class Interface, class Info, class Param1>
-std::list<factory<Interface, Info, Param1> > & get()
- {
- TypeInfo current_type = type_info_handler<TypeInfo,
- factory<Interface, Info, Param1> >::get_class_type();
- typename FactoryMap::iterator it =
- factories_.find(current_type);
-
- if (it == factories_.end())
- {
- factory_container<Interface, Info, Param1> * ret =
- new factory_container<Interface, Info, Param1>();
- factories_[current_type] = ret;
- return *ret;
- }
- else
- {
- // Change to dynamic if this fails
- return static_cast<factory_container<Interface,
- Info, Param1> &>(*(it->second));
- }
- }
-template <class Actual, class Interface, class Info, class Param1>
-void add(Info info)
- {
- typedef std::list<factory<Interface, Info, Param1> > ListType;
- ListType & s = this->get<Interface, Info, Param1>();
- factory<Interface, Info, Param1> f(info);
- //f.set_type<Actual>();
- f.set_type_special((Actual*)0);
- s.push_back(f);
- //it->set_type<Actual>();
- }
- template <class Interface, class Info, class Param1, class Param2>
-operator std::list<factory<Interface, Info, Param1, Param2> > & ()
- {return this->get<Interface, Info, Param1, Param2>();}
- template <class Interface, class Info, class Param1, class Param2>
-std::list<factory<Interface, Info, Param1, Param2> > & get()
- {
- TypeInfo current_type =
- type_info_handler<TypeInfo, factory<Interface, Info, Param1,
- Param2> >::get_class_type();
- typename FactoryMap::iterator it =
- factories_.find(current_type);
-
- if (it == factories_.end())
- {
- factory_container<Interface, Info, Param1, Param2> * ret =
- new factory_container<Interface, Info, Param1, Param2>();
- factories_[current_type] = ret;
- return *ret;
- }
- else
- {
- // Change to dynamic if this fails
- return static_cast<factory_container<Interface, Info, Param1,
- Param2> &>(*(it->second));
- }
- }
-template <class Actual, class Interface, class Info, class Param1,
- class Param2>
-void add(Info info)
- {
- typedef std::list<factory<Interface, Info, Param1, Param2> > ListType;
- ListType & s = this->get<Interface, Info, Param1, Param2>();
- factory<Interface, Info, Param1, Param2> f(info);
- //f.set_type<Actual>();
- f.set_type_special((Actual*)0);
- s.push_back(f);
- //it->set_type<Actual>();
- }
- template <class Interface, class Info, class Param1, class Param2,
- class Param3>
-operator std::list<factory<Interface, Info, Param1, Param2, Param3> > & ()
- {return this->get<Interface, Info, Param1, Param2, Param3>();}
- template <class Interface, class Info, class Param1, class Param2,
- class Param3>
-std::list<factory<Interface, Info, Param1, Param2, Param3> > & get()
- {
- TypeInfo current_type =
- type_info_handler<TypeInfo, factory<Interface, Info, Param1, Param2,
- Param3> >::get_class_type();
- typename FactoryMap::iterator it = factories_.find(current_type);
-
- if (it == factories_.end())
- {
- factory_container<Interface, Info, Param1, Param2, Param3> * ret =
- new factory_container<Interface, Info, Param1, Param2, Param3>();
- factories_[current_type] = ret;
- return *ret;
- }
- else
- {
- // Change to dynamic if this fails
- return static_cast<factory_container<Interface, Info, Param1, Param2,
- Param3> &>(*(it->second));
- }
- }
-template <class Actual, class Interface, class Info, class Param1,
- class Param2, class Param3>
-void add(Info info)
- {
- typedef std::list<factory<Interface, Info, Param1, Param2,
- Param3> > ListType;
- ListType & s = this->get<Interface, Info, Param1, Param2, Param3>();
- factory<Interface, Info, Param1, Param2, Param3> f(info);
- //f.set_type<Actual>();
- f.set_type_special((Actual*)0);
- s.push_back(f);
- //it->set_type<Actual>();
- }
- template <class Interface, class Info, class Param1, class Param2,
- class Param3, class Param4>
-operator std::list<factory<Interface, Info, Param1, Param2, Param3,
- Param4> > & ()
- {return this->get<Interface, Info, Param1, Param2, Param3, Param4>();}
- template <class Interface, class Info, class Param1, class Param2,
- class Param3, class Param4>
-std::list<factory<Interface, Info, Param1, Param2, Param3, Param4> > & get()
- {
- TypeInfo current_type =
- type_info_handler<TypeInfo, factory<Interface, Info, Param1, Param2,
- Param3, Param4> >::get_class_type();
- typename FactoryMap::iterator it = factories_.find(current_type);
-
- if (it == factories_.end())
- {
- factory_container<Interface, Info, Param1, Param2, Param3,
- Param4> * ret = new factory_container<Interface, Info, Param1,
- Param2, Param3, Param4>();
- factories_[current_type] = ret;
- return *ret;
- }
- else
- {
- // Change to dynamic if this fails
- return static_cast<factory_container<Interface, Info, Param1, Param2,
- Param3, Param4> &>(*(it->second));
- }
- }
-template <class Actual, class Interface, class Info, class Param1, class
- Param2, class Param3, class Param4>
-void add(Info info)
- {
- typedef std::list<factory<Interface, Info, Param1, Param2, Param3,
- Param4> > ListType;
- ListType & s = this->get<Interface, Info, Param1, Param2, Param3,
- Param4>();
- factory<Interface, Info, Param1, Param2, Param3, Param4> f(info);
- //f.set_type<Actual>();
- f.set_type_special((Actual*)0);
- s.push_back(f);
- //it->set_type<Actual>();
- }
- template <class Interface, class Info, class Param1, class Param2,
- class Param3, class Param4, class Param5>
-operator std::list<factory<Interface, Info, Param1, Param2, Param3, Param4,
- Param5> > & ()
- {return this->get<Interface, Info, Param1, Param2, Param3, Param4,
- Param5>();}
- template <class Interface, class Info, class Param1, class Param2,
- class Param3, class Param4, class Param5>
-std::list<factory<Interface, Info, Param1, Param2, Param3, Param4,
- Param5> > & get()
- {
- TypeInfo current_type =
- type_info_handler<TypeInfo, factory<Interface, Info, Param1, Param2,
- Param3, Param4, Param5> >::get_class_type();
- typename FactoryMap::iterator it =
- factories_.find(current_type);
-
- if (it == factories_.end())
- {
- factory_container<Interface, Info, Param1, Param2, Param3, Param4,
- Param5> * ret = new factory_container<Interface, Info, Param1,
- Param2, Param3, Param4, Param5>();
- factories_[current_type] = ret;
- return *ret;
- }
- else
- {
- // Change to dynamic if this fails
- return static_cast<factory_container<Interface, Info, Param1, Param2,
- Param3, Param4, Param5> &>(*(it->second));
- }
- }
-template <class Actual, class Interface, class Info, class Param1, class
- Param2, class Param3, class Param4, class Param5>
-void add(Info info)
- {
- typedef std::list<factory<Interface, Info, Param1, Param2, Param3,
- Param4, Param5> > ListType;
- ListType & s = this->get<Interface, Info, Param1, Param2, Param3,
- Param4, Param5>();
- factory<Interface, Info, Param1, Param2, Param3, Param4, Param5> f(info);
- //f.set_type<Actual>();
- f.set_type_special((Actual*)0);
- s.push_back(f);
- //it->set_type<Actual>();
- }
- template <class Interface, class Info, class Param1, class Param2,
- class Param3, class Param4, class Param5, class Param6>
- operator std::list<factory<Interface, Info, Param1, Param2, Param3,
- Param4, Param5, Param6> > & ()
- {
- return this->get<Interface, Info, Param1, Param2, Param3, Param4,
- Param5, Param6>();}
- template <class Interface, class Info, class Param1, class Param2,
- class Param3, class Param4, class Param5, class Param6>
- std::list<factory<Interface, Info, Param1, Param2, Param3, Param4,
- Param5, Param6> > & get()
- {
- TypeInfo current_type = type_info_handler<TypeInfo, factory<Interface,
- Info, Param1,
- Param2, Param3, Param4, Param5, Param6> >::get_class_type();
- typename FactoryMap::iterator it =
- factories_.find(current_type);
-
- if (it == factories_.end())
- {
- factory_container<Interface, Info, Param1, Param2, Param3, Param4,
- Param5, Param6> * ret = new factory_container<Interface, Info,
- Param1, Param2, Param3, Param4, Param5, Param6>();
- factories_[current_type] = ret;
- return *ret;
- }
- else
- {
- // Change to dynamic if this fails
- return static_cast<factory_container<Interface, Info, Param1, Param2,
- Param3, Param4, Param5, Param6> &>(*(it->second));
- }
- }
-template <class Actual, class Interface, class Info, class Param1,
- class Param2, class Param3, class Param4, class Param5, class Param6>
-void add(Info info)
- {
- typedef std::list<factory<Interface, Info, Param1, Param2, Param3,
- Param4, Param5, Param6> > ListType;
- ListType & s = this->get<Interface, Info, Param1, Param2, Param3,
- Param4, Param5, Param6>();
- factory<Interface, Info, Param1, Param2, Param3, Param4, Param5,
- Param6> f(info);
- //f.set_type<Actual>();
- f.set_type_special((Actual*)0);
- s.push_back(f);
- //it->set_type<Actual>();
+ BOOST_EXTENSION_FACTORY_MAP_GET_FUNCTION, _)
+ ~basic_factory_map() {
+ for (typename std::map<TypeInfo, generic_map_holder*>
+ ::iterator it =maps_.begin();
+ it != maps_.end(); ++it) {
+ delete it->second;
+ }
   }
-#endif // BOOST_EXTENSION_USE_PP
+private:
+ class generic_map_holder {
+ public:
+ virtual ~generic_map_holder() {}
+ };
+ template <class T>
+ class map_holder : public generic_map_holder, public T{
+ };
+ std::map<TypeInfo, generic_map_holder*> maps_;
 };
-
 typedef basic_factory_map<default_type_info> factory_map;
 }}
 
-#endif
+#undef BOOST_EXTENSION_FACTORY_MAP_GET_FUNCTION
+
+#endif
\ No newline at end of file

Modified: sandbox/boost/extension/registry.hpp
==============================================================================
--- sandbox/boost/extension/registry.hpp (original)
+++ sandbox/boost/extension/registry.hpp 2007-09-04 23:56:48 EDT (Tue, 04 Sep 2007)
@@ -1,104 +0,0 @@
-/*
- * Boost.Extension / registry:
- * library registration (automates some operations)
- *
- * (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_REGISTRY_HPP
-#define BOOST_EXTENSION_REGISTRY_HPP
-#include <map>
-#include <string>
-#include <boost/extension/counted_factory_map.hpp>
-#include <boost/extension/shared_library.hpp>
-#include <boost/extension/impl/typeinfo.hpp>
-namespace boost{namespace extensions{
-template <class TypeInfo>
-class basic_registry : public basic_counted_factory_map<TypeInfo>
-{
-protected:
- std::map<std::string, std::pair<shared_library, int> > libraries_;
- typedef std::map<std::string, std::pair<shared_library, int> >::iterator
- library_iterator;
-public:
- ~basic_registry() {
- for (library_iterator it = libraries_.begin(); it != libraries_.end();)
- {
- close((it++)->first.c_str());
- }
- }
- bool clear() {
- bool ret_val = false;
- for (library_iterator it = libraries_.begin(); it != libraries_.end();)
- {
- if (!it->second.second) {
- ret_val = true;
- close((it++)->first.c_str());
- }
- else
- {
- ++it;
- }
- }
- return ret_val;
- }
- bool open(const char * library_location, const char * function_name =
- "boost_extension_registry_function") {
- library_iterator it = libraries_.find(library_location);
- if (it == libraries_.end()) {
- it = libraries_.insert(std::make_pair(std::string(library_location),
- std::make_pair(shared_library(library_location,
- false),
- int(0)))).first;
- this->current_library_ = library_location;
- this->current_counter_ = &it->second.second;
- it->second.first.open();
- if (it->second.first.is_open() == false) {
- libraries_.erase(it);
- return false;
- }
- functor<void, counted_factory_map &> load_func =
- it->second.first.get_functor<void, counted_factory_map &>
- (function_name);
- if (load_func.is_valid())
- {
- load_func(*this);
- return true;
- }
- return false;
- }
- return false;
- }
- bool close(const char * library_location) {
- // This removes all of the factories from this library
- library_iterator it = libraries_.find(library_location);
- if (it == libraries_.end())
- return false;
- for (typename basic_counted_factory_map<TypeInfo>::FactoryMap::iterator it
- = this->factories_.begin(); it != this->factories_.end();) {
- if(it->second->remove_library(library_location))
- {
- delete it->second;
- this->factories_.erase(it++);
- }
- else
- {
- ++it;
- }
- }
- it->second.first.close();
- libraries_.erase(it);
- return true;
- }
- size_t num_libraries() {
- return libraries_.size();
- }
-};
-typedef basic_registry<default_type_info> registry;
-}}
-#endif

Modified: sandbox/boost/extension/shared_library.hpp
==============================================================================
--- sandbox/boost/extension/shared_library.hpp (original)
+++ sandbox/boost/extension/shared_library.hpp 2007-09-04 23:56:48 EDT (Tue, 04 Sep 2007)
@@ -1,377 +0,0 @@
-/*
- * 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_LINKED_LIBRARY_HPP
-#define BOOST_EXTENSION_LINKED_LIBRARY_HPP
-#include <boost/extension/impl/library_impl.hpp>
-
-#ifdef BOOST_EXTENSION_USE_BOOST_FUNCTION
-#include <boost/function.hpp>
-#endif
-
-
-#ifdef BOOST_EXTENSION_USE_PP
-
-#include <boost/preprocessor/arithmetic/inc.hpp>
-#include <boost/preprocessor/if.hpp>
-#include <boost/preprocessor/punctuation/comma_if.hpp>
-#include <boost/preprocessor/repetition.hpp>
-
-#ifndef BOOST_EXTENSION_MAX_FUNCTOR_PARAMS
-#define BOOST_EXTENSION_MAX_FUNCTOR_PARAMS 6
-#endif
-
-/// functor template specialization macro.
-#define BOOST_EXTENSION_FUNCTOR_CLASS_PREFIX(Z, N, _) \
-template<class ReturnValue BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, \
- class Param) > \
-class functor<ReturnValue BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > { \
- protected:
-/**/
-
-#define BOOST_EXTENSION_FUNCTOR_CLASS_SUFFIX(Z, N, _) \
- FunctionType func_; \
- public: \
- bool is_valid(){return func_ != 0;} \
- functor(FunctionType func) \
- : func_(func) {} \
- functor(generic_function_ptr func) \
- : func_(FunctionType((ReturnValue (*)(BOOST_PP_ENUM_PARAMS(N, \
- Param))) func)) {} \
- ReturnValue operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, Param, p)) { \
- return func_(BOOST_PP_ENUM_PARAMS(N, p)); \
- } \
-};
-/**/
-
-
-#ifdef BOOST_EXTENSION_USE_BOOST_FUNCTION
-
-#define BOOST_EXTENSION_FUNCTOR_CLASS(Z, N, _) \
- BOOST_EXTENSION_FUNCTOR_CLASS_PREFIX(Z, N, _) \
- typedef BOOST_PP_CAT(boost::function, N) \
- <ReturnValue BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, Param) > \
- FunctionType; \
- BOOST_EXTENSION_FUNCTOR_CLASS_SUFFIX(Z, N, _)
-/**/
-
-#else
-
-#define BOOST_EXTENSION_FUNCTOR_CLASS(Z, N, _) \
- BOOST_EXTENSION_FUNCTOR_CLASS_PREFIX(Z, N, _) \
- typedef ReturnValue (*FunctionType)(BOOST_PP_ENUM_PARAMS(N, Param)); \
- BOOST_EXTENSION_FUNCTOR_CLASS_SUFFIX(Z, N, _)
-/**/
-
-#endif // ifdef BOOST_EXTENSION_USE_BOOST_FUNCTION
-#endif // ifdef BOOST_EXTENSION_USE_PP
-
-
-
-namespace boost{namespace extensions{
-
-#ifdef BOOST_EXTENSION_USE_PP
-
-/// Declaration of functor class template.
-template <class ReturnValue,
- BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_INC(\
- BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), class Param, void)>\
- class functor;
-
-/// Functor template specializations.
-BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_FUNCTOR_CLASS, _)
-
-#undef BOOST_EXTENSION_FUNCTOR_CLASS
-#else
-
-template <class ReturnValue, class Param1 = void, class Param2 = void,
- class Param3 = void, class Param4 = void, class Param5 = void,
- class Param6 = void>
-class functor
-{
-protected:
-#ifdef BOOST_EXTENSION_USE_BOOST_FUNCTION
- typedef boost::function6<ReturnValue, Param1, Param2, Param3,
- Param4, Param5, Param6> FunctionType;
-#else
- typedef ReturnValue (*FunctionType)(Param1, Param2, Param3, Param4,
- Param5, Param6);
-#endif // BOOST_EXTENSION_USE_BOOST_FUNCTION
- FunctionType func_;
-public:
- bool is_valid(){return func_ != 0;}
- functor(FunctionType func)
- :func_(func)
- {}
- functor(generic_function_ptr func)
- :func_(FunctionType((ReturnValue (*)(Param1, Param2, Param3, Param4,
- Param5, Param6)) func))
- {}
- ReturnValue operator()(Param1 p1, Param2 p2, Param3 p3, Param4 p4,
- Param5 p5, Param6 p6)
- {
- return func_(p1, p2, p3, p4, p5, p6);
- }
-};
-
-template <class ReturnValue, class Param1, class Param2, class Param3,
- class Param4, class Param5>
-class functor<ReturnValue, Param1, Param2, Param3, Param4, Param5>
-{
-protected:
-#ifdef BOOST_EXTENSION_USE_BOOST_FUNCTION
- typedef boost::function5<ReturnValue, Param1, Param2, Param3,
- Param4, Param5> FunctionType;
-#else
- typedef ReturnValue (*FunctionType)(Param1, Param2, Param3, Param4, Param5);
-#endif // BOOST_EXTENSION_USE_BOOST_FUNCTION
- FunctionType func_;
-public:
- bool is_valid(){return func_ != 0;}
- functor(FunctionType func)
- :func_(func)
- {}
- functor(generic_function_ptr func)
- :func_(FunctionType((ReturnValue (*)(Param1, Param2, Param3,
- Param4, Param5)) func))
- {}
- ReturnValue operator()(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)
- {
- return func_(p1, p2, p3, p4, p5);
- }
-};
-
-template <class ReturnValue, class Param1, class Param2, class Param3,
- class Param4>
-class functor<ReturnValue, Param1, Param2, Param3, Param4>
-{
-protected:
-#ifdef BOOST_EXTENSION_USE_BOOST_FUNCTION
- typedef boost::function4<ReturnValue, Param1, Param2, Param3,
- Param4> FunctionType;
-#else
- typedef ReturnValue (*FunctionType)(Param1, Param2, Param3, Param4);
-#endif // BOOST_EXTENSION_USE_BOOST_FUNCTION
- FunctionType func_;
-public:
- bool is_valid(){return func_ != 0;}
- functor(FunctionType func)
- :func_(func)
- {}
- functor(generic_function_ptr func)
- :func_(FunctionType((ReturnValue (*)(Param1, Param2, Param3,
- Param4)) func))
- {}
- ReturnValue operator()(Param1 p1, Param2 p2, Param3 p3, Param4 p4)
- {
- return func_(p1, p2, p3, p4);
- }
-};
-
-template <class ReturnValue, class Param1, class Param2, class Param3>
-class functor<ReturnValue, Param1, Param2, Param3>
-{
-protected:
-#ifdef BOOST_EXTENSION_USE_BOOST_FUNCTION
- typedef boost::function3<ReturnValue, Param1, Param2, Param3> FunctionType;
-#else
- typedef ReturnValue (*FunctionType)(Param1, Param2, Param3);
-#endif // BOOST_EXTENSION_USE_BOOST_FUNCTION
- FunctionType func_;
-public:
- bool is_valid(){return func_ != 0;}
- functor(FunctionType func)
- :func_(func)
- {}
- functor(generic_function_ptr func)
- :func_(FunctionType((ReturnValue (*)(Param1, Param2, Param3)) func))
- {}
- ReturnValue operator()(Param1 p1, Param2 p2, Param3 p3)
- {
- return func_(p1, p2, p3);
- }
-};
-
-template <class ReturnValue, class Param1, class Param2>
-class functor<ReturnValue, Param1, Param2>
-{
-protected:
-#ifdef BOOST_EXTENSION_USE_BOOST_FUNCTION
- typedef boost::function2<ReturnValue, Param1, Param2> FunctionType;
-#else
- typedef ReturnValue (*FunctionType)(Param1, Param2);
-#endif // BOOST_EXTENSION_USE_BOOST_FUNCTION
- FunctionType func_;
-public:
- bool is_valid(){return func_ != 0;}
- functor(FunctionType func)
- :func_(func)
- {}
- functor(generic_function_ptr func)
- :func_(FunctionType((ReturnValue (*)(Param1, Param2)) func))
- {}
- ReturnValue operator()(Param1 p1, Param2 p2)
- {
- return func_(p1, p2);
- }
-};
-
-template <class ReturnValue, class Param1>
-class functor<ReturnValue, Param1>
-{
-protected:
-#ifdef BOOST_EXTENSION_USE_BOOST_FUNCTION
- typedef boost::function1<ReturnValue, Param1> FunctionType;
-#else
- typedef ReturnValue (*FunctionType)(Param1);
-#endif // BOOST_EXTENSION_USE_BOOST_FUNCTION
-
- FunctionType func_;
-public:
- bool is_valid(){return func_ != 0;}
- functor(FunctionType func)
- :func_(func)
- {}
- functor(generic_function_ptr func)
- :func_(FunctionType((ReturnValue (*)(Param1)) func))
- {}
- ReturnValue operator()(Param1 p1)
- {
- return func_(p1);
- }
-};
-
-template <class ReturnValue>
-class functor<ReturnValue>
-{
-protected:
-#ifdef BOOST_EXTENSION_USE_BOOST_FUNCTION
- typedef boost::function0<ReturnValue> FunctionType;
-#else
- typedef ReturnValue (*FunctionType)();
-#endif // BOOST_EXTENSION_USE_BOOST_FUNCTION
- FunctionType func_;
-public:
- bool is_valid(){return func_ != 0;}
- functor(FunctionType func)
- :func_(func)
- {}
- functor(generic_function_ptr func)
- :func_(FunctionType((ReturnValue (*)()) func))
- {}
- ReturnValue operator()()
- {
- return func_();
- }
-};
-
-#endif // ifdef BOOST_EXTENSION_USE_PP
-
-
-class shared_library
-{
-protected:
- std::string location_;
- library_handle handle_;
- bool auto_close_;
-public:
- bool is_open(){return handle_ != 0;}
- static bool is_linkable_library(const char * file_name) {
- return is_library(file_name);
- }
- bool open(){return (handle_ = load_shared_library(location_.c_str())) != 0;}
- bool close(){return close_shared_library(handle_);}
-
-#ifdef BOOST_EXTENSION_USE_PP
-
-#define BOOST_EXTENSION_GET_FUNCTOR_METHOD(Z, N, _) \
- template <class ReturnValue BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, class Param) > \
- functor<ReturnValue BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param) > \
- get_functor(const char * function_name) \
- { \
- return functor<ReturnValue BOOST_PP_COMMA_IF(N) \
- BOOST_PP_ENUM_PARAMS(N, Param)> \
- (get_function(handle_, function_name)); \
- } \
- /**/
-
- BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_EXTENSION_MAX_FUNCTOR_PARAMS), \
- BOOST_EXTENSION_GET_FUNCTOR_METHOD, _)
-
-#undef BOOST_EXTENSION_GET_FUNCTOR_METHOD
-#else
- template <class ReturnValue>
- functor<ReturnValue>
- get_functor(const char * function_name)
- {
- return functor<ReturnValue>
- (get_function(handle_, function_name));
- }
- template <class ReturnValue, class Param1>
- functor<ReturnValue, Param1>
- get_functor(const char * function_name)
- {
- return functor<ReturnValue, Param1>
- (get_function(handle_, function_name));
- }
- template <class ReturnValue, class Param1, class Param2>
- functor<ReturnValue, Param1, Param2>
- get_functor(const char * function_name)
- {
- return functor<ReturnValue, Param1, Param2>
- (get_function(handle_, function_name));
- }
- template <class ReturnValue, class Param1, class Param2, class Param3>
- functor<ReturnValue, Param1, Param2, Param3>
- get_functor(const char * function_name)
- {
- return functor<ReturnValue, Param1, Param2, Param3>
- (get_function(handle_, function_name));
- }
- template <class ReturnValue, class Param1, class Param2, class Param3,
- class Param4>
- functor<ReturnValue, Param1, Param2, Param3, Param4>
- get_functor(const char * function_name)
- {
- return functor<ReturnValue, Param1, Param2, Param3, Param4>
- (get_function(handle_, function_name));
- }
- template <class ReturnValue, class Param1, class Param2, class Param3,
- class Param4, class Param5>
- functor<ReturnValue, Param1, Param2, Param3, Param4, Param5>
- get_functor(const char * function_name)
- {
- return functor<ReturnValue, Param1, Param2, Param3, Param4, Param5>
- (get_function(handle_, function_name));
- }
- template <class ReturnValue, class Param1, class Param2, class Param3,
- class Param4, class Param5, class Param6>
- functor<ReturnValue, Param1, Param2, Param3, Param4, Param5, Param6>
- get_functor(const char * function_name)
- {
- return functor<ReturnValue, Param1, Param2, Param3, Param4, Param5,
- Param6>
- (get_function(handle_, function_name));
- }
-#endif // BOOST_EXTENSION_USE_PP
-
-shared_library(const char * location, bool auto_close = false)
- :location_(location), handle_(0), auto_close_(auto_close){}
-};
-}}
-
-
-#endif

Modified: sandbox/libs/extension/test/Jamfile.v2
==============================================================================
--- sandbox/libs/extension/test/Jamfile.v2 (original)
+++ sandbox/libs/extension/test/Jamfile.v2 2007-09-04 23:56:48 EDT (Tue, 04 Sep 2007)
@@ -14,7 +14,6 @@
 project
     : requirements
       <library>$(BOOST_ROOT)libs/test/build//boost_unit_test_framework/<link>shared
- # <source>auto_test_main.cpp
       <include>../../../
       <include>$(BOOST_ROOT)
       <define>BOOST_TEST_NO_AUTO_LINK=1
@@ -28,16 +27,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 hello_world_test.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 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/construction.cpp
==============================================================================
--- sandbox/libs/extension/test/construction.cpp (original)
+++ sandbox/libs/extension/test/construction.cpp 2007-09-04 23:56:48 EDT (Tue, 04 Sep 2007)
@@ -9,28 +9,130 @@
  * See http://www.boost.org/ for latest version.
  */
 
-#include <boost/extension/factory_map.hpp>
+
 #include <boost/extension/factory.hpp>
-#include <boost/extension/shared_library.hpp>
+#include <boost/extension/factory_map.hpp>
 #define BOOST_TEST_MAIN
 #include <boost/test/unit_test.hpp>
+#include <memory>
+#include <map>
 
+using namespace boost::extensions;
 
 
-using namespace boost::extensions;
+class Automobile {
+public:
+ virtual ~Automobile() {}
+ Automobile() {}
+ virtual int getSpeed() {return 45;}
+};
+
+class Van : virtual public Automobile {
+public:
+ virtual ~Van() {}
+ Van() {}
+ virtual int getSpeed() {return 35;}
+};
+
+class PickupTruck : virtual public Automobile {
+public:
+ virtual ~PickupTruck() {}
+ PickupTruck() {}
+ virtual int getSpeed() {return 50;}
+};
+
+class Racecar : virtual public Automobile {
+public:
+ virtual ~Racecar() {}
+ Racecar(int speed) : speed_(speed) {}
+ virtual int getSpeed() {return speed_;}
+private:
+ int speed_;
+};
 
-BOOST_AUTO_TEST_CASE(zone_construction)
+class RacingVan : public Racecar, public Van
 {
- factory_map z;
+public:
+ virtual ~RacingVan() {}
+ RacingVan() : Racecar(120) {}
+ virtual int getSpeed() {return Racecar::getSpeed();}
+};
 
+
+
+
+BOOST_AUTO_TEST_CASE(factory_argless) {
+ factory<Automobile> f;
+ f.set<PickupTruck>();
+ BOOST_CHECK(f.is_valid());
+ std::auto_ptr<Automobile> pickup(f.create());
+ BOOST_CHECK_EQUAL(pickup->getSpeed(), 50);
 }
-BOOST_AUTO_TEST_CASE(factory_construction)
+
+BOOST_AUTO_TEST_CASE(map_argless)
 {
- //factory f;
+ std::map<std::string, factory<Automobile> > m;
+ m["A van"].set<Van>();
+ m["A basic automobile"].set<Automobile>();
+ m["A pickup truck"].set<PickupTruck>();
+ std::auto_ptr<Automobile> van(m["A van"].create());
+ BOOST_CHECK_EQUAL(van->getSpeed(), 35);
+ BOOST_CHECK_EQUAL
+ (m["An unloaded car!"].create(),
+ (Automobile*)0);
+}
 
+template <>
+Automobile * create_function<Automobile, Racecar>::create()
+{
+ return new Racecar(101);
 }
-BOOST_AUTO_TEST_CASE(linked_library_construction)
+
+BOOST_AUTO_TEST_CASE(factory_template)
 {
- shared_library l((std::string("liblocal") + ".extension").c_str());
+ factory<Automobile> f;
+ f.set<Racecar>();
+ BOOST_CHECK(f.is_valid());
+ std::auto_ptr<Automobile> racecar(f.create());
+ BOOST_CHECK_EQUAL(racecar->getSpeed(), 101);
+}
 
+BOOST_AUTO_TEST_CASE(factory_map_argless)
+{
+ factory_map m;
+ m.get<Automobile, std::string>()["A pickup truck"].set<PickupTruck>();
+ m.get<Automobile, std::string>()["A racing van!"].set<RacingVan>();
+ std::auto_ptr<Automobile> pickup
+ (m.get<Automobile, std::string>()["A pickup truck"].create());
+ BOOST_CHECK_EQUAL(pickup->getSpeed(), 50);
+ std::auto_ptr<Automobile> racingVan
+ (m.get<Automobile, std::string>()["A racing van!"].create());
+ BOOST_CHECK_EQUAL(racingVan->getSpeed(), 120);
+ std::auto_ptr<Automobile> car_ptr
+ (m.get<Automobile, std::string>()["A nonexistent car!"].create());
+ BOOST_CHECK_EQUAL(car_ptr.get(), (Automobile*)0);
 }
+/*
+BOOST_AUTO_TEST_CASE(registry_argless2)
+{
+ registry r;
+ r.add<PickupTruck, Automobile, std::string>("A pickup truck");
+ r.add<RacingVan, Automobile, std::string>("A racing van!");
+ factory_map<Automobile, std::string> & m1(r.get<Automobile, std::string>());
+ factory_map<Automobile, std::string> & m2(r.get());
+ BOOST_CHECK_EQUAL(m1.size(), 2);
+}
+
+BOOST_AUTO_TEST_CASE(counted_registry_argless)
+{
+ count_registry r;
+ r.add<PickupTruck, Automobile, std::string>("A pickup truck");
+ r.add<RacingVan, Automobile, std::string>("A racing van!");
+ {
+ BOOST_CHECK_EQUAL(r.instances(), 0);
+ std::auto_ptr<Automobile> pickup =
+ r.create<Automobile, std::string>("A pickup truck");
+ BOOST_CHECK_EQUAL(r.instances(), 1);
+ }
+ BOOST_CHECK_EQUAL(r.instances(), 0);
+}*/


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