SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
OutputRegistry.h
Go to the documentation of this file.
1
17/*
18 * @file OutputRegistry.h
19 * @author nikoapos
20 */
21
22#ifndef _SEFRAMEWORK_OUTPUTREGISTRY_H
23#define _SEFRAMEWORK_OUTPUTREGISTRY_H
24
25#include <functional>
26#include <map>
27#include <set>
28#include <string>
29#include <typeindex>
30#include <vector>
31
32#include "Table/Row.h"
34
35namespace SourceXtractor {
36
38
39public:
40
41 template <typename PropertyType, typename OutType>
43
45
46 template <typename PropertyType, typename OutType>
56
63 template <typename PropertyType>
67 // Get the current converter
68 auto converter = m_name_to_converter_map.at(current_name);
70 // Remove the old converter
71 // Do it *before*, because the new name may be the same!
74
75 // Add the new ones
76 for (auto instance : instance_names) {
77 // Make a copy of the converter and set the index
78 auto new_converter = converter;
79 new_converter.second.index = instance.second;
80 // Register the new converter with the new name
81 auto& postfix = instance.first;
82 auto new_name = current_name + "_" + postfix;
85 new_names.push_back(new_name);
86 }
87 }
88 // Replace all the old names with the new ones
90 }
91
99 template <typename PropertyType>
102 // Get the current converter
103 auto converter = m_name_to_converter_map.at(current_name);
105 // Remove the old converter
106 // Do it *before*, because the new name may be the same!
109
110 // Add the new ones
111 for (auto instance : instance_names) {
112 // Make a copy of the converter and set the index
113 auto new_converter = converter;
114 new_converter.second.index = instance.second;
115 // Register the new converter with the new name
116 auto& new_name = instance.first;
119 new_names.push_back(new_name);
120 }
121
122 // Replace all the old names with the new ones
124 names.erase(std::find(names.begin(), names.end(), current_name));
126 }
127
141 template <typename PropertyType>
144 throw Elements::Exception() << "No registered ColumnConverters for"
145 << " property " << typeid(PropertyType).name();
146 }
148 }
149
152 for (auto& pair : m_output_properties) {
153 result.emplace(pair.first);
154 }
155 return result;
156 }
157
159
161
162private:
163
165 public:
166 template <typename PropertyType, typename OutType>
168 m_convert_func = [converter](const SourceInterface& source, std::size_t i){
169 return converter(source.getProperty<PropertyType>(i));
170 };
171 }
176 private:
178 };
179
184
189
190};
191
192} /* namespace SourceXtractor */
193
194#endif /* _SEFRAMEWORK_OUTPUTREGISTRY_H */
195
T back_inserter(T... args)
boost::variant< bool, int32_t, int64_t, float, double, std::string, std::vector< bool >, std::vector< int32_t >, std::vector< int64_t >, std::vector< float >, std::vector< double >, NdArray::NdArray< int32_t >, NdArray::NdArray< int64_t >, NdArray::NdArray< float >, NdArray::NdArray< double > > cell_type
ColumnFromSource(ColumnConverter< PropertyType, OutType > converter)
Euclid::Table::Row::cell_type operator()(const SourceInterface &source)
std::function< Euclid::Table::Row::cell_type(const SourceInterface &, std::size_t index) m_convert_func)
std::map< std::string, ColInfo > m_name_to_col_info_map
void registerColumnConverter(std::string column_name, ColumnConverter< PropertyType, OutType > converter, std::string column_unit="", std::string column_description="")
void enableOutput(std::string alias_name, bool configurable_output=false)
SourceToRowConverter getSourceToRowConverter(const std::vector< std::string > &enabled_optional)
std::multimap< std::string, std::type_index > m_output_properties
std::set< std::string > getOutputPropertyNames()
void registerPropertyInstances(const std::string &current_name, const std::vector< std::pair< std::string, unsigned int > > &instance_names)
std::function< Euclid::Table::Row(const SourceInterface &)> SourceToRowConverter
std::map< std::string, std::pair< std::type_index, ColumnFromSource > > m_name_to_converter_map
std::map< std::type_index, std::vector< std::string > > m_property_to_names_map
void registerPropertyInstances(const std::vector< std::pair< std::string, unsigned int > > &instance_names)
void printPropertyColumnMap(const std::vector< std::string > &properties={})
The SourceInterface is an abstract "source" that has properties attached to it.
T copy(T... args)
T count(T... args)
T emplace(T... args)
T find(T... args)