From: stephan b. <sg...@us...> - 2004-12-25 16:37:56
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31576/include/pclasses/Plugin Modified Files: Plugin.h Log Message: More tweaking of the interface. Index: Plugin.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Plugin/Plugin.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Plugin.h 25 Dec 2004 02:44:57 -0000 1.6 +++ Plugin.h 25 Dec 2004 16:37:47 -0000 1.7 @@ -16,50 +16,6 @@ namespace P { namespace Plugin { - - - /** - An internal helper type to clean up a list of pointers to - objects. - - ContainterT must be compatible with list<T *> - and calling 'delete Tobj' must be well-behaved. - */ - template <typename ContainterT> - struct PluginCleaner : public ::P::NonCopyable - { - typedef ContainterT ListType; - PluginCleaner() - { - } - - /** - Does nothing. - */ - ~PluginCleaner() throw() - { - // Reminder: System::openSharedLib() owns them! -// typename ListType::iterator it = m_list.begin(); -// while( m_list.end() != it ) -// { -// delete( (*it) ); -// ++it; -// } -// m_list.clear(); - } - - /** - Returns this object's container. - */ - ListType & container() - { - return this->m_list; - } - - private: - ListType m_list; - }; - /** @@ -81,6 +37,8 @@ typedef InterfaceT InterfaceType; typedef ::P::NamedTypeFactory< InterfaceT > ParentType; typedef PluginManager<InterfaceType> ThisType; + typedef typename ParentType::factory_func_type factory_func_type; + typedef typename ParentType::ResultType ResultType; /** Creates a PluginManager with a default search path @@ -93,21 +51,12 @@ } /** - When a PluginManager goes out of scope it deletes - all SharedLib objects it opened via - addPlugin(). The exact behaviour of this depends on - the platform-specific SharedLib implementation. It - is never safe to use symbols from a DLL once the - DLL has been closed, but it is also impossible for - us to track every single dll-registered - symbol. Thus the safest thing to do is never use - standlone PluginManager instances, and use the one - available via instance() instead. + Does nothing. */ virtual ~PluginManager() throw() { - // reminder: m_holder goes out of scope - // and cleans up it's container() now... + // reminder: openSharedLib() owns + // the objects in m_holder. } @@ -124,7 +73,7 @@ The caller owns the returned object, which may be 0. */ virtual - InterfaceType * create( const std::string & feature ) + ResultType create( const std::string & feature ) { InterfaceType * ret = ParentType::create( feature ); if( ret ) return ret; @@ -189,7 +138,7 @@ } ::P::System::SharedLib * shl = ::P::System::openSharedLib( fn ); //CERR << "Opened fn="<<fn<<"\n"; - this->m_holder.container().push_back( shl ); + this->m_holder.push_back( shl ); return shl; } @@ -240,12 +189,12 @@ */ PluginList & sharedLibs() { - return this->m_holder.container(); + return this->m_holder; } const PluginList & sharedLibs() const { - return this->m_holder.container(); + return this->m_holder; } /** @@ -267,7 +216,7 @@ this->m_path.addPath( PCLASSES_LIB_DIR ); this->m_path.addExtension(std::string(".")+std::string(PCLASSES_PLATFORM_SHARED_LIB_EXTENSION)); } - PluginCleaner<PluginList> m_holder; + PluginList m_holder; ::P::System::PathFinder m_path; // ^^^^ todo: consider making this static. }; |