DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::config::api::info::onclass Class Reference

#include <config_api_info.hpp>

Static Public Member Functions

template<typename T>
static T allnames ()
static dunedaq::conffwk::class_t definition (std::string const &cn, bool direct_only)
template<bool SORTED = true>
static std::vector< dbe::inner::configobject::trefobjects (std::string const &cname, bool const keep_inherited=true)
static bool derived (std::string const &fromclass, std::string const &aclass)
template<>
std::vector< dbe::trefobjects (std::string const &cname, bool const keep_inherited)
template<>
std::vector< dbe::trefobjects (std::string const &cname, bool const keep_inherited)

Detailed Description

Definition at line 80 of file config_api_info.hpp.

Member Function Documentation

◆ allnames()

template<typename T>
T dbe::config::api::info::onclass::allnames ( )
inlinestatic

Get a list of all classes defined in the database

Returns

Definition at line 37 of file config_api.hpp.

38{
39 typedef dunedaq::conffwk::fmap<dunedaq::conffwk::fset> type_cmap;
40 type_cmap const & baseclasses = dbaccessor::dbptr()->superclasses();
41
42 T config_class_list;
43
44 std::transform ( baseclasses.begin(), baseclasses.end(),
45 std::back_inserter ( config_class_list ),
46 [] ( type_cmap::value_type const & element )
47 {
48 return element.first->c_str();
49 } );
50
51 if ( not config_class_list.empty() )
52 {
53 std::sort ( std::begin ( config_class_list ), std::end ( config_class_list ) );
54 }
55
56 return config_class_list;
57}
static cptr< dunedaq::conffwk::Configuration > dbptr()

◆ definition()

dunedaq::conffwk::class_t dbe::config::api::info::onclass::definition ( std::string const & cn,
bool direct_only )
static

Get class information from class name

Parameters
cnis the class name to retrieve information for
determinesif class information should include direct-only relation, attribute , sub-class and superclass information
Returns
a class information object

Definition at line 116 of file config_api_info.cpp.

117{
118 try
119 {
120 return dbaccessor::dbptr()->get_class_info ( cn, direct_only );
121 }
122 catch ( dunedaq::conffwk::NotFound const & Ex )
123 {
124 return dunedaq::conffwk::class_t();
125 }
126}

◆ derived()

bool dbe::config::api::info::onclass::derived ( std::string const & fromclass,
std::string const & aclass )
static

Determine if a class is derived from another

Parameters
fromclassis the classname of the class the we want to see if a class is derived from
aclassis the classname of the candidate class to be derived from inclass
Returns
true if aclass is derived fromclass

Definition at line 81 of file config_api_info.cpp.

82{
83 dunedaq::conffwk::class_t aclassdef
85
86 for ( std::string const & x : aclassdef.p_superclasses )
87 {
88 if ( fromclass == x )
89 {
90 return true;
91 }
92 }
93
94 return false;
95}
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)
const std::vector< std::string > p_superclasses
Definition Schema.hpp:168

◆ objects() [1/3]

template<>
std::vector< dbe::tref > dbe::config::api::info::onclass::objects ( std::string const & cname,
bool const keep_inherited )
static

Definition at line 56 of file config_api_info.cpp.

61{
62 std::vector<dbe::tref> objectrefs = inner::dbcontroller::gets ( cname );
63
64 if ( not keep_inherited )
65 {
66 objectrefs.erase (
67 std::remove_if ( objectrefs.begin(), objectrefs.end(),
68 [&cname] ( dbe::tref anobject )
69 {
70 return ( anobject.class_name() != cname );
71 } ),
72 objectrefs.end() );
73 }
74
75 return objectrefs;
76}
static std::vector< configobject::tref > gets(std::string const &cname, std::string const &query="")
inner::configobject::tref tref
Definition tref.hpp:35

◆ objects() [2/3]

template<>
std::vector< dbe::tref > dbe::config::api::info::onclass::objects ( std::string const & cname,
bool const keep_inherited )
static

Definition at line 1 of file config_api_info.cpp.

38{
39 std::vector<dbe::tref> objectrefs = inner::dbcontroller::gets ( cname );
40
41 if ( not keep_inherited )
42 {
43 objectrefs.erase (
44 std::remove_if ( objectrefs.begin(), objectrefs.end(),
45 [&cname] ( dbe::tref anobject )
46 {
47 return ( anobject.class_name() != cname );
48 } ),
49 objectrefs.end() );
50 }
51
52 std::sort ( objectrefs.begin(), objectrefs.end(), SortObjects() );
53
54 return objectrefs;
55}

◆ objects() [3/3]

template<bool SORTED = true>
std::vector< dbe::inner::configobject::tref > dbe::config::api::info::onclass::objects ( std::string const & cname,
bool const keep_inherited = true )
static

Retrieve references to config objects of a given class

Parameters
cnameis the class name to retrieve objects for
keep_inheritedif set to false filters out any objects inherited from this class
Returns
a vector of references

The documentation for this class was generated from the following files: