concrete_factory.hh
Go to the documentation of this file.
00001 // Copyright Vladimir Prus 2004.
00002 // Distributed under the Boost Software License, Version 1.0.
00003 // (See accompanying file LICENSE_1_0.txt
00004 // or copy at http://www.boost.org/LICENSE_1_0.txt)
00005 
00006 #ifndef BOOST_CONCRETE_FACTORY_VP_2004_08_25
00007 #define BOOST_CONCRETE_FACTORY_VP_2004_08_25
00008 
00009 #include <utilmm/plugin/abstract_factory.hh>
00010 #include <utilmm/plugin/plugin_wrapper.hh>
00011 
00012 #include <iostream>
00013 
00014 namespace utilmm { namespace plugin {
00015 
00016     template<class BasePlugin, class Concrete, class Base, class Parameters>
00017     struct concrete_factory_item {                
00018     };
00019 
00020     template<class BasePlugin, class Concrete, class Base>
00021     struct concrete_factory_item<BasePlugin, Concrete, Base, boost::mpl::list<> > 
00022         : public Base
00023     {                
00024         BasePlugin* create(dll_handle dll)
00025         {
00026             std::cout << "CF: 0 args\n";
00027             return new plugin_wrapper<Concrete, boost::mpl::list<> >(dll);
00028         }
00029     };
00030 
00031     template<class BasePlugin, class Concrete, class Base, class A1>
00032     struct concrete_factory_item<BasePlugin, Concrete, Base, boost::mpl::list<A1> > 
00033         : public Base
00034     {                
00035         BasePlugin* create(dll_handle dll, A1 a1)
00036         {
00037             std::cout << "CF: 1 args\n";
00038             return new plugin_wrapper<Concrete, boost::mpl::list<A1> >(dll, a1);
00039         }
00040     };
00041 
00042     template<class BasePlugin, class Concrete, class Base, class A1, class A2>
00043     struct concrete_factory_item<BasePlugin, Concrete, Base, boost::mpl::list<A1, A2> > 
00044         : public Base
00045     {                
00046         BasePlugin* create(dll_handle dll, A1 a1, A2 a2)
00047         {
00048             std::cout << "CF: 2 args\n";
00049             return new plugin_wrapper<Concrete, boost::mpl::list<A1, A2> >(dll, a1, a2);
00050         }
00051     };
00052     
00053     using namespace boost::mpl::placeholders;
00054 
00055     template<class BasePlugin, class Concrete>
00056     struct concrete_factory :
00057         public boost::mpl::inherit_linearly<
00058         typename virtual_constructors<BasePlugin>::type,
00059         concrete_factory_item<BasePlugin, Concrete, _, _>,
00060         abstract_factory<BasePlugin> >::type
00061     {
00062     };    
00063 
00064     
00065 
00066     
00067 
00068 
00069 }}
00070 
00071 #endif


utilmm
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Thu Jan 2 2014 11:38:31