Skip to content
Snippets Groups Projects
Commit 25c23928 authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Made getReader and getWriter private and removed the need for shared_ptr as return value

parent bdea8bf0
No related branches found
No related tags found
No related merge requests found
......@@ -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" );
}
......
......@@ -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
......
......@@ -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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment