]> Creatis software - cpPlugins.git/blob - tools/ExecutePipeline.cxx
0532fa203f2a5f352460e14a46ea10cb7e328f26
[cpPlugins.git] / tools / ExecutePipeline.cxx
1 #include <iostream>
2 #include <cpPlugins/Interface/Loader.h>
3 #include <cpPlugins/OS/FileSystem.h>
4 #include <cpPlugins/Interface/Workspace.h>
5
6 int main( int argc, char* argv[] )
7 {
8   if( argc < 2 )
9   {
10     std::cerr
11       << "Usage: " << argv[ 0 ] << " workspace"
12       << std::endl;
13     return( 1 );
14
15   } // fi
16
17   // Get plugins loader
18   cpPlugins::Interface::Loader loader;
19   loader.GuessEnvironment( cpPlugins::OS::FileSystem::CanonicalPath( "." ) );
20
21   int ret = 0;
22   try
23   {
24     // Prepare workspace
25     cpPlugins::Interface::Workspace::Pointer workspace =
26       cpPlugins::Interface::Workspace::New( );
27     workspace->Load( argv[ 1 ] );
28
29     // Execute workspace
30     workspace->PrintExecutionOn( );
31     workspace->Update( );
32   }
33   catch( std::exception& err )
34   {
35     std::cerr << "Error caught: " << err.what( ) << std::endl;
36     ret = 1;
37
38   } // yrt
39
40   // Close connection to loaded plugins file and finish execution
41   loader.UnRegisterAll( );
42   return( ret );
43 }
44
45 // eof - $RCSfile$