X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPluginsBase%2FRawFileReader.cxx;fp=lib%2FcpPluginsBase%2FRawFileReader.cxx;h=386bbc9dc43c53859e7b7110361869fecc242795;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=0000000000000000000000000000000000000000;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/cpPluginsBase/RawFileReader.cxx b/lib/cpPluginsBase/RawFileReader.cxx new file mode 100644 index 0000000..386bbc9 --- /dev/null +++ b/lib/cpPluginsBase/RawFileReader.cxx @@ -0,0 +1,53 @@ +// ========================================================================= +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ========================================================================= + +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsBase::RawFileReader:: +RawFileReader( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +cpPluginsBase::RawFileReader:: +~RawFileReader( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsBase::RawFileReader:: + _Configure( ) +{ + this->ConfigureInValue< std::string >( "FileName" ); + this->_ConfigureOutput< cpPluginsBase::RawData >( "Output" ); +} + +// ------------------------------------------------------------------------- +void cpPluginsBase::RawFileReader:: +_GenerateData( ) +{ + typedef cpPluginsBase::RawData _TData; + + std::string fname = std::string( this->GetInValue( "FileName" ) ); + std::ifstream iStr( fname.c_str( ), std::ios::binary | std::ios::ate ); + if( iStr ) + { + std::streamsize size = iStr.tellg( ); + iStr.seekg( 0, std::ios::beg ); + char* buffer = new char[ size ]; + iStr.read( buffer, size ); + this->_GetOutput< _TData >( "Output" )->TakeOwnership( buffer, size ); + iStr.close( ); + } + else + cpPluginsErrorMacro( + this, << "Could not load file \"" << fname << "\"" + ); +} + +// eof - $RCSfile$