SourceXtractorPlusPlus  0.10
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 };
46 
47 OutputConfig::OutputConfig(long manager_id) : Configuration(manager_id), m_format(OutputFileFormat::ASCII) {
48 }
49 
51  return { {"Output configuration", {
52  {OUTPUT_FILE.c_str(), po::value<std::string>()->default_value(""),
53  "The file to store the output catalog"},
54  {OUTPUT_FILE_FORMAT.c_str(), po::value<std::string>()->default_value("FITS"),
55  "The format of the output catalog, one of ASCII or FITS (default: FITS)"},
56  {OUTPUT_PROPERTIES.c_str(), po::value<std::string>()->default_value("PixelCentroid"),
57  "The output properties to add in the output catalog"},
58  {OUTPUT_FLUSH_SIZE.c_str(), po::value<int>()->default_value(100),
59  "Write to the catalog after this number of sources have been processed (0 means once at the end)"}
60  }}};
61 }
62 
64  auto& format = args.at(OUTPUT_FILE_FORMAT).as<std::string>();
65  if (format_map.count(format) == 0) {
66  throw Elements::Exception() << "Unknown output file format: " << format;
67  }
68 }
69 
71  m_out_file = args.at(OUTPUT_FILE).as<std::string>();
72 
73  std::stringstream properties_str {args.at(OUTPUT_PROPERTIES).as<std::string>()};
74  std::string name;
75  while (std::getline(properties_str, name, ',')) {
77  }
78 
79  auto& format = args.at(OUTPUT_FILE_FORMAT).as<std::string>();
80  m_format = format_map.at(format);
81 
82  int flush_size = args.at(OUTPUT_FLUSH_SIZE).as<int>();
83  m_flush_size = (flush_size >= 0) ? flush_size : 0;
84 }
85 
87  return m_out_file;
88 }
89 
91  return m_format;
92 }
93 
95  return m_output_properties;
96 }
97 
99  return m_flush_size;
100 }
101 
102 } // SEImplementation namespace
103 
104 
105 
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()