SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Plugin
ExternalFlag
ExternalFlagTaskFactory.cpp
Go to the documentation of this file.
1
23
#include "
SEImplementation/Configuration/OutputConfig.h
"
24
25
#include "
SEImplementation/Plugin/ExternalFlag/ExternalFlagConfig.h
"
26
#include "
SEImplementation/Plugin/ExternalFlag/ExternalFlag.h
"
27
#include "
SEImplementation/Plugin/ExternalFlag/ExternalFlagTask.h
"
28
#include "
SEImplementation/Plugin/ExternalFlag/ExternalFlagTaskFactory.h
"
29
30
namespace
SourceXtractor
{
31
32
const
char
ExternalFlagTaskFactory::propertyName
[] =
"ExternalFlags"
;
33
34
void
ExternalFlagTaskFactory::reportConfigDependencies
(
Euclid::Configuration::ConfigManager
&
manager
)
const
{
35
manager
.registerConfiguration<
ExternalFlagConfig
>();
36
manager
.registerConfiguration<
OutputConfig
>();
37
}
38
39
40
std::shared_ptr<Task>
ExternalFlagTaskFactory::createTask
(
const
PropertyId
&
property_id
)
const
{
41
if
(
m_flag_info_map
.find(
property_id
) !=
m_flag_info_map
.end()) {
42
auto
&
flag_info
=
m_flag_info_map
.at(
property_id
);
43
44
// Here we use an ugly switch for choosing the correct type of the task to
45
// instantiate.
46
switch
(
flag_info
.second) {
47
case
ExternalFlagConfig::Type::OR
:
48
return
std::make_shared<ExternalFlagTaskOr>
(
flag_info
.first,
property_id
.getIndex());
49
case
ExternalFlagConfig::Type::AND
:
50
return
std::make_shared<ExternalFlagTaskAnd>
(
flag_info
.first,
property_id
.getIndex());
51
case
ExternalFlagConfig::Type::MIN
:
52
return
std::make_shared<ExternalFlagTaskMin>
(
flag_info
.first,
property_id
.getIndex());
53
case
ExternalFlagConfig::Type::MAX
:
54
return
std::make_shared<ExternalFlagTaskMax>
(
flag_info
.first,
property_id
.getIndex());
55
case
ExternalFlagConfig::Type::MOST
:
56
return
std::make_shared<ExternalFlagTaskMost>
(
flag_info
.first,
property_id
.getIndex());
57
}
58
}
59
60
return
nullptr
;
61
}
62
63
64
void
ExternalFlagTaskFactory::configure
(
Euclid::Configuration::ConfigManager
&
manager
) {
65
// Loop through the different flag infos. The i will be the index of the flag property.
66
auto
&
flag_info_list
=
manager
.getConfiguration<
ExternalFlagConfig
>().getFlagInfoList();
67
for
(
unsigned
int
i
= 0;
i
<
flag_info_list
.size(); ++
i
) {
68
auto
&
pair
=
flag_info_list
.at(
i
);
69
m_instance_names
.
emplace_back
(
pair
.first,
i
);
70
auto
property_id
= PropertyId::create<ExternalFlag>(
i
);
71
72
m_flag_info_map
[
property_id
] =
pair
.second;
73
}
74
75
auto
&
output_config
=
manager
.getConfiguration<
OutputConfig
>();
76
auto
&
output_properties
=
output_config
.getOutputProperties();
77
m_is_output_requested
=
std::find
(
output_properties
.begin(),
output_properties
.end(),
propertyName
)
78
!=
output_properties
.end();
79
}
80
81
void
ExternalFlagTaskFactory::registerPropertyInstances
(
OutputRegistry
& output_registry) {
82
output_registry.
registerPropertyInstances
<
ExternalFlag
>(
m_instance_names
);
83
if
(
m_is_output_requested
&&
m_instance_names
.
empty
()) {
84
throw
Elements::Exception
() <<
"Requested property ExternalFlag is not configured to produce any output"
;
85
}
86
}
87
88
}
// SourceXtractor namespace
89
90
91
ExternalFlagConfig.h
ExternalFlagTaskFactory.h
ExternalFlagTask.h
ExternalFlag.h
OutputConfig.h
Elements::Exception
Euclid::Configuration::ConfigManager
SourceXtractor::ExternalFlagConfig
Definition
ExternalFlagConfig.h:37
SourceXtractor::ExternalFlagConfig::Type::OR
@ OR
SourceXtractor::ExternalFlagConfig::Type::MAX
@ MAX
SourceXtractor::ExternalFlagConfig::Type::AND
@ AND
SourceXtractor::ExternalFlagConfig::Type::MOST
@ MOST
SourceXtractor::ExternalFlagConfig::Type::MIN
@ MIN
SourceXtractor::ExternalFlagTaskFactory::registerPropertyInstances
void registerPropertyInstances(OutputRegistry &) override
Definition
ExternalFlagTaskFactory.cpp:81
SourceXtractor::ExternalFlagTaskFactory::m_is_output_requested
bool m_is_output_requested
Definition
ExternalFlagTaskFactory.h:60
SourceXtractor::ExternalFlagTaskFactory::propertyName
static const char propertyName[]
Definition
ExternalFlagTaskFactory.h:42
SourceXtractor::ExternalFlagTaskFactory::reportConfigDependencies
void reportConfigDependencies(Euclid::Configuration::ConfigManager &manager) const override
Registers all the Configuration dependencies.
Definition
ExternalFlagTaskFactory.cpp:34
SourceXtractor::ExternalFlagTaskFactory::configure
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.
Definition
ExternalFlagTaskFactory.cpp:64
SourceXtractor::ExternalFlagTaskFactory::m_instance_names
std::vector< std::pair< std::string, unsigned int > > m_instance_names
Definition
ExternalFlagTaskFactory.h:58
SourceXtractor::ExternalFlagTaskFactory::createTask
std::shared_ptr< Task > createTask(const PropertyId &property_id) const override
Returns a Task producing a Property corresponding to the given PropertyId.
Definition
ExternalFlagTaskFactory.cpp:40
SourceXtractor::ExternalFlagTaskFactory::m_flag_info_map
std::map< PropertyId, ExternalFlagConfig::FlagInfo > m_flag_info_map
Definition
ExternalFlagTaskFactory.h:57
SourceXtractor::ExternalFlag
Definition
ExternalFlag.h:46
SourceXtractor::OutputConfig
Definition
OutputConfig.h:36
SourceXtractor::OutputRegistry
Definition
OutputRegistry.h:37
SourceXtractor::OutputRegistry::registerPropertyInstances
void registerPropertyInstances(const std::vector< std::pair< std::string, unsigned int > > &instance_names)
Definition
OutputRegistry.h:64
SourceXtractor::PropertyId
Identifier used to set and retrieve properties.
Definition
PropertyId.h:40
std::vector::emplace_back
T emplace_back(T... args)
std::vector::empty
T empty(T... args)
std::find
T find(T... args)
std::function
SourceXtractor
Definition
Aperture.h:30
std::pair
Generated by
1.10.0