SourceXtractorPlusPlus  0.19
SourceXtractor++, the next generation SExtractor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OutputFactory.cpp
Go to the documentation of this file.
1 
22 #include <system_error>
23 #include <iostream>
24 #include <fstream>
25 #include <system_error>
26 #include <CCfits/CCfits>
27 
29 
31 
36 
38 
39 namespace SourceXtractor {
40 
42  auto source_to_row = m_output_registry->getSourceToRowConverter(m_output_properties);
43 
44  if (m_output_filename != "") {
45  switch (m_output_format) {
47  return std::make_shared<FitsOutput>(m_output_filename, source_to_row, m_flush_size);
49  return std::make_shared<LdacOutput>(m_output_filename, source_to_row, m_flush_size);
50  default:
52  return std::make_shared<AsciiOutput>(m_output_filename, source_to_row, m_flush_size);
53  }
54  } else {
55  return std::make_shared<AsciiOutput>(m_output_filename, source_to_row, m_flush_size);
56  }
57 }
58 
61 }
62 
64  auto& output_config = manager.getConfiguration<OutputConfig>();
65  m_output_properties = output_config.getOutputProperties();
66  m_flush_size = output_config.getFlushSize();
67  m_output_filename = output_config.getOutputFile();
68  m_output_format = output_config.getOutputFileFormat();
69 
70  if (m_output_filename != "") {
71  // Check if we can, at least, create it.
72  // Otherwise, the error will be triggered only at the end of the full process!
73  std::ofstream check_writeable{m_output_filename};
74  if (!check_writeable) {
75  throw Elements::Exception(
76  std::system_error(errno, std::system_category(), "Failed to open the output catalog").what());
77  }
78  }
79 }
80 
81 } // SourceXtractor namespace
82 
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.
std::shared_ptr< Output > createOutput() const
std::shared_ptr< OutputRegistry > m_output_registry
Definition: OutputFactory.h:55
T system_category(T...args)
STL class.
void reportConfigDependencies(Euclid::Configuration::ConfigManager &manager) const override
Registers all the Configuration dependencies.
std::vector< std::string > m_output_properties
Definition: OutputFactory.h:56
std::unique_ptr< T > make_unique(Args &&...args)
OutputConfig::OutputFileFormat m_output_format
Definition: OutputFactory.h:59