5 #include <cpPlugins/Interface.h>
6 #include <cpPlugins/Workspace.h>
8 int main( int argc, char* argv[] )
12 std::cout << "Usage: " << argv[ 0 ] << " workspace args" << std::endl;
16 std::string ws_file = argv[ 1 ];
18 // Configure a plugin interface and load given workspace
19 cpPlugins::Interface interface;
20 cpPlugins::Workspace ws;
21 ws.SetInterface( &interface );
22 std::string err = ws.LoadWorkspace( ws_file );
26 << "Error loading workspace \"" << ws_file << "\": "
33 for( unsigned int i = 2; i < argc; i += 2 )
35 std::vector< std::string > tokens;
36 cpPlugins::TokenizeString( tokens, argv[ i ], "@" );
37 std::string filter_name = tokens[ 1 ];
38 std::string param_name = tokens[ 0 ];
39 std::string param_value = argv[ i + 1 ];
41 auto filter = ws.GetFilter( filter_name );
43 filter->GetParameters( )->SetString( param_name, param_value );
46 << "Warning: filter \"" << filter_name
47 << "\" is not defined inside the loaded workspace." << std::endl;
52 ws.PrintExecutionOn( );
57 catch( itk::ExceptionObject& err1 )
59 std::cerr << "Error caught: " << err1 << std::endl;
62 catch( std::exception& err2 )
64 std::cerr << "Error caught: " << err2.what( ) << std::endl;
69 std::cerr << "Unknown error caught." << std::endl;