]> Creatis software - cpPlugins.git/blobdiff - appli/examples/ReadRawFile_01.cxx
Moved to version 1.0
[cpPlugins.git] / appli / examples / ReadRawFile_01.cxx
diff --git a/appli/examples/ReadRawFile_01.cxx b/appli/examples/ReadRawFile_01.cxx
new file mode 100644 (file)
index 0000000..5156b8d
--- /dev/null
@@ -0,0 +1,40 @@
+// =========================================================================
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
+
+#include <iostream>
+#include <cpPlugins/DataObject.h>
+#include <cpPlugins/Filter.h>
+#include <cpPlugins/Pipeline.h>
+
+int main( int argc, char* argv[] )
+{
+  typedef cpPlugins::Pipeline TPipeline;
+  typedef cpPlugins::Filter   TFilter;
+
+  if( argc != 2 )
+  {
+    std::cerr << "Usage: " << argv[ 0 ] << " file" << std::endl;
+    return( 1 );
+  } // end if
+
+  try
+  {
+    TPipeline::SharedPtr pipeline = TPipeline::New( );
+    TFilter* reader =
+      pipeline->CreateNode( "cpPluginsBase::RawFileReader" )->
+      Cast< TFilter >( );
+    reader->SetInValue( "FileName", std::string( argv[ 1 ] ) );
+    reader->Update( );
+
+    std::cout << *( reader->GetOutput( "Output" ) ) << std::endl;
+  }
+  catch( std::exception& err )
+  {
+    std::cerr << "ERROR CAUGHT: " << err.what( ) << std::endl;
+    return( 1 );
+  } // end try
+  return( 0 );
+}
+
+// eof - $RCSfile$