SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
src
lib
Output
OutputRegistry.cpp
Go to the documentation of this file.
1
17
/*
18
* File: OutputRegistry.cpp
19
* Author: nikoapos
20
*
21
* Created on July 28, 2016, 7:12 PM
22
*/
23
24
#include <algorithm>
25
26
#include "ElementsKernel/Exception.h"
27
28
#include "
SEFramework/Output/OutputRegistry.h
"
29
30
#include <iostream>
31
32
using namespace
Euclid::Table
;
33
34
namespace
SourceXtractor
{
35
36
auto
OutputRegistry::getSourceToRowConverter
(
const
std::vector<std::string>
&
enabled_properties
) ->
SourceToRowConverter
{
37
std::vector<std::type_index>
out_prop_list
{};
38
for
(
auto
&
prop
:
enabled_properties
) {
39
if
(m_output_properties.count(
prop
) == 0) {
40
throw
Elements::Exception
() <<
"Unknown output property "
<<
prop
;
41
}
42
auto
matching_properties
= m_output_properties.equal_range(
prop
);
43
for
(
auto
i
=
matching_properties
.first;
i
!=
matching_properties
.second; ++
i
) {
44
if
(
std::find
(
out_prop_list
.begin(),
out_prop_list
.end(),
i
->second) ==
out_prop_list
.end()) {
45
out_prop_list
.emplace_back(
i
->second);
46
}
47
}
48
}
49
return
[
this
,
out_prop_list
](
const
SourceInterface
&
source
) {
50
std::vector<ColumnInfo::info_type>
info_list
{};
51
std::vector<Row::cell_type>
cell_values
{};
52
for
(
const
auto
&
property
:
out_prop_list
) {
53
if
(m_property_to_names_map.count(
property
) == 0) {
54
throw
Elements::Exception
() <<
"Missing column generator for "
<<
property
.name();
55
}
56
for
(
const
auto
& name : m_property_to_names_map.at(
property
)) {
57
auto
&
col_info
= m_name_to_col_info_map.at(name);
58
info_list
.emplace_back(name, m_name_to_converter_map.at(name).first,
59
col_info
.unit,
col_info
.description);
60
cell_values
.emplace_back(m_name_to_converter_map.at(name).second(
source
));
61
}
62
}
63
if
(
info_list
.empty()) {
64
throw
Elements::Exception
() <<
"The given configuration would not generate any output"
;
65
}
66
return
Row
{
std::move
(
cell_values
),
std::make_shared<ColumnInfo>
(
move
(
info_list
))};
67
};
68
}
69
70
void
OutputRegistry::printPropertyColumnMap
(
const
std::vector<std::string>
&
properties
) {
71
std::set<std::string>
properties_set
{
properties
.begin(),
properties
.end()};
72
for
(
auto
&
prop
:
m_output_properties
) {
73
if
(!
properties
.empty() &&
properties_set
.find(
prop
.first) ==
properties_set
.end()) {
74
continue
;
75
}
76
std::cout
<<
prop
.first <<
":\n"
;
77
for
(
auto
&
col
:
m_property_to_names_map
.
at
(
prop
.second)) {
78
std::cout
<<
" - "
<<
col
;
79
auto
& info =
m_name_to_col_info_map
.at(
col
);
80
if
(info.description !=
""
) {
81
std::cout
<<
" : "
<< info.description;
82
}
83
if
(info.unit !=
""
) {
84
std::cout
<<
" "
<< info.unit <<
""
;
// place here braces "()" around the units, if desired
85
}
86
std::cout
<<
'\n'
;
87
}
88
}
89
}
90
91
92
}
OutputRegistry.h
std::map::at
T at(T... args)
std::cout
Elements::Exception
Euclid::Table::Row
SourceXtractor::OutputRegistry::m_name_to_col_info_map
std::map< std::string, ColInfo > m_name_to_col_info_map
Definition
OutputRegistry.h:187
SourceXtractor::OutputRegistry::getSourceToRowConverter
SourceToRowConverter getSourceToRowConverter(const std::vector< std::string > &enabled_optional)
Definition
OutputRegistry.cpp:36
SourceXtractor::OutputRegistry::m_output_properties
std::multimap< std::string, std::type_index > m_output_properties
Definition
OutputRegistry.h:188
SourceXtractor::OutputRegistry::m_property_to_names_map
std::map< std::type_index, std::vector< std::string > > m_property_to_names_map
Definition
OutputRegistry.h:185
SourceXtractor::OutputRegistry::printPropertyColumnMap
void printPropertyColumnMap(const std::vector< std::string > &properties={})
Definition
OutputRegistry.cpp:70
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition
SourceInterface.h:46
std::find
T find(T... args)
std::function
std::move
T move(T... args)
Euclid::Table
SourceXtractor
Definition
Aperture.h:30
Generated by
1.10.0