#include <dbcontroller.hpp>
Definition at line 24 of file dbcontroller.hpp.
◆ locker
◆ t_mutex
◆ t_object_handle
◆ t_object_key
◆ t_object_map
◆ dbcontroller() [1/2]
dbe::inner::dbcontroller::dbcontroller |
( |
| ) |
|
|
privatedefault |
◆ dbcontroller() [2/2]
dbe::inner::dbcontroller::dbcontroller |
( |
dbcontroller const & | | ) |
|
|
privatedelete |
◆ create_object_request() [1/4]
creates an object to the database that is described from an aref
- Parameters
-
obj | is an aref of an object, based on which the object is put onto the database |
- Returns
- return a tref to the resulting object
Definition at line 297 of file dbcontroller.cpp.
299{
301}
static configobject::tref create_object_request(dbe::t_config_object_preimage const &rep)
◆ create_object_request() [2/4]
◆ create_object_request() [3/4]
Create an object in the database by first creating its associated subgraph as described in a gref
- Parameters
-
objref | is the graph reference (gref) to the object |
- Returns
- a transaction reference to a tref
Definition at line 303 of file dbcontroller.cpp.
305{
306 return obj.rebuild();
307}
◆ create_object_request() [4/4]
Create a new configuration object from its representation
- Parameters
-
rep | is the representation, with attributes and relations included |
- Returns
Definition at line 271 of file dbcontroller.cpp.
273{
275 image.ref.this_class,
276 image.ref.this_name);
277
279 try
280 {
282 }
283 catch (dunedaq::conffwk::Exception const & e)
284 {
285
287 throw;
288 }
289 catch (daq::dbe::Exception const & e)
290 {
291
293 throw;
294 }
295}
static tref set_object(tref newobj, dbe::t_config_object_preimage::type_attrmap const &attributes, dbe::t_config_object_preimage::type_relmap const &relations)
static dunedaq::conffwk::ConfigObject create_object(std::string const &fn, std::string const &cn, std::string const &name)
static dbcontroller & ref()
configobject::gref< T > remove(dbe::tref ref)
configobject::tref insert(dunedaq::conffwk::ConfigObject const &)
Represents database objects.
config_object_aggregates config_object_aggregator
◆ delete_object_request() [1/2]
removes object from the database and returns an aref of the object before copying
- Parameters
-
obj | is a tref to the object that must be removed from the database |
◆ delete_object_request() [2/2]
Definition at line 244 of file dbcontroller.cpp.
247{
249 subgraph.notify(notice);
250 return subgraph;
251}
◆ flush()
void dbe::inner::dbcontroller::flush |
( |
| ) |
|
|
static |
Empties the internal cache and sets all associated objects to destroyed This results in all previously held references to be set to null
Definition at line 207 of file dbcontroller.cpp.
208{
211 me.this_allobjects.clear();
212}
std::lock_guard< t_mutex > locker
◆ get()
Retrieve an object from the database, and empty reference is retrieved if the object cannot be found in the database
- Parameters
-
desc | is a description of the object to be searched for in the database |
- Returns
- a transaction reference to the object in the database
Definition at line 383 of file dbcontroller.cpp.
384{
386}
configobject::tref lookup(dbe::cokey const &desc)
◆ gets()
std::vector< configobject::tref > dbe::inner::dbcontroller::gets |
( |
std::string const & | cname, |
|
|
std::string const & | query = "" ) |
|
static |
Retrieve all objects from the database of a specific class
- Parameters
-
cname | is the class name for which to retrieve classes |
- Returns
- a vector of references with the objects
Definition at line 388 of file dbcontroller.cpp.
390{
392 query);
393 std::vector<configobject::tref> result;
394
396 {
397 try
398 {
400 { keyin.UID(), keyin.class_name() }));
401 }
402 catch (daq::dbe::config_object_retrieval_result_is_null const & e)
403 {
404
405
406 }
407 }
408 return result;
409}
static std::vector< dunedaq::conffwk::ConfigObject > query_class(std::string const &classname, std::string const &query)
◆ insert()
Insert or replace a ConfigObject into the internal store
- Parameters
-
the | configuration object to insert, actually makes a copy of it |
- Returns
- a tref to the inserted copy of the object
Definition at line 439 of file dbcontroller.cpp.
440{
441
442 std::shared_ptr<configobject::oref> element(new configobject::oref(obj));
443
444 bool object_inserted;
445 t_object_map::iterator position;
446
448 std::tie(position, object_inserted) =
this_allobjects.emplace(*element, element);
449
450 if (not object_inserted)
451 {
452
453
455 }
456
457 return position->second;
458}
t_object_map this_allobjects
◆ lookup()
Searches for an object matching the criteria in the underlying database connection and then updates the internal map by comparing if it should be removed. All references to the object are transparently updated. If this cannot be done then they are replaced
- Parameters
-
the | configuration object to lookup for in the cache and the database |
- Returns
- the tref that points to that object in case of success , a null tref in case of failure
Definition at line 413 of file dbcontroller.cpp.
414{
415
417
419 {
420
422 key.this_name);
424 {
426 }
427 }
428 else
429 {
430 return position->second;
431 }
432
433 throw daq::dbe::config_object_retrieval_result_is_null (
ERS_HERE,
434 key.this_name + "@" + key.this_class );
435}
static dunedaq::conffwk::ConfigObject get_object(std::string const &, std::string const &)
bool is_null() const noexcept
Check if object's implementation points to null.
◆ move_object_request()
Move an object to a new database file
- Parameters
-
objref | is the tref of the associated ConfigObject to be moved to a new database file |
destfile | is the destination file where this object must be moved to |
- Returns
- a tref pointing to the resulting object, in case that there has been any type of relocation inside this is going to be different from the original. If there has been no relocation, i.e. in case of failure a null reference is returned
Definition at line 325 of file dbcontroller.cpp.
327{
328 if (not objref.is_null())
329 {
330 static_cast<ConfigObject &
>(*(objref.refered)).move(destfile);
331 }
332
333 return objref;
334}
◆ operator=()
◆ ref()
Obtain a reference to the dbcontroller
- Returns
Definition at line 199 of file dbcontroller.cpp.
200{
202 return self;
203}
◆ referenced_by()
std::vector< tref > dbe::inner::dbcontroller::referenced_by |
( |
configobject::tref | objref, |
|
|
std::string const & | name = "*", |
|
|
bool | check_composite_only = true ) |
|
private |
Return a list of references to the objects in the database that reference and object
- Parameters
-
objref | the tref to the object for which references are to be retrieved |
name | the name of the relation for which references are to be retrieved |
check_composite_only | return only composite connections |
- Returns
Definition at line 216 of file dbcontroller.cpp.
219{
220 std::vector<ConfigObject> linked;
221 objref.ref().referenced_by(linked, name, check_composite_only);
222
224
226 {
227 try
228 {
230 { anobj.UID(), anobj.class_name() }));
231 }
232 catch (daq::dbe::config_object_retrieval_result_is_null const & e)
233 {
234
235
236 }
237 }
238
240}
static configobject::tref get(dbe::cokey const &desc)
Only Configuration DB opened by rdbconfig or oksconflibs plug in can be const char *message Internal DBE references cannot point to null ConfigObject references
◆ remove()
Takes care of removing an object from the underlying implementation and setting all held references to it null . Performs check for derived objects having be removed.
- Parameters
-
the | configobject to remove from the underlying database |
- Returns
- returns a list of objects that have been removed from the database these are in a form that permits to recreate the deleted objects
Definition at line 462 of file dbcontroller.cpp.
463{
464 configobject::gref<T> subgraph;
465
466 {
468
469 if (not
ref.is_null())
470 {
471 subgraph.record(
ref);
472 }
473
474
475 for (T const & key : subgraph.this_remove_stack)
476 {
477
479 }
480 }
481
482
484
485 subgraph.post();
486
487 return subgraph;
488}
static void destroy_object(dunedaq::conffwk::ConfigObject &)
◆ rename()
Rename an object and update the internal cache
- Parameters
-
- Returns
Definition at line 346 of file dbcontroller.cpp.
348{
349 if (not objref.is_null())
350 {
351
352 std::shared_ptr<configobject::oref> current_ptr = objref.refered;
353
354
356 try
357 {
358
360 aname);
361 }
363 {
364
366 }
367
368 bool nofail;
369 t_object_map::iterator position;
370 std::tie(position, nofail) =
this_allobjects.emplace(*current_ptr, current_ptr);
371
372 if (not nofail)
373 {
374 throw daq::dbe::dbcontroller_internal_cache_failure(
ERS_HERE);
375 }
376 return position->second;
377 }
378 return objref;
379}
static void rename_object(dunedaq::conffwk::ConfigObject &object, std::string const &newname)
Generic configuration exception.
std::string const parse(ers::Issue const &)
◆ rename_object_request()
Rename an object in the database
- Parameters
-
objref | is a tref to the current object |
newname | is the new name of the object |
- Returns
- a tref pointing to the resulting object. In case of failure this results in returning a null reference. In rare cases there may be relocations that will change the reference.
Definition at line 338 of file dbcontroller.cpp.
340{
342}
configobject::tref rename(configobject::tref objref, std::string const &aname)
◆ configobject::tref
◆ this_allobjects
◆ this_lock
The documentation for this class was generated from the following files: