X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2Fbash%2FcpPlugins_createHost.cxx;h=d75292774d2501b52a0f5511355201f1ca7a98c1;hb=da7cadeecad8bf04551591e9cb9e86977e2cbb47;hp=6f8214d1bb828c1f0f0d9b0f11d92a21dce4aa7e;hpb=b23970017af98ef6617ddf40f225d4d15fa65854;p=cpPlugins.git diff --git a/appli/bash/cpPlugins_createHost.cxx b/appli/bash/cpPlugins_createHost.cxx index 6f8214d..d752927 100644 --- a/appli/bash/cpPlugins_createHost.cxx +++ b/appli/bash/cpPlugins_createHost.cxx @@ -1,6 +1,7 @@ #include #include #include +#include #include // ------------------------------------------------------------------------- @@ -25,7 +26,7 @@ std::string GetFileName( const std::string& path ) std::size_t pos = fname.find_last_of( "." ); if( pos != std::string::npos ) fname = fname.substr( 0, pos ); - + return( fname ); } @@ -53,18 +54,46 @@ int main( int argc, char* argv[] ) } // fi output_code << "#include " << std::endl; + output_code + << "#include " + << std::endl; for( int i = 3; i < argc; ++i ) output_code << "#include \"" << argv[ i ] << "\"" << std::endl; + output_code << std::endl; + + std::istringstream nspaces( argv[ 2 ] ); + std::string nspace; + unsigned int number_of_nspaces = 0; + while( std::getline( nspaces, nspace, ':' ) ) + { + if( nspace != "" ) + { + output_code << "namespace " << nspace << std::endl << "{" << std::endl; + number_of_nspaces++; + + } // fi + + } // elihw + + for( int i = 3; i < argc; ++i ) + output_code + << "CPPLUGINS_INHERIT_PROVIDER( " + << GetFileName( argv[ i ] ) << " );" << std::endl; + + for( unsigned int i = 0; i < number_of_nspaces; ++i ) + output_code << "}" << std::endl; + output_code << std::endl; + + output_code - << std::endl << "PLUMA_CONNECTOR" << std::endl << "bool connect( pluma::Host& host )" << std::endl - << "{" << std::endl - << " using namespace " << argv[ 2 ] << ";" << std::endl; + << "{" << std::endl; for( int i = 3; i < argc; ++i ) output_code << " host.add( new " + << argv[ 2 ] << "::" << GetFileName( argv[ i ] ) << "Provider( ) );" << std::endl; @@ -73,6 +102,8 @@ int main( int argc, char* argv[] ) << " return( true );" << std::endl << "}" << std::endl; + output_code << std::endl << "// eof - $RCSfile$" << std::endl << std::endl; + // Finish output_code.close( ); return( 0 );