--- /dev/null
+// =========================================================================
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
+
+#include <iostream>
+#include <vector>
+#include <boost/filesystem.hpp>
+#include <boost/program_options.hpp>
+#include <cpPlugins/Pipeline.h>
+
+int main( int argc, char* argv[] )
+{
+ typedef cpPlugins::Pipeline TPipeline;
+ namespace bpo = boost::program_options;
+
+ // Declare the supported options.
+ bpo::options_description d( "Allowed options" );
+ d.add_options( )
+ ( "help,h", "produce help message" )
+ ( "interactive,i", bpo::bool_switch( )->default_value( false ), "Run an interactive menu to configure pipeline" )
+ ( "overwrite,o", bpo::bool_switch( )->default_value( false ), "Overwrite XML file" )
+ ( "contents,c", bpo::bool_switch( )->default_value( false ), "Print pipeline contents" )
+ ( "value,v", bpo::value< std::vector< std::string > >( ), "Parameter values" )
+ ( "pipeline,p", bpo::value< std::string >( )->required( ), "Pipeline file" )
+ ;
+ bpo::positional_options_description p;
+ p.add( "pipeline", -1 );
+
+ // Parse input arguments
+ bpo::variables_map v;
+ try
+ {
+ bpo::store(
+ bpo::
+ command_line_parser( argc, argv ).options( d ).positional( p ).run( ),
+ v
+ );
+ bpo::notify( v );
+ if( v.count( "help" ) > 0 )
+ {
+ std::cerr << d << std::endl;
+ return( 0 );
+
+ } // fi
+ }
+ catch( std::exception& err )
+ {
+ std::cerr << "Error caught: " << err.what( ) << std::endl;
+ std::cerr << d << std::endl;
+ return( 1 );
+
+ } // yrt
+
+ try
+ {
+ // Load pipeline
+ TPipeline::SharedPtr pipeline = TPipeline::New( );
+ pipeline->ExecutionDebugOn( );
+ pipeline->LoadXML( v[ "pipeline" ].as< std::string >( ) );
+
+ // Configure pipeline
+ if( v.count( "value" ) > 0 )
+ {
+ for(
+ const std::string& pv:
+ v[ "value" ].as< std::vector< std::string > >( )
+ )
+ {
+ std::size_t b = pv.find_first_of( "=" );
+ pipeline->SetInValue( pv.substr( 0, b ), pv.substr( b + 1 ) );
+
+ } // rof
+
+ } // fi
+
+ // Just print pipeline contents
+ if( v[ "contents" ].as< bool >( ) )
+ {
+ /* TODO
+ TPipeline::TParametersMap pmap = pipeline->GetParametersMap( );
+ TPipeline::TParametersMap::const_iterator pIt;
+ for( pIt = pmap.begin( ); pIt != pmap.end( ); ++pIt )
+ {
+ std::cout
+ << pIt->first << " ("
+ << pIt->second.first << "="
+ << pIt->second.second << ")"
+ << std::endl;
+
+ } // rof
+ */
+ return( 0 );
+
+ } // fi
+
+ // Interactively configure pipeline
+ if( v[ "interactive" ].as< bool >( ) )
+ {
+ std::cout << "** Interactively configuring pipeline **" << std::endl;
+ /* TODO
+ TPipeline::TParametersMap pmap = pipeline->GetParametersMap( );
+ TPipeline::TParametersMap::const_iterator pIt;
+ for( pIt = pmap.begin( ); pIt != pmap.end( ); ++pIt )
+ {
+ std::cout
+ << pIt->first << " ("
+ << pIt->second.first << "="
+ << pIt->second.second << "): "
+ << std::ends;
+ std::string line;
+ std::getline( std::cin, line );
+ if( line != "" )
+ {
+ std::size_t p = pIt->first.find( "@" );
+ pipeline->SetParameter(
+ pIt->first.substr( p + 1 ),
+ pIt->first.substr( 0, p ),
+ line
+ );
+
+ } // fi
+
+ } // rof
+ */
+ } // fi
+
+ // Execute pipeline
+ pipeline->Update( );
+
+ // Save pipeline
+ if( v[ "overwrite" ].as< bool >( ) )
+ pipeline->SaveXML( v[ "pipeline" ].as< std::string >( ) );
+ }
+ catch( std::exception& err )
+ {
+ std::cerr << "ERROR CAUGHT: " << err.what( ) << std::endl;
+ return( 1 );
+
+ } // yrt
+ return( 0 );
+}
+
+// eof - $RCSfile$