diff --git a/Core/PythonAPI/src/IntensityDataIOFactory.pypp.cpp b/Core/PythonAPI/src/IntensityDataIOFactory.pypp.cpp index f11cedf83f9d7a340e74207b98f248d8fc2ea51e..9bf8abbbba0d91ec66783073a1d2e881790f1eaf 100644 --- a/Core/PythonAPI/src/IntensityDataIOFactory.pypp.cpp +++ b/Core/PythonAPI/src/IntensityDataIOFactory.pypp.cpp @@ -32,26 +32,6 @@ void register_IntensityDataIOFactory_class(){ typedef bp::class_< IntensityDataIOFactory > IntensityDataIOFactory_exposer_t; IntensityDataIOFactory_exposer_t IntensityDataIOFactory_exposer = IntensityDataIOFactory_exposer_t( "IntensityDataIOFactory" ); bp::scope IntensityDataIOFactory_scope( IntensityDataIOFactory_exposer ); - { //::IntensityDataIOFactory::getReader - - typedef ::boost::shared_ptr< OutputDataReader > ( *getReader_function_type )( ::std::string const & ); - - IntensityDataIOFactory_exposer.def( - "getReader" - , getReader_function_type( &::IntensityDataIOFactory::getReader ) - , ( bp::arg("file_name") ) ); - - } - { //::IntensityDataIOFactory::getWriter - - typedef ::boost::shared_ptr< OutputDataWriter > ( *getWriter_function_type )( ::std::string const & ); - - IntensityDataIOFactory_exposer.def( - "getWriter" - , getWriter_function_type( &::IntensityDataIOFactory::getWriter ) - , ( bp::arg("file_name") ) ); - - } { //::IntensityDataIOFactory::readIntensityData typedef ::OutputData< double > * ( *readIntensityData_function_type )( ::std::string const & ); @@ -73,8 +53,6 @@ void register_IntensityDataIOFactory_class(){ , ( bp::arg("data"), bp::arg("file_name") ) ); } - IntensityDataIOFactory_exposer.staticmethod( "getReader" ); - IntensityDataIOFactory_exposer.staticmethod( "getWriter" ); IntensityDataIOFactory_exposer.staticmethod( "readIntensityData" ); IntensityDataIOFactory_exposer.staticmethod( "writeIntensityData" ); } diff --git a/Core/Tools/inc/IntensityDataIOFactory.h b/Core/Tools/inc/IntensityDataIOFactory.h index 7f3548278cac80b12820e545a505b92aff8d4b51..2afb0e369253dd8c35f239955e0a56a88a7a116b 100644 --- a/Core/Tools/inc/IntensityDataIOFactory.h +++ b/Core/Tools/inc/IntensityDataIOFactory.h @@ -32,15 +32,14 @@ template <class T> class OutputData; class BA_CORE_API_ IntensityDataIOFactory { public: - typedef boost::shared_ptr<OutputDataReader > OutputDataReader_t; - typedef boost::shared_ptr<OutputDataWriter > OutputDataWriter_t; - static OutputData<double > *readIntensityData(const std::string& file_name); - static OutputDataReader_t getReader(const std::string& file_name); static void writeIntensityData(const OutputData<double>& data, const std::string& file_name); - static OutputDataWriter_t getWriter(const std::string& file_name); + +private: + static OutputDataReader* getReader(const std::string& file_name); + static OutputDataWriter* getWriter(const std::string& file_name); }; #endif // OUTPUTDATAIOFACTORY_H diff --git a/Core/Tools/src/IntensityDataIOFactory.cpp b/Core/Tools/src/IntensityDataIOFactory.cpp index 393c63e1cb5283f9a1aac0abee3736483237469a..f17ec86eed1ddb65db6d644ab36f55919b29214f 100644 --- a/Core/Tools/src/IntensityDataIOFactory.cpp +++ b/Core/Tools/src/IntensityDataIOFactory.cpp @@ -22,17 +22,20 @@ #include "Utils.h" #include "FileSystem.h" +#include <boost/scoped_ptr.hpp> + /* ************************************************************************* */ // reading output data /* ************************************************************************* */ OutputData<double > *IntensityDataIOFactory::readIntensityData( const std::string& file_name) { - return getReader(file_name)->getOutputData(); + boost::scoped_ptr<OutputDataReader> reader(getReader(file_name)); + return reader->getOutputData(); } -IntensityDataIOFactory::OutputDataReader_t IntensityDataIOFactory::getReader( +OutputDataReader* IntensityDataIOFactory::getReader( const std::string& file_name) { OutputDataReader *reader = new OutputDataReader( file_name ); @@ -51,7 +54,7 @@ IntensityDataIOFactory::OutputDataReader_t IntensityDataIOFactory::getReader( reader->setStrategy( read_strategy ); } - return OutputDataReader_t(reader); + return reader; } /* ************************************************************************* */ @@ -60,10 +63,11 @@ IntensityDataIOFactory::OutputDataReader_t IntensityDataIOFactory::getReader( void IntensityDataIOFactory::writeIntensityData(const OutputData<double>& data, const std::string& file_name) { - return getWriter(file_name)->writeOutputData(data); + boost::scoped_ptr<OutputDataWriter> writer(getWriter(file_name)); + return writer->writeOutputData(data); } -IntensityDataIOFactory::OutputDataWriter_t IntensityDataIOFactory::getWriter( +OutputDataWriter* IntensityDataIOFactory::getWriter( const std::string& file_name) { OutputDataWriter *writer = new OutputDataWriter( file_name ); @@ -78,7 +82,7 @@ IntensityDataIOFactory::OutputDataWriter_t IntensityDataIOFactory::getWriter( writer->setStrategy( write_strategy ); - return OutputDataWriter_t(writer); + return writer; }