plugin_wrapper.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_PLUGIN_WRAPPER_VP_2004_08_25
00007 #define BOOST_PLUGIN_WRAPPER_VP_2004_08_25
00008 
00009 #include <boost/mpl/list.hpp>
00010 #include <boost/shared_ptr.hpp>
00011 
00012 #include <iostream>
00013 
00014 namespace utilmm { namespace plugin {
00015 
00016     template<class Wrapped, class Parameters>
00017     struct plugin_wrapper {};
00018 
00019     struct dll_handle_holder {
00020         dll_handle_holder(dll_handle dll) : m_dll(dll) {}
00021         ~dll_handle_holder()
00022         {
00023             std::cout << "DLL handle is dying\n";
00024         }
00025     private:
00026         dll_handle m_dll;
00027     };
00028 
00029     template<class Wrapped>
00030     struct plugin_wrapper<Wrapped, boost::mpl::list<> > 
00031         : public dll_handle_holder, public Wrapped {        
00032         plugin_wrapper(dll_handle dll) : dll_handle_holder(dll) {}
00033 
00034     };
00035 
00036     template<class Wrapped, class A1>
00037     struct plugin_wrapper<Wrapped, boost::mpl::list<A1> > 
00038         : public dll_handle_holder, Wrapped {        
00039         plugin_wrapper(dll_handle dll, A1 a1) 
00040         : dll_handle_holder(dll), Wrapped(a1) {}
00041 
00042     };
00043 
00044     template<class Wrapped, class A1, class A2>
00045     struct plugin_wrapper<Wrapped, boost::mpl::list<A1, A2> > 
00046         : public dll_handle_holder, Wrapped {        
00047         plugin_wrapper(dll_handle dll, A1 a1, A2 a2) : 
00048         dll_handle_holder(dll), Wrapped(a1, a2) {
00049             std::cout << "plugin_wrapper: " << a1 << " : " << a2 << "\n";
00050         }
00051     };
00052 
00053 }}
00054 
00055 #endif


utilmm
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Wed Sep 16 2015 07:05:43