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 75 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 32 of file config_api.hpp.

33{
35 type_cmap const & baseclasses = dbaccessor::dbptr()->superclasses();
36
37 T config_class_list;
38
39 std::transform ( baseclasses.begin(), baseclasses.end(),
40 std::back_inserter ( config_class_list ),
41 [] ( type_cmap::value_type const & element )
42 {
43 return element.first->c_str();
44 } );
45
46 if ( not config_class_list.empty() )
47 {
48 std::sort ( std::begin ( config_class_list ), std::end ( config_class_list ) );
49 }
50
51 return config_class_list;
52}
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 111 of file config_api_info.cpp.

112{
113 try
114 {
115 return dbaccessor::dbptr()->get_class_info ( cn, direct_only );
116 }
117 catch ( dunedaq::conffwk::NotFound const & Ex )
118 {
120 }
121}
Try to access non-existent object or class.
Definition Errors.hpp:47

◆ 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 76 of file config_api_info.cpp.

77{
80
81 for ( std::string const & x : aclassdef.p_superclasses )
82 {
83 if ( fromclass == x )
84 {
85 return true;
86 }
87 }
88
89 return false;
90}
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)

◆ 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 1 of file config_api_info.cpp.

33{
34 std::vector<dbe::tref> objectrefs = inner::dbcontroller::gets ( cname );
35
36 if ( not keep_inherited )
37 {
38 objectrefs.erase (
39 std::remove_if ( objectrefs.begin(), objectrefs.end(),
40 [&cname] ( dbe::tref anobject )
41 {
42 return ( anobject.class_name() != cname );
43 } ),
44 objectrefs.end() );
45 }
46
47 std::sort ( objectrefs.begin(), objectrefs.end(), SortObjects() );
48
49 return objectrefs;
50}
static std::vector< configobject::tref > gets(std::string const &cname, std::string const &query="")

◆ 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 51 of file config_api_info.cpp.

56{
57 std::vector<dbe::tref> objectrefs = inner::dbcontroller::gets ( cname );
58
59 if ( not keep_inherited )
60 {
61 objectrefs.erase (
62 std::remove_if ( objectrefs.begin(), objectrefs.end(),
63 [&cname] ( dbe::tref anobject )
64 {
65 return ( anobject.class_name() != cname );
66 } ),
67 objectrefs.end() );
68 }
69
70 return objectrefs;
71}

◆ objects() [3/3]

template<bool SORTED = true>
static 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: