DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::inner::configobject::ref_interface< T > Class Template Reference

#include <config_reference.hpp>

Public Member Functions

bool is_null () const
 
std::string UID () const
 
std::string class_name () const
 
std::string full_name () const
 
std::string contained_in () const
 
template<typename U >
get (std::string const &key)
 
template<typename U >
void get (std::string const &key, U &val)
 
std::vector< T > referenced_by (std::string const &name="*", bool check_composite_only=true) const
 
void set_obj_null (std::string const &name, bool is_simple, bool skip_non_null_check=false)
 
void set_obj (std::string const &name, T const &other, bool skip_non_null_check=false)
 
void set_objs (std::string const &name, std::vector< T > const &others, bool skip_non_null_check=false)
 
template<typename U >
void set_by_val (std::string const &name, U val)
 
template<typename U >
void set_by_ref (std::string const &name, U &val)
 
void set_enum (std::string const &name, std::string const &val)
 
void set_class (std::string const &name, std::string const &val)
 
void set_date (std::string const &name, std::string const &val)
 
void set_time (std::string const &name, std::string const &val)
 
void set_enum (std::string const &name, const std::vector< std::string > &value)
 
void set_class (std::string const &name, const std::vector< std::string > &value)
 
void set_date (std::string const &name, const std::vector< std::string > &value)
 
void set_time (std::string const &name, const std::vector< std::string > &value)
 
void move (std::string const &at)
 
void print_ref (std::ostream &s, dunedaq::conffwk::Configuration &conf, const std::string &prefix="", bool show_contained_in=false) const
 Print details of object's attributes and relationships.
 

Protected Member Functions

template<typename U >
getdirect (std::string const &key) const
 

Private Member Functions

 operator dunedaq::conffwk::ConfigObject & () noexcept
 
 operator dunedaq::conffwk::ConfigObject & () const noexcept
 

Friends

template<typename X , typename U >
class authorized_getter
 
class dbe::inner::configobject::tref
 
class dbe::inner::configobject::vref
 
class dbe::inner::configobject::aref< T >
 
std::ostream & operator<< (std::ostream &os, dbe::inner::configobject::tref const &atref)
 

Detailed Description

template<typename T>
class dbe::inner::configobject::ref_interface< T >

Definition at line 148 of file config_reference.hpp.

Member Function Documentation

◆ class_name()

template<typename T >
std::string dbe::inner::configobject::ref_interface< T >::class_name ( ) const
inline

Definition at line 196 of file config_reference.hpp.

197 {
198 return static_cast<dunedaq::conffwk::ConfigObject &>(*this).class_name();
199 }
Represents database objects.
const std::string & class_name() const noexcept
Return object's class name.

◆ contained_in()

template<typename T >
std::string dbe::inner::configobject::ref_interface< T >::contained_in ( ) const
inline

Definition at line 206 of file config_reference.hpp.

207 {
208 return static_cast<dunedaq::conffwk::ConfigObject &>(*this).contained_in();
209 }
const std::string contained_in() const
Return the name of the database file this object belongs to.

◆ full_name()

template<typename T >
std::string dbe::inner::configobject::ref_interface< T >::full_name ( ) const
inline

Definition at line 201 of file config_reference.hpp.

202 {
203 return static_cast<dunedaq::conffwk::ConfigObject &>(*this).full_name();
204 }
const std::string full_name() const noexcept
Return full object name.

◆ get() [1/2]

template<typename T >
template<typename U >
U dbe::inner::configobject::ref_interface< T >::get ( std::string const & key)
inline

Retrieve values of type U referred by the given key

Parameters
keyis the attribute name
Returns
the value of type U referred by the named attribute

Definition at line 217 of file config_reference.hpp.

218 {
219 authorized_getter<T, U> guard(this);
220 return guard(key);
221 }

◆ get() [2/2]

template<typename T >
template<typename U >
void dbe::inner::configobject::ref_interface< T >::get ( std::string const & key,
U & val )
inline

Compatibility interface to support ConfigObject style queries

Parameters
keya string of what to look for
valis a reference to the object where the value of matching type will be placed

Definition at line 229 of file config_reference.hpp.

230 {
231 val = get<U>(key);
232 }

◆ getdirect()

template<typename T >
template<typename U >
U dbe::inner::configobject::ref_interface< T >::getdirect ( std::string const & key) const
inlineprotected

Retrieve values of type U referred by the given key

Parameters
keyis the attribute name
Returns
the value of type U referred by the named attribute

Definition at line 168 of file config_reference.hpp.

169 {
170 U value;
171 try
172 {
173 static_cast<dunedaq::conffwk::ConfigObject &>(*const_cast<ref_interface<T>*>(this)).get(key, value);
174 }
175 catch (dunedaq::conffwk::Exception const & e)
176 {
177 // TODO handle retrieval errors here
178 }
179 return value;
180 }

◆ is_null()

template<typename T >
bool dbe::inner::configobject::ref_interface< T >::is_null ( ) const
inline

Definition at line 186 of file config_reference.hpp.

187 {
188 return static_cast<dunedaq::conffwk::ConfigObject &>(static_cast<T const *>(this)->ref(false)).is_deleted();
189 }
bool is_deleted() const
Check if object was deleted.

◆ move()

template<typename T >
void dbe::inner::configobject::ref_interface< T >::move ( std::string const & at)
inline

Definition at line 327 of file config_reference.hpp.

328 {
329 static_cast<dunedaq::conffwk::ConfigObject &>(*this).move(at);
330 }
void move(const std::string &at)
Move object to a different database.

◆ operator dunedaq::conffwk::ConfigObject &() [1/2]

template<typename T >
dbe::inner::configobject::ref_interface< T >::operator dunedaq::conffwk::ConfigObject & ( ) const
inlineexplicitprivatenoexcept

Definition at line 156 of file config_reference.hpp.

157 {
158 return static_cast<T const *>(this)->ref();
159 }

◆ operator dunedaq::conffwk::ConfigObject &() [2/2]

template<typename T >
dbe::inner::configobject::ref_interface< T >::operator dunedaq::conffwk::ConfigObject & ( )
inlineexplicitprivatenoexcept

Definition at line 151 of file config_reference.hpp.

152 {
153 return static_cast<T*>(this)->ref();
154 }

◆ print_ref()

template<typename T >
void dbe::inner::configobject::ref_interface< T >::print_ref ( std::ostream & s,
dunedaq::conffwk::Configuration & conf,
const std::string & prefix = "",
bool show_contained_in = false ) const
inline

Print details of object's attributes and relationships.

Parameters
sthe output stream
confthe configuration object (required to read schema description)
prefixoptional shift output using prefix
show_contained_inoptional print out info about object database file

Definition at line 336 of file config_reference.hpp.

342 {
343 static_cast<dunedaq::conffwk::ConfigObject &>(*this).print_ref(s, conf, prefix, show_contained_in);
344 }
void print_ref(std::ostream &s, Configuration &conf, const std::string &prefix="", bool show_contained_in=false) const noexcept
Print details of object's attributes and relationships.

◆ referenced_by()

template<typename T >
template std::vector< tref > dbe::inner::configobject::ref_interface< T >::referenced_by ( std::string const & name = "*",
bool check_composite_only = true ) const

New method to retrieve reference to this object through some relation

Parameters
nameof of the relation to check references through to this object
check_composite_onlyenables checking of only composite parent objects
Returns
a list of objects referencing this

Definition at line 30 of file dbcontroller.cpp.

32{
33 std::vector<ConfigObject> referees;
34 std::vector<tref> result;
35
36 static_cast<ConfigObject &>(*this).referenced_by(referees, name, check_composite_only);
37
38 for (ConfigObject const & x : referees)
39 {
40 try
41 {
42 result.push_back(inner::dbcontroller::get(
43 { x.UID(), x.class_name() }));
44 }
45 catch (daq::dbe::config_object_retrieval_result_is_null const & e)
46 {
47 // Nothing needed to do here, this is normal, just the query has resulted in null
48 }
49 }
50
51 return result;
52}
static configobject::tref get(dbe::cokey const &desc)
void referenced_by(std::vector< ConfigObject > &value, const std::string &relationship_name="*", bool check_composite_only=true, unsigned long rlevel=0, const std::vector< std::string > *rclasses=nullptr) const
Get objects which have references to given object.

◆ set_by_ref()

template<typename T >
template<typename U >
void dbe::inner::configobject::ref_interface< T >::set_by_ref ( std::string const & name,
U & val )
inline

Definition at line 282 of file config_reference.hpp.

283 {
284 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_by_ref(name, val);
285 }
void set_by_ref(const std::string &name, T &value)
Set attribute value.

◆ set_by_val()

template<typename T >
template<typename U >
void dbe::inner::configobject::ref_interface< T >::set_by_val ( std::string const & name,
U val )
inline

Definition at line 277 of file config_reference.hpp.

278 {
279 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_by_val(name, val);
280 }
void set_by_val(const std::string &name, T value)
Set attribute value.

◆ set_class() [1/2]

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_class ( std::string const & name,
const std::vector< std::string > & value )
inline

Definition at line 312 of file config_reference.hpp.

313 {
314 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_class(name, value);
315 }
void set_class(const std::string &name, const std::string &value)
Set attribute class value.

◆ set_class() [2/2]

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_class ( std::string const & name,
std::string const & val )
inline

Definition at line 292 of file config_reference.hpp.

293 {
294 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_class(name, val);
295 }

◆ set_date() [1/2]

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_date ( std::string const & name,
const std::vector< std::string > & value )
inline

Definition at line 317 of file config_reference.hpp.

318 {
319 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_date(name, value);
320 }
void set_date(const std::string &name, const std::string &value)
Set attribute date value.

◆ set_date() [2/2]

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_date ( std::string const & name,
std::string const & val )
inline

Definition at line 297 of file config_reference.hpp.

298 {
299 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_date(name, val);
300 }

◆ set_enum() [1/2]

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_enum ( std::string const & name,
const std::vector< std::string > & value )
inline

Definition at line 307 of file config_reference.hpp.

308 {
309 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_enum(name, value);
310 }
void set_enum(const std::string &name, const std::string &value)
Set attribute enumeration value.

◆ set_enum() [2/2]

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_enum ( std::string const & name,
std::string const & val )
inline

Definition at line 287 of file config_reference.hpp.

288 {
289 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_enum(name, val);
290 }

◆ set_obj()

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_obj ( std::string const & name,
T const & other,
bool skip_non_null_check = false )
inline

Definition at line 255 of file config_reference.hpp.

257 {
258 static_cast<dunedaq::conffwk::ConfigObject &> ( *this ).set_obj ( name,
259 &static_cast<dunedaq::conffwk::ConfigObject &> ( other ),
260 skip_non_null_check);
261 }
void set_obj(const std::string &name, const ConfigObject *o, bool skip_non_null_check=false)
Set relationship single-value.

◆ set_obj_null()

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_obj_null ( std::string const & name,
bool is_simple,
bool skip_non_null_check = false )
inline

Definition at line 244 of file config_reference.hpp.

245 {
246 if(is_simple)
247 {
248 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_obj(name, nullptr, skip_non_null_check);
249 } else
250 {
251 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_objs(name, {}, skip_non_null_check);
252 }
253 }
void set_objs(const std::string &name, const std::vector< const ConfigObject * > &o, bool skip_non_null_check=false)
Set relationship multi-value.

◆ set_objs()

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_objs ( std::string const & name,
std::vector< T > const & others,
bool skip_non_null_check = false )
inline

Definition at line 263 of file config_reference.hpp.

265 {
266 std::vector<dunedaq::conffwk::ConfigObject const *> configobjects;
267
268 std::transform(std::begin(others), std::end(others),
269 std::back_inserter(configobjects), [](T const & aref )
270 {
271 return &static_cast<dunedaq::conffwk::ConfigObject const &> ( aref );
272 } );
273
274 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_objs(name, configobjects, skip_non_null_check);
275 }
inner::configobject::aref< config_object_linked< std::string > > aref
Definition tref.hpp:32

◆ set_time() [1/2]

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_time ( std::string const & name,
const std::vector< std::string > & value )
inline

Definition at line 322 of file config_reference.hpp.

323 {
324 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_time(name, value);
325 }
void set_time(const std::string &name, const std::string &value)
Set attribute time value.

◆ set_time() [2/2]

template<typename T >
void dbe::inner::configobject::ref_interface< T >::set_time ( std::string const & name,
std::string const & val )
inline

Definition at line 302 of file config_reference.hpp.

303 {
304 static_cast<dunedaq::conffwk::ConfigObject &>(*this).set_time(name, val);
305 }

◆ UID()

template<typename T >
std::string dbe::inner::configobject::ref_interface< T >::UID ( ) const
inline

Definition at line 191 of file config_reference.hpp.

192 {
193 return static_cast<dunedaq::conffwk::ConfigObject &>(*this).UID();
194 }
const std::string & UID() const noexcept
Return object identity.

Friends And Related Symbol Documentation

◆ authorized_getter

template<typename T >
template<typename X , typename U >
friend class authorized_getter
friend

Definition at line 182 of file config_reference.hpp.

◆ dbe::inner::configobject::aref< T >

template<typename T >
friend class dbe::inner::configobject::aref< T >
friend

Definition at line 350 of file config_reference.hpp.

◆ dbe::inner::configobject::tref

template<typename T >
friend class dbe::inner::configobject::tref
friend

Definition at line 349 of file config_reference.hpp.

◆ dbe::inner::configobject::vref

template<typename T >
friend class dbe::inner::configobject::vref
friend

Definition at line 350 of file config_reference.hpp.

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream & os,
dbe::inner::configobject::tref const & atref )
friend

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