SourceXtractorPlusPlus  0.12
Please provide a description of the project.
ExternalFlagTaskFactory.cpp
Go to the documentation of this file.
1 
24 
29 
30 namespace SourceXtractor {
31 
32 const char ExternalFlagTaskFactory::propertyName[] = "ExternalFlags";
33 
37 }
38 
39 
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) {
48  return std::make_shared<ExternalFlagTaskOr>(flag_info.first, property_id.getIndex());
50  return std::make_shared<ExternalFlagTaskAnd>(flag_info.first, property_id.getIndex());
52  return std::make_shared<ExternalFlagTaskMin>(flag_info.first, property_id.getIndex());
54  return std::make_shared<ExternalFlagTaskMax>(flag_info.first, property_id.getIndex());
56  return std::make_shared<ExternalFlagTaskMost>(flag_info.first, property_id.getIndex());
57  }
58  }
59 
60  return nullptr;
61 }
62 
63 
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);
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 
84  throw Elements::Exception() << "Requested property ExternalFlag is not configured to produce any output";
85  }
86 }
87 
88 } // SourceXtractor namespace
89 
90 
91 
void reportConfigDependencies(Euclid::Configuration::ConfigManager &manager) const override
Registers all the Configuration dependencies.
void registerPropertyInstances(const std::vector< std::pair< std::string, unsigned int >> &instance_names)
unsigned int getIndex() const
Definition: PropertyId.h:70
virtual std::shared_ptr< Task > createTask(const PropertyId &property_id) const override
Returns a Task producing a Property corresponding to the given PropertyId.
void registerPropertyInstances(OutputRegistry &) override
const std::vector< std::string > getOutputProperties()
std::map< PropertyId, ExternalFlagConfig::FlagInfo > m_flag_info_map
std::vector< std::pair< std::string, unsigned int > > m_instance_names
T find(T... args)
T size(T... args)
Identifier used to set and retrieve properties.
Definition: PropertyId.h:40
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.
T emplace_back(T... args)