SourceXtractorPlusPlus  0.11
Please provide a description of the project.
OutputConfig.cpp
Go to the documentation of this file.
1 
23 #include <sstream>
24 
26 
29 
31 
32 using namespace Euclid::Configuration;
33 namespace po = boost::program_options;
34 
35 namespace SourceXtractor {
36 
37 static const std::string OUTPUT_FILE {"output-catalog-filename"};
38 static const std::string OUTPUT_FILE_FORMAT {"output-catalog-format"};
39 static const std::string OUTPUT_PROPERTIES {"output-properties"};
40 static const std::string OUTPUT_FLUSH_SIZE {"output-flush-size"};
41 
43  {"ASCII", OutputConfig::OutputFileFormat::ASCII},
44  {"FITS", OutputConfig::OutputFileFormat::FITS},
45  {"FITS_LDAC", OutputConfig::OutputFileFormat::FITS_LDAC}
46 };
47 
48 OutputConfig::OutputConfig(long manager_id) : Configuration(manager_id), m_format(OutputFileFormat::ASCII),
49  m_flush_size(100) {
50 }
51 
53  return { {"Output configuration", {
54  {OUTPUT_FILE.c_str(), po::value<std::string>()->default_value(""),
55  "The file to store the output catalog"},
56  {OUTPUT_FILE_FORMAT.c_str(), po::value<std::string>()->default_value("FITS"),
57  "The format of the output catalog, one of ASCII or FITS (default: FITS)"},
58  {OUTPUT_PROPERTIES.c_str(), po::value<std::string>()->default_value("PixelCentroid"),
59  "The output properties to add in the output catalog"},
60  {OUTPUT_FLUSH_SIZE.c_str(), po::value<int>()->default_value(100),
61  "Write to the catalog after this number of sources have been processed (0 means once at the end)"}
62  }}};
63 }
64 
66  auto& format = args.at(OUTPUT_FILE_FORMAT).as<std::string>();
67  if (format_map.count(format) == 0) {
68  throw Elements::Exception() << "Unknown output file format: " << format;
69  }
70 }
71 
73  m_out_file = args.at(OUTPUT_FILE).as<std::string>();
74 
75  std::stringstream properties_str {args.at(OUTPUT_PROPERTIES).as<std::string>()};
76  std::string name;
77  while (std::getline(properties_str, name, ',')) {
79  }
80 
81  auto& format = args.at(OUTPUT_FILE_FORMAT).as<std::string>();
82  m_format = format_map.at(format);
83 
84  int flush_size = args.at(OUTPUT_FLUSH_SIZE).as<int>();
85  m_flush_size = (flush_size >= 0) ? flush_size : 0;
86 }
87 
89  return m_out_file;
90 }
91 
93  return m_format;
94 }
95 
97  return m_output_properties;
98 }
99 
101  return m_flush_size;
102 }
103 
104 } // SEImplementation namespace
105 
106 
107 
T getline(T... args)
void initialize(const UserValues &args) override
STL class.
static std::map< std::string, OutputConfig::OutputFileFormat > format_map
STL class.
T at(T... args)
OutputFileFormat m_format
Definition: OutputConfig.h:67
const std::vector< std::string > getOutputProperties()
std::vector< std::string > m_output_properties
Definition: OutputConfig.h:68
static const std::string OUTPUT_FILE_FORMAT
void preInitialize(const UserValues &args) override
std::map< std::string, Configuration::OptionDescriptionList > getProgramOptions() override
T c_str(T... args)
static const std::string OUTPUT_FLUSH_SIZE
static const std::string OUTPUT_FILE
static const std::string OUTPUT_PROPERTIES
T emplace_back(T... args)
OutputFileFormat getOutputFileFormat()