DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::config::api::graph::linked::through Namespace Reference

Functions

template<typename T>
std::vector< T > relations (tref const &item)
template<typename T>
std::vector< T > attributes (tref const &item)
template<typename T>
T relation (tref item, dunedaq::conffwk::relationship_t const &relation)
template<typename T>
T attribute (tref item, dunedaq::conffwk::attribute_t const &attr)
template<>
tref attribute< tref > (tref object, dunedaq::conffwk::attribute_t const &attr)
template<>
std::vector< tref > attribute< std::vector< tref > > (tref item, dunedaq::conffwk::attribute_t const &attr)
template<>
tref relation< tref > (tref object, dunedaq::conffwk::relationship_t const &r)
template<>
std::vector< tref > relation< std::vector< tref > > (tref item, dunedaq::conffwk::relationship_t const &r)
template<>
QStringList relation< QStringList > (tref item, dunedaq::conffwk::relationship_t const &r)
template<>
std::vector< dbe::config_object_description< std::string > > relation< std::vector< dbe::config_object_description< std::string > > > (tref object, dunedaq::conffwk::relationship_t const &relation)

Function Documentation

◆ attribute()

template<typename T>
T dbe::config::api::graph::linked::through::attribute ( tref item,
dunedaq::conffwk::attribute_t const & attr )

Get object reference/s through a specified attribute

e.g. A-C->B

returns B for object A through relation C

Parameters
itemis the object to retrieve the relation value
relationis the relation to retrieve the value for
Returns
the value of the relation converted to the specified type

◆ attribute< std::vector< tref > >()

template<>
std::vector< tref > dbe::config::api::graph::linked::through::attribute< std::vector< tref > > ( tref item,
dunedaq::conffwk::attribute_t const & attr )

Definition at line 42 of file config_api_graph.cpp.

51{
52 if (attr.p_type == dunedaq::conffwk::class_type) {
53 if (attr.p_is_multi_value) {
54 std::vector<tref> adj;
55 item.get(attr.p_name, adj);
56 return adj;
57 } else if (attr.p_is_not_null) {
58 try {
59 return { attribute<tref>(item, attr) };
60 } catch (daq::dbe::config_object_retrieval_result_is_null const& e) {
61 if (attr.p_is_not_null) {
62 WARN("Query returned null value for an attr that has p_is_not_null set true",
63 "Program parsing data validation failure",
64 item.full_name(),
65 " for attribute ",
66 attr.p_name);
67 } else {
68 DEBUG("Query returned null value", "Program parsing data validation");
69 }
70 }
71 }
72 }
73
74 return {};
75}
#define WARN(...)
Definition messenger.hpp:82
#define DEBUG(...)
tref attribute< tref >(tref object, dunedaq::conffwk::attribute_t const &attr)

◆ attribute< tref >()

Definition at line 42 of file config_api_graph.cpp.

44{
45 return object.get<tref>(attr.p_name);
46}
inner::configobject::tref tref
Definition tref.hpp:36

◆ attributes()

template<typename T>
template std::vector< tref > dbe::config::api::graph::linked::through::attributes< tref > ( tref const & item)

Get objects referenced by an object through any attributes

e.g. A-c->B , and another A-c->D returns {B,D} but A-c->B , A-d->B return {B}

Parameters
itemis the object for which objects must be retrieved
Returns
a vector of linked objects

Definition at line 185 of file config_api_graph.cpp.

186{
187 dunedaq::conffwk::class_t classdef{ info::onclass::definition(o.class_name(), true) };
188
189 std::vector<T> voisins;
190
191 for (dunedaq::conffwk::attribute_t const& attr : classdef.p_attributes) {
192 std::vector<tref> a = attribute<std::vector<T>>(o, attr);
193 voisins.insert(voisins.end(), a.begin(), a.end());
194 }
195
196 voisins.erase(std::unique(std::begin(voisins), std::end(voisins)), std::end(voisins));
197 return voisins;
198}
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)
T attribute(tref item, dunedaq::conffwk::attribute_t const &attr)
const std::vector< attribute_t > p_attributes
Definition Schema.hpp:161

◆ relation()

template<typename T>
T dbe::config::api::graph::linked::through::relation ( tref item,
dunedaq::conffwk::relationship_t const & relation )

Get object reference/s through a specified relation

e.g. A-C->B

returns B for object A through relation C

Parameters
itemis the object to retrieve the relation value
relationis the relation to retrieve the value for
Returns
the value of the relation converted to the specified type

◆ relation< QStringList >()

template<>
template QStringList dbe::config::api::graph::linked::through::relation< QStringList > ( tref item,
dunedaq::conffwk::relationship_t const & r )

Definition at line 107 of file config_api_graph.cpp.

109{
110 QStringList result;
111 std::vector<tref> adjacent = relation<std::vector<tref>>(item, r);
112
113 for (auto const& x : adjacent) {
114 result.push_back(x.UID().c_str());
115 }
116
117 return result;
118}
T relation(tref item, dunedaq::conffwk::relationship_t const &relation)

◆ relation< std::vector< dbe::config_object_description< std::string > > >()

template<>
std::vector< dbe::config_object_description< std::string > > dbe::config::api::graph::linked::through::relation< std::vector< dbe::config_object_description< std::string > > > ( tref object,
dunedaq::conffwk::relationship_t const & relation )

Definition at line 107 of file config_api_graph.cpp.

124{
125 std::vector<dbe::config_object_description<std::string>> result;
126
127 std::vector<tref> adjacent = linked::through::relation<std::vector<tref>>(object, relation);
128
129 for (auto const& x : adjacent) {
130 result.push_back(x);
131 }
132
133 return result;
134}

◆ relation< std::vector< tref > >()

template<>
std::vector< tref > dbe::config::api::graph::linked::through::relation< std::vector< tref > > ( tref item,
dunedaq::conffwk::relationship_t const & r )

Definition at line 83 of file config_api_graph.cpp.

92{
94 try {
95 return { through::relation<tref>(item, r) };
96 } catch (daq::dbe::config_object_retrieval_result_is_null const& e) {
97 return {};
98 }
99 } else {
100 std::vector<tref> adjacent;
101 item.get(r.p_name, adjacent);
102 return adjacent;
103 }
104}
tref relation< tref >(tref object, dunedaq::conffwk::relationship_t const &r)
bool is_simple(dunedaq::conffwk::relationship_t const &)

◆ relation< tref >()

Definition at line 83 of file config_api_graph.cpp.

85{
86 return object.get<tref>(r.p_name);
87}

◆ relations()

template<typename T>
template std::vector< tref > dbe::config::api::graph::linked::through::relations< tref > ( tref const & item)

Get objects referenced by an object through any relation

e.g. A-c->B , and another A-c->D returns {B,D} but A-c->B , A-d->B return {B}

Parameters
itemis the object for which objects must be retrieved
Returns
a vector of linked objects

Definition at line 163 of file config_api_graph.cpp.

164{
165 dunedaq::conffwk::class_t classdef{ info::onclass::definition(o.class_name(), false) };
166
167 std::vector<T> voisins;
168
169 for (dunedaq::conffwk::relationship_t const& r : classdef.p_relationships) {
170 std::vector<T> a = relation<std::vector<T>>(o, r);
171 voisins.insert(voisins.end(), a.begin(), a.end());
172 }
173
174 voisins.erase(std::unique(std::begin(voisins), std::end(voisins)), std::end(voisins));
175 return voisins;
176}
const std::vector< relationship_t > p_relationships
Definition Schema.hpp:162