std::ofstream out_stream( argv[ 1 ] );
// Write include section
- out_stream
- << "#include <map>" << std::endl
- << "#include <set>" << std::endl;
for( int i = 2; i < argc; ++i )
out_stream << "#include \"" << argv[ i ] << "\"" <<std::endl;
// Write init/finish section
- out_stream
- << std::endl
- << "void __attribute__ ((constructor)) _initialize( )" << std::endl
- << "{" << std::endl << "}" << std::endl << std::endl
- << "void __attribute__ ((destructor)) _finalize( )" << std::endl
- << "{" << std::endl << "}" << std::endl << std::endl;
+ /* TODO:
+ out_stream
+ << std::endl
+ << "void __attribute__ ((constructor)) _initialize( )" << std::endl
+ << "{" << std::endl << "}" << std::endl << std::endl
+ << "void __attribute__ ((destructor)) _finalize( )" << std::endl
+ << "{" << std::endl << "}" << std::endl;
+ */
// Write access function
out_stream
- << "extern \"C\" std::map< std::string, std::set< std::string > > "
+ << std::endl
+ << "extern \"C\" __declspec(dllexport) const char* "
<< "cpPlugins_LoadedFilters( )" << std::endl << "{" << std::endl
- << " std::map< std::string, std::set< std::string > > classes;"
- << std::endl;
+ << " static std::string classes;"
+ << std::endl
+ << " classes = \"\";" << std::endl;
for( auto iIt = info.begin( ); iIt != info.end( ); ++iIt )
for( auto jIt = iIt->second.begin( ); jIt != iIt->second.end( ); ++jIt )
out_stream
- << " classes[ \"" << iIt->first
- << "\" ].insert( \"" << jIt->first << "\" );" << std::endl;
+ << " classes += std::string( \"" << iIt->first
+ << ":" << jIt->first << ";\" );" << std::endl;
out_stream
- << " return( classes );" << std::endl
+ << " return( classes.c_str( ) );" << std::endl
<< "}" << std::endl << std::endl;
// Write creators
for( auto jIt = iIt->second.begin( ); jIt != iIt->second.end( ); ++jIt )
{
out_stream
- << "extern \"C\" cpPlugins::ProcessObject::Pointer "
+ << "extern \"C\" __declspec(dllexport) void* "
<< iIt->first << "_" << jIt->first
<< "( )" << std::endl << "{" << std::endl
- << std::endl
- << " cpPlugins::ProcessObject::Pointer p;" << std::endl
- << " " << jIt->second << "::" << jIt->first << "::Pointer f = "
- << jIt->second << "::" << jIt->first << "::New( );" << std::endl
- << " p = f.GetPointer( );" << std::endl << " return( p );"
+ << " static " << jIt->second << "::" << jIt->first << "::Pointer f;" << std::endl
+ << " f = " << jIt->second << "::" << jIt->first << "::New( );" << std::endl
+ << " return( &f );"
<< std::endl;
out_stream
<< "}" << std::endl << std::endl;