]> Creatis software - cpPlugins.git/blob - appli/examples/ReadWriteRawFile_01.cxx
Moved to version 1.0
[cpPlugins.git] / appli / examples / ReadWriteRawFile_01.cxx
1 // =========================================================================
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4
5 #include <iostream>
6 #include <cpPlugins/Filter.h>
7 #include <cpPlugins/Pipeline.h>
8
9 int main( int argc, char* argv[] )
10 {
11   typedef cpPlugins::Pipeline TPipeline;
12   typedef cpPlugins::Filter   TFilter;
13
14   if( argc != 3 )
15   {
16     std::cerr << "Usage: " << argv[ 0 ] << " input output" << std::endl;
17     return( 1 );
18   } // end if
19
20   try
21   {
22
23     TPipeline::SharedPtr pipeline = TPipeline::New( );
24
25     TFilter* reader =
26       pipeline->CreateNode( "cpPluginsBase::RawFileReader" )->
27       Cast< TFilter >( );
28     reader->SetInValue( "FileName", std::string( argv[ 1 ] ) );
29
30     TFilter* writer =
31       pipeline->CreateNode( "cpPluginsBase::RawFileWriter" )->
32       Cast< TFilter >( );
33     writer->SetInValue( "FileName", std::string( argv[ 2 ] ) );
34     writer->SetInput( "Input", reader->GetOutput( "Output" ) );
35     writer->Update( );
36   }
37   catch( std::exception& err )
38   {
39     std::cerr << "ERROR CAUGHT: " << err.what( ) << std::endl;
40     return( 1 );
41   } // end try
42   return( 0 );
43 }
44
45 // eof - $RCSfile$