BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
OutputDataWriteFactory.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Device/InputOutput/OutputDataWriteFactory.cpp
6 //! @brief Implements class OutputDataWriteFactory.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
15 #include "Base/Types/Exceptions.h"
17 
19 {
20  OutputDataWriter* result = new OutputDataWriter(file_name);
21  result->setStrategy(getWriteStrategy(file_name));
22  return result;
23 }
24 
26 {
27  IOutputDataWriteStrategy* result(nullptr);
28  if (DataFormatUtils::isIntFile(file_name)) {
29  result = new OutputDataWriteINTStrategy();
30  }
31 
32 #ifdef BORNAGAIN_TIFF_SUPPORT
33  else if (DataFormatUtils::isTiffFile(file_name)) {
34  result = new OutputDataWriteTiffStrategy();
35  }
36 #endif // BORNAGAIN_TIFF_SUPPORT
37 
38  else {
39  result = new OutputDataWriteNumpyTXTStrategy();
40  }
41 
42  return result;
43 }
Defines class OutputDataIOFactory.
Defines many exception classes in namespace Exceptionss.
Defines class OutputDataWriteFactory.
Strategy interface to write OututData in file.
static OutputDataWriter * getWriter(const std::string &file_name)
static IOutputDataWriteStrategy * getWriteStrategy(const std::string &file_name)
Strategy to write OutputData to special BornAgain ASCII format.
Strategy to write OutputData to simple ASCII file with the layout as in numpy.savetxt.
Write OutputData to file using different witing strategies.
void setStrategy(IOutputDataWriteStrategy *write_strategy)
Sets concrete writing strategy.
bool isIntFile(const std::string &file_name)
returns true if file name corresponds to BornAgain native format (compressed or not)
bool isTiffFile(const std::string &file_name)
returns true if file name corresponds to tiff file (can be also compressed)