]> Creatis software - cpPlugins.git/blob - appli/bash/cpPlugins_createHost.cxx
...
[cpPlugins.git] / appli / bash / cpPlugins_createHost.cxx
1 #include <fstream>
2 #include <iostream>
3 #include <string>
4
5 #include <boost/filesystem/path.hpp>
6
7 int main( int argc, char* argv[] )
8 {
9   // Open file
10   if( argc < 4 )
11   {
12     std::cerr
13       << "Usage: " << argv[ 0 ]
14       << " output_code namespace filter1 filter2 ..."
15       << std::endl;
16     return( 1 );
17
18   } // fi
19   std::ofstream output_code( argv[ 1 ] );
20   if( !output_code )
21   {
22     std::cerr
23       << "Could not open file \"" << argv[ 1 ] << "\" for writing"
24       << std::endl;
25     return( 1 );
26
27   } // fi
28
29   output_code << "#include <Pluma/Connector.hpp>" << std::endl;
30   for( int i = 3; i < argc; ++i )
31     output_code << "#include \"" << argv[ i ] << "\"" << std::endl;
32   output_code
33     << std::endl
34     << "PLUMA_CONNECTOR" << std::endl
35     << "bool connect( pluma::Host& host )" << std::endl
36     << "{" << std::endl
37     << "  using namespace " << argv[ 2 ] << ";" << std::endl;
38
39   for( int i = 3; i < argc; ++i )
40   {
41     boost::filesystem::path p( argv[ i ] );
42     output_code
43       << "  host.add( new "
44       << p.stem( ).generic_string( )
45       << "Provider( ) );"
46       << std::endl;
47
48   } // rof
49
50   output_code
51     << "  return( true );" << std::endl
52     << "}" << std::endl;
53
54   // Finish
55   output_code.close( );
56   return( 0 );
57 }
58
59 // eof - $RCSfile$