SourceXtractorPlusPlus  0.17
SourceXtractor++, the next generation SExtractor
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 
35 
37 
39 
40 namespace SourceXtractor {
41 
43  auto source_to_row = m_output_registry->getSourceToRowConverter(m_output_properties);
44 
45  if (m_output_filename != "") {
46  switch (m_output_format) {
48  return std::make_shared<FitsOutput>(m_output_filename, source_to_row, m_flush_size);
50  return std::make_shared<LdacOutput>(m_output_filename, source_to_row, m_flush_size);
51  default:
53  return std::make_shared<AsciiOutput>(m_output_filename, source_to_row, m_flush_size);
54  }
55  } else {
56  return std::make_shared<AsciiOutput>(m_output_filename, source_to_row, m_flush_size);
57  }
58 }
59 
62 }
63 
65  auto& output_config = manager.getConfiguration<OutputConfig>();
66  m_output_properties = output_config.getOutputProperties();
67  m_flush_size = output_config.getFlushSize();
68  m_output_filename = output_config.getOutputFile();
69  m_output_format = output_config.getOutputFileFormat();
70 
71  if (m_output_filename != "") {
72  // Check if we can, at least, create it.
73  // Otherwise, the error will be triggered only at the end of the full process!
74  std::ofstream check_writeable{m_output_filename};
75  if (!check_writeable) {
76  throw Elements::Exception(
77  std::system_error(errno, std::system_category(), "Failed to open the output catalog").what());
78  }
79  }
80 }
81 
82 } // SourceXtractor namespace
83 
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.
OutputConfig::OutputFileFormat m_output_format
Definition: OutputFactory.h:59
std::shared_ptr< OutputRegistry > m_output_registry
Definition: OutputFactory.h:55
std::vector< std::string > m_output_properties
Definition: OutputFactory.h:56
void reportConfigDependencies(Euclid::Configuration::ConfigManager &manager) const override
Registers all the Configuration dependencies.
std::shared_ptr< Output > createOutput() const
std::unique_ptr< T > make_unique(Args &&... args)
T system_category(T... args)