#include <cpPlugins/Interface.h>
#ifdef cpPlugins_SYS_WINDOWS
+# include <Windows.h>
#else // cpPlugins_SYS_WINDOWS
# include <dlfcn.h>
#endif // cpPlugins_SYS_WINDOWS
return( this->m_Filters );
}
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::
+LoadConfiguration( const std::string& filename )
+{
+ std::ifstream in( filename.c_str( ) );
+ if( !in )
+ return( false );
+
+ this->UnloadAll( );
+ std::string line;
+ while( std::getline( in, line ) )
+ {
+ try
+ {
+ this->LoadPluginFile( line );
+ }
+ catch( ... )
+ {
+ // Do nothing
+
+ } // yrt
+
+ } // elihw
+ return( true );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::
+SaveConfiguration( const std::string& filename ) const
+{
+ std::ofstream out( filename.c_str( ) );
+ if( !out )
+ return( false );
+ auto dIt = this->m_DynLibraries.begin( );
+ for( ; dIt != this->m_DynLibraries.end( ); ++dIt )
+ out << dIt->first << std::endl;
+ out.close( );
+}
+
// -------------------------------------------------------------------------
void cpPlugins::Interface::
LoadPluginFile( const std::string& filename )
{
void* hnd = NULL;
#ifdef cpPlugins_SYS_WINDOWS
- // TODO:
+ hnd = ::LoadLibraryA( fname.c_str( ) );
#else // cpPlugins_SYS_WINDOWS
hnd = dlopen( fname.c_str( ), RTLD_NOW | RTLD_GLOBAL );
dlerror( );
TFilters cpPlugins::Interface::
_DLGetFilters( void* hnd )
{
+ typedef const TFilters ( *f_t )( );
+
TFilters filters;
#ifdef cpPlugins_SYS_WINDOWS
- // TODO:
+ auto f = ( f_t )(
+ ::GetProcAddress( ( HMODULE )hnd, "cpPlugins_LoadedFilters" )
+ );
+ std::cout << f << std::endl;
#else // cpPlugins_SYS_WINDOWS
- typedef const TFilters ( *f_t )( );
auto f = ( f_t ) dlsym( hnd, "cpPlugins_LoadedFilters" );
const char* err = dlerror( );
if( err != NULL )
);
} // fi
- filters = f( );
#endif // cpPlugins_SYS_WINDOWS
+ filters = f( );
return( filters );
}
_DLClose( void* hnd )
{
#ifdef cpPlugins_SYS_WINDOWS
- // TODO:
+ ::FreeLibrary( ( HMODULE )hnd );
#else // cpPlugins_SYS_WINDOWS
dlclose( hnd );
#endif // cpPlugins_SYS_WINDOWS