--- /dev/null
+#include <iostream>
+#include <set>
+#include <string>
+#include <vector>
+#include <cpPlugins/Interface.h>
+#include <cpPlugins/Workspace.h>
+
+int main( int argc, char* argv[] )
+{
+ if( argc == 1 )
+ {
+ std::cout << "Usage: " << argv[ 0 ] << " workspace args" << std::endl;
+ return( 1 );
+
+ } // fi
+ std::string ws_file = argv[ 1 ];
+
+ // Configure a plugin interface and load given workspace
+ cpPlugins::Interface interface;
+ cpPlugins::Workspace ws;
+ ws.SetInterface( &interface );
+ std::string err = ws.LoadWorkspace( ws_file );
+ if( err != "" )
+ {
+ std::cerr
+ << "Error loading workspace \"" << ws_file << "\": "
+ << err << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Read arguments
+ for( unsigned int i = 2; i < argc; i += 2 )
+ {
+ std::vector< std::string > tokens;
+ cpPlugins::TokenizeString( tokens, argv[ i ], "@" );
+ std::string filter_name = tokens[ 1 ];
+ std::string param_name = tokens[ 0 ];
+ std::string param_value = argv[ i + 1 ];
+
+ auto filter = ws.GetFilter( filter_name );
+ if( filter != NULL )
+ filter->GetParameters( )->SetString( param_name, param_value );
+ else
+ std::cerr
+ << "Warning: filter \"" << filter_name
+ << "\" is not defined inside the loaded workspace." << std::endl;
+
+ } // rof
+
+ // Execute workspace
+ ws.PrintExecutionOn( );
+ try
+ {
+ ws.Execute( );
+ }
+ catch( itk::ExceptionObject& err1 )
+ {
+ std::cerr << "Error caught: " << err1 << std::endl;
+ return( 1 );
+ }
+ catch( std::exception& err2 )
+ {
+ std::cerr << "Error caught: " << err2.what( ) << std::endl;
+ return( 1 );
+ }
+ catch( ... )
+ {
+ std::cerr << "Unknown error caught." << std::endl;
+ return( 1 );
+
+ } // yrt
+ return( 0 );
+}
+
+// eof - $RCSfile$