diff --git a/Core/InputOutput/IntensityDataIOFactory.cpp b/Core/InputOutput/IntensityDataIOFactory.cpp index 83bc15d1cb6f9457daddac70691a4428b5b2e771..ead3c1aa1629c6df626c7c92d73703d86f34d969 100644 --- a/Core/InputOutput/IntensityDataIOFactory.cpp +++ b/Core/InputOutput/IntensityDataIOFactory.cpp @@ -21,27 +21,24 @@ #include "IHistogram.h" -OutputData<double > *IntensityDataIOFactory::readOutputData(const std::string& file_name) +OutputData<double >* IntensityDataIOFactory::readOutputData(const std::string& file_name) { - std::unique_ptr<OutputDataReader> P_reader(OutputDataReadFactory::getReader(file_name)); - return P_reader->getOutputData(); + return OutputDataReadFactory::getReader(file_name)->getOutputData(); } -IHistogram *IntensityDataIOFactory::readIntensityData(const std::string &file_name) +IHistogram* IntensityDataIOFactory::readIntensityData(const std::string& file_name) { return IHistogram::createHistogram(*(readOutputData(file_name))); } - -void IntensityDataIOFactory::writeOutputData(const OutputData<double>& data, - const std::string& file_name) +void IntensityDataIOFactory::writeOutputData( + const OutputData<double>& data, const std::string& file_name) { - std::unique_ptr<OutputDataWriter> P_writer(OutputDataWriteFactory::getWriter(file_name)); - return P_writer->writeOutputData(data); + return OutputDataWriteFactory::getWriter(file_name)->writeOutputData(data); } -void IntensityDataIOFactory::writeIntensityData(const IHistogram &histogram, - const std::string &file_name) +void IntensityDataIOFactory::writeIntensityData( + const IHistogram& histogram, const std::string& file_name) { writeOutputData(*(histogram.createOutputData()), file_name); } diff --git a/Core/InputOutput/IntensityDataIOFactory.h b/Core/InputOutput/IntensityDataIOFactory.h index b52c0fa3b092a4b4fc981f510cdb9c2dac82bc52..e5cb2bbc7edefe14c25c1e8a98c4a3ed8b22bb3e 100644 --- a/Core/InputOutput/IntensityDataIOFactory.h +++ b/Core/InputOutput/IntensityDataIOFactory.h @@ -51,21 +51,16 @@ class BA_CORE_API_ IntensityDataIOFactory { public: //! Reads file and returns newly created OutputData object - static OutputData<double > *readOutputData(const std::string& file_name); + static OutputData<double>* readOutputData(const std::string& file_name); //! Reads file and returns newly created Histogram object - static IHistogram *readIntensityData(const std::string& file_name); + static IHistogram* readIntensityData(const std::string& file_name); //! Writes OutputData in file - static void writeOutputData(const OutputData<double>& data, - const std::string& file_name); + static void writeOutputData(const OutputData<double>& data, const std::string& file_name); //! Writes histogram in file - static void writeIntensityData(const IHistogram &histogram, - const std::string& file_name); - + static void writeIntensityData(const IHistogram &histogram, const std::string& file_name); }; #endif // OUTPUTDATAIOFACTORY_H - - diff --git a/Core/InputOutput/OutputDataReader.cpp b/Core/InputOutput/OutputDataReader.cpp index f603c389274b2d715f3d0396942d3017e1705216..418ecf8fb88f61eca1042db6bf1b40500aa4d1d1 100644 --- a/Core/InputOutput/OutputDataReader.cpp +++ b/Core/InputOutput/OutputDataReader.cpp @@ -20,17 +20,16 @@ #include <fstream> -OutputDataReader::OutputDataReader(const std::string &file_name) +OutputDataReader::OutputDataReader(const std::string& file_name) : m_file_name(file_name) { } -OutputData<double > *OutputDataReader::getOutputData() +OutputData<double >* OutputDataReader::getOutputData() { - if(!m_read_strategy) { - throw NullPointerException("OutputDataReader::getOutputData() ->" + if(!m_read_strategy) + throw NullPointerException("OutputDataReader::getOutputData() -> " " Error! No read strategy defined"); - } std::ifstream fin; std::ios_base::openmode openmode = std::ios::in; @@ -38,25 +37,23 @@ OutputData<double > *OutputDataReader::getOutputData() openmode = std::ios::in | std::ios_base::binary; fin.open(m_file_name.c_str(), openmode ); - if(!fin.is_open()) { + if(!fin.is_open()) throw FileNotIsOpenException("OutputDataReader::getOutputData() -> Error. Can't open file '" + m_file_name + "' for reading."); - } - if (!fin.good()) { + if (!fin.good()) throw FileIsBadException("OutputDataReader::getOutputData() -> Error! File is not good, " "probably it is a directory."); - } - OutputData<double > *result = getFromFilteredStream(fin); + OutputData<double >* result = getFromFilteredStream(fin); fin.close(); return result; } -void OutputDataReader::setStrategy(IOutputDataReadStrategy *read_strategy) +void OutputDataReader::setStrategy(IOutputDataReadStrategy* read_strategy) { m_read_strategy.reset(read_strategy); } -OutputData<double > *OutputDataReader::getFromFilteredStream(std::istream &input_stream) +OutputData<double >* OutputDataReader::getFromFilteredStream(std::istream& input_stream) { boost::iostreams::filtering_streambuf<boost::iostreams::input> input_filtered; if (OutputDataIOHelper::isGZipped(m_file_name)) { diff --git a/Core/InputOutput/OutputDataReader.h b/Core/InputOutput/OutputDataReader.h index d92702ab7316a745ea6e70f24c6b8d25c2623e8b..7b9a56e0166f17128e4774b09bd76ab7921b6c0b 100644 --- a/Core/InputOutput/OutputDataReader.h +++ b/Core/InputOutput/OutputDataReader.h @@ -34,17 +34,15 @@ public: OutputDataReader(const std::string& file_name); //! read output data from file (file name was set already from OutputDataIOFactory) - OutputData<double > *getOutputData(); + OutputData<double >* getOutputData(); //! Sets concrete reading strategy - void setStrategy(IOutputDataReadStrategy *read_strategy); + void setStrategy(IOutputDataReadStrategy* read_strategy); private: - OutputData<double > *getFromFilteredStream(std::istream &input_stream); + OutputData<double >* getFromFilteredStream(std::istream& input_stream); std::string m_file_name; std::unique_ptr<IOutputDataReadStrategy> m_read_strategy; }; #endif // OUTPUTDATAREADER_H - - diff --git a/Core/TestMachinery/FutestSuite.cpp b/Core/TestMachinery/FutestSuite.cpp index ad154f528debc25343acf180f853db5106ba698c..0c8a2a2ac1209e9a02bec523a6ea9a038def8508 100644 --- a/Core/TestMachinery/FutestSuite.cpp +++ b/Core/TestMachinery/FutestSuite.cpp @@ -125,7 +125,7 @@ OutputData<double>* FutestSuite::getReferenceData() const result = IntensityDataIOFactory::readOutputData(filename); } catch(const std::exception& ex) { throw std::runtime_error( - std::string("FutestSuite::getReferenceData() -> Exception caught: ") + ex.what() ); + "FutestSuite::getReferenceData() -> Exception caught: " + ex.what() ); } return result; } diff --git a/Tests/Functional/Core/BatchSimulation.cpp b/Tests/Functional/Core/BatchSimulation.cpp index 3fe78d4c0fa8ccf2c4d73d1503105cea6d7291ff..9823dcb5c59b2cc3cd063fadda3c4abcf3acb41f 100644 --- a/Tests/Functional/Core/BatchSimulation.cpp +++ b/Tests/Functional/Core/BatchSimulation.cpp @@ -15,14 +15,14 @@ int TestBatchSimulation() sampleFactory.createItem("CylindersInBABuilder") ); simulation->setSampleBuilder(builder); simulation->runSimulation(); - const std::unique_ptr<OutputData<double > > reference(simulation->getDetectorIntensity()); - const std::unique_ptr<OutputData<double > > result(reference->clone()); + const std::unique_ptr<OutputData<double>> reference(simulation->getDetectorIntensity()); + const std::unique_ptr<OutputData<double>> result(reference->clone()); result->setAllTo(0.0); const int n_batches = 9; const double threshold = 2e-10; for(size_t i_batch=0; i_batch<n_batches; ++i_batch) { - const std::unique_ptr<GISASSimulation > batch(simulation->clone()); + const std::unique_ptr<GISASSimulation> batch(simulation->clone()); ThreadInfo threadInfo; threadInfo.n_threads = 1; threadInfo.n_batches = n_batches; @@ -39,7 +39,8 @@ int TestBatchSimulation() std::cout << "BatchSimulation" << " " << "Running simulations in batch mode" << " " << diff << " " << (diff>threshold ? "[FAILED]" : "[OK]") << std::endl; - if( diff > threshold ) return IFutest::FAILED; + if( diff > threshold ) + return IFutest::FAILED; return IFutest::SUCCESS; } diff --git a/cmake/bornagain/modules/BornAgainConfiguration.cmake b/cmake/bornagain/modules/BornAgainConfiguration.cmake index f7d88bd06747313d0f488cc88f98f3a0a16c20dd..03f04de5fe47b4d4b05ec730612b239d8b568cf6 100644 --- a/cmake/bornagain/modules/BornAgainConfiguration.cmake +++ b/cmake/bornagain/modules/BornAgainConfiguration.cmake @@ -33,7 +33,7 @@ endif() # source directories # ----------------------------------------------------------------------------- -set(BA_REF_DATA_DIR ${CMAKE_SOURCE_DIR}/Test/ReferenceData/BornAgain) +set(BA_REF_DATA_DIR ${CMAKE_SOURCE_DIR}/Tests/ReferenceData/BornAgain) # ----------------------------------------------------------------------------- # cmake runtime output configuration