SourceXtractorPlusPlus
0.17
SourceXtractor++, the next generation SExtractor
SEImplementation
src
lib
Output
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
28
#include "
SEFramework/Output/OutputRegistry.h
"
29
30
#include "
SEImplementation/Configuration/DetectionImageConfig.h
"
31
32
#include "
SEImplementation/Output/AsciiOutput.h
"
33
#include "
SEImplementation/Output/FitsOutput.h
"
34
#include "
SEImplementation/Output/LdacOutput.h
"
35
36
#include "
SEImplementation/Output/OutputFactory.h
"
37
38
using
Euclid::make_unique
;
39
40
namespace
SourceXtractor
{
41
42
std::shared_ptr<Output>
OutputFactory::createOutput
()
const
{
43
auto
source_to_row =
m_output_registry
->getSourceToRowConverter(
m_output_properties
);
44
45
if
(
m_output_filename
!=
""
) {
46
switch
(
m_output_format
) {
47
case
OutputConfig::OutputFileFormat::FITS
:
48
return
std::make_shared<FitsOutput>(
m_output_filename
, source_to_row,
m_flush_size
);
49
case
OutputConfig::OutputFileFormat::FITS_LDAC
:
50
return
std::make_shared<LdacOutput>(
m_output_filename
, source_to_row,
m_flush_size
);
51
default
:
52
case
OutputConfig::OutputFileFormat::ASCII
:
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
60
void
OutputFactory::reportConfigDependencies
(
Euclid::Configuration::ConfigManager
& manager)
const
{
61
manager.
registerConfiguration
<
OutputConfig
>();
62
}
63
64
void
OutputFactory::configure
(
Euclid::Configuration::ConfigManager
& manager) {
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
AsciiOutput.h
DetectionImageConfig.h
FitsOutput.h
LdacOutput.h
OutputFactory.h
OutputRegistry.h
std::ofstream
Elements::Exception
Euclid::Configuration::ConfigManager
Euclid::Configuration::ConfigManager::registerConfiguration
void registerConfiguration()
Euclid::Configuration::ConfigManager::getConfiguration
T & getConfiguration()
SourceXtractor::OutputConfig
Definition:
OutputConfig.h:36
SourceXtractor::OutputConfig::OutputFileFormat::FITS_LDAC
@ FITS_LDAC
SourceXtractor::OutputConfig::OutputFileFormat::FITS
@ FITS
SourceXtractor::OutputConfig::OutputFileFormat::ASCII
@ ASCII
SourceXtractor::OutputFactory::configure
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.
Definition:
OutputFactory.cpp:64
SourceXtractor::OutputFactory::m_output_format
OutputConfig::OutputFileFormat m_output_format
Definition:
OutputFactory.h:59
SourceXtractor::OutputFactory::m_output_registry
std::shared_ptr< OutputRegistry > m_output_registry
Definition:
OutputFactory.h:55
SourceXtractor::OutputFactory::m_output_properties
std::vector< std::string > m_output_properties
Definition:
OutputFactory.h:56
SourceXtractor::OutputFactory::reportConfigDependencies
void reportConfigDependencies(Euclid::Configuration::ConfigManager &manager) const override
Registers all the Configuration dependencies.
Definition:
OutputFactory.cpp:60
SourceXtractor::OutputFactory::m_flush_size
size_t m_flush_size
Definition:
OutputFactory.h:57
SourceXtractor::OutputFactory::createOutput
std::shared_ptr< Output > createOutput() const
Definition:
OutputFactory.cpp:42
SourceXtractor::OutputFactory::m_output_filename
std::string m_output_filename
Definition:
OutputFactory.h:60
Euclid::make_unique
std::unique_ptr< T > make_unique(Args &&... args)
SourceXtractor
Definition:
Aperture.h:30
std::shared_ptr
std::system_category
T system_category(T... args)
std::system_error
Generated by
1.9.1