1 #include <cpPlugins/Interface/Interface.h>
3 // -------------------------------------------------------------------------
4 cpPlugins::Interface::Interface::
7 this->m_Pluma.acceptProviderType< ObjectProvider >( );
10 // -------------------------------------------------------------------------
11 cpPlugins::Interface::Interface::
17 // -------------------------------------------------------------------------
18 cpPlugins::Interface::Interface::
19 TClasses& cpPlugins::Interface::Interface::
22 return( this->m_Classes );
25 // -------------------------------------------------------------------------
26 const cpPlugins::Interface::Interface::
27 TClasses& cpPlugins::Interface::Interface::
30 return( this->m_Classes );
33 // -------------------------------------------------------------------------
34 cpPlugins::Interface::Object::Pointer cpPlugins::Interface::Interface::
35 CreateObject( const std::string& name ) const
37 TClassesIterator cIt = this->m_Classes.find( name );
38 if( cIt != this->m_Classes.end( ) )
40 ObjectProvider* provider =
41 dynamic_cast< ObjectProvider* >( this->m_Providers[ cIt->second ] );
42 if( provider != NULL )
43 return( provider->create( ) );
49 // -------------------------------------------------------------------------
50 cpPlugins::Interface::ProcessObject::Pointer
51 cpPlugins::Interface::Interface::
52 CreateProcessObject( const std::string& name ) const
54 cpPlugins::Interface::Object::Pointer o = this->CreateObject( name );
55 cpPlugins::Interface::ProcessObject::Pointer p =
56 dynamic_cast< cpPlugins::Interface::ProcessObject* >( o.GetPointer( ) );
60 // -------------------------------------------------------------------------
61 bool cpPlugins::Interface::Interface::
62 Load( const std::string& path )
67 ret = this->m_Pluma.load( path );
69 this->_LoadClasses( );
79 // -------------------------------------------------------------------------
80 bool cpPlugins::Interface::Interface::
81 Load( const std::string& folder, const std::string& name )
86 ret = this->m_Pluma.load( folder, name );
88 this->_LoadClasses( );
98 // -------------------------------------------------------------------------
99 int cpPlugins::Interface::Interface::
100 LoadFromFolder( const std::string& folder, bool r )
105 ret = this->m_Pluma.loadFromFolder( folder, r );
107 this->_LoadClasses( );
117 // -------------------------------------------------------------------------
118 bool cpPlugins::Interface::Interface::
119 Unload( const std::string& name )
124 ret = this->m_Pluma.unload( name );
127 this->m_Providers.clear( );
128 this->m_Classes.clear( );
129 this->_LoadClasses( );
141 // -------------------------------------------------------------------------
142 void cpPlugins::Interface::Interface::
147 this->m_Pluma.unloadAll( );
154 this->m_Providers.clear( );
155 this->m_Classes.clear( );
158 // -------------------------------------------------------------------------
159 void cpPlugins::Interface::Interface::
160 GetLoadedPlugins( std::vector< const std::string* >& names ) const
162 this->m_Pluma.getLoadedPlugins( names );
165 // -------------------------------------------------------------------------
166 bool cpPlugins::Interface::Interface::
167 IsLoaded( const std::string& name ) const
169 return( this->m_Pluma.isLoaded( name ) );
172 // -------------------------------------------------------------------------
173 void cpPlugins::Interface::Interface::
176 this->m_Providers.clear( );
177 this->m_Classes.clear( );
178 this->m_Pluma.getProviders( this->m_Providers );
180 // Get reader provider
181 for( unsigned int i = 0; i < this->m_Providers.size( ); ++i )
183 Object::Pointer dummy = this->m_Providers[ i ]->create( );
184 this->m_Classes[ dummy->GetClassName( ) ] = i;