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

Namespaces

namespace  file

Functions

template<class T>
void modobj (tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T Value)
template<>
void modobj< std::vector< std::string > > (tref Object, dunedaq::conffwk::attribute_t const &AttributeData, std::vector< std::string > Value)
void newobj (std::string const &fn, std::string const &class_name, std::string const &UID, dbe::t_config_object_preimage::type_attrmap const &attributes, dbe::t_config_object_preimage::type_relmap const &relations, QUuid const &src)
bool delobj (inner::configobject::tref obj, QUuid const &src)
bool renobj (inner::configobject::tref obj, std::string const &newuuid, QUuid const &src)
bool movobj (inner::configobject::tref obj, std::string const &destination, QUuid const &src)
void modobj (inner::configobject::tref obj, dunedaq::conffwk::relationship_t const &link, std::vector< std::string > const &others)
template<>
void modobj< std::string > (tref Object, const dunedaq::conffwk::attribute_t &AttributeData, std::string Value)
template<>
void modobj< std::vector< std::string > > (tref Object, const dunedaq::conffwk::attribute_t &AttributeData, std::vector< std::string > Value)

Function Documentation

◆ delobj()

bool dbe::config::api::commands::delobj ( inner::configobject::tref obj,
QUuid const & src )

Create a command that once activated it will delete an object and when undone will recreate the object from the database

emits an object_deleted signal

Parameters
objan object copy shadowing the one to be removed from the database
srcis the internal uuid of the object reqesting the change
Returns
false in case of error

Definition at line 75 of file config_api_commands.cpp.

76{
77 try {
78 std::string const description{ "Object deleted : " + obj.UID() + "@" + obj.class_name() };
79 config_internal_change request{ config_internal_change::DELETED, description, obj.UID(), obj.class_name(), "" };
82 } catch (daq::dbe::ObjectChangeWasNotSuccessful const& dbe_err) {
83 INFO("Delete Object: The object could not be deleted!\n\n", dbe::config::errors::parse(dbe_err).c_str());
84 return false;
85 }
86
87 return true;
88}
static t_undo_stack_cptr get_commands()
static t_internal_changes_stack_cptr get_internal_change_stack()
#define INFO(...)
Definition messenger.hpp:98
std::string const parse(ers::Issue const &)

◆ modobj() [1/2]

void dbe::config::api::commands::modobj ( inner::configobject::tref obj,
dunedaq::conffwk::relationship_t const & link,
std::vector< std::string > const & others )

Set a RELATION to new values , causes the Object and the objects designated by the new values to become linked

object -> others[x]

Parameters
objectthat holds the outgoing link [ -> ]
linkto set between object that others
othersare the objects to be connected to object

Definition at line 142 of file config_api_commands.cpp.

143{
144 try {
145 confaccessor::get_commands()->push(new dbe::actions::object::changerefs(object, linkinfo, others_names));
146 std::string const description(others_names.size() != 1 ? "Multi Relationship : " + linkinfo.p_name
147 : "Single Relationship : " + linkinfo.p_name);
148
149 config_internal_change const change{
150 config_internal_change::MODIFIED, description, object.UID(), object.class_name(), ""
151 };
152
154 } catch (daq::dbe::ObjectChangeWasNotSuccessful const& dbe_err) {
155 WARN("The object reference could not be changed", dbe::config::errors::parse(dbe_err).c_str());
156 }
157}
#define WARN(...)
Definition messenger.hpp:82

◆ modobj() [2/2]

template<class T>
void dbe::config::api::commands::modobj ( inner::configobject::tref obj,
dunedaq::conffwk::attribute_t const & attr,
T value )

Set an ATTRIBUTE to a specific value by generating appropriately modification commands

Parameters
objto be modified
attrprovides information about the attribute to be modified
valueto be assigned to the new object

Definition at line 97 of file config_api.hpp.

98{
99 try {
100 std::string const description = std::string("Attribute ") + AttributeData.p_name;
101
103 dbe::config_internal_change::MODIFIED, description, Object.UID(), Object.class_name(), Object.contained_in()
104 };
105
106 confaccessor::get_commands()->push(new dbe::actions::ChangeAttribute<T>(Object, AttributeData, Value));
108
109 } catch (daq::dbe::ObjectChangeWasNotSuccessful const& dbe_err) {
110 WARN("The object attribute could not be changed", dbe::config::errors::parse(dbe_err).c_str());
111 } catch (dunedaq::conffwk::Exception const& e) {
112 WARN("Change Attribute: The attribute could not be changed", dbe::config::errors::parse(e).c_str());
113 }
114}

◆ modobj< std::string >()

template<>
void dbe::config::api::commands::modobj< std::string > ( tref Object,
const dunedaq::conffwk::attribute_t & AttributeData,
std::string Value )

Definition at line 162 of file config_api_commands.cpp.

164{
165 try {
167 Change.uid = Object.UID();
168 Change.classname = Object.class_name();
170 Change.description = QString("Attribute ").append(AttributeData.p_name.c_str()).toStdString();
171
172 if (AttributeData.p_type == dunedaq::conffwk::string_type) {
173 confaccessor::get_commands()->push(new dbe::actions::ChangeAttribute<std::string>(Object, AttributeData, Value));
174 } else if (AttributeData.p_type == dunedaq::conffwk::enum_type) {
175 confaccessor::get_commands()->push(new dbe::actions::ChangeEnum<std::string>(Object, AttributeData, Value));
176 } else if (AttributeData.p_type == dunedaq::conffwk::class_type) {
177 confaccessor::get_commands()->push(new dbe::actions::ChangeClass<std::string>(Object, AttributeData, Value));
178 } else if (AttributeData.p_type == dunedaq::conffwk::date_type) {
179
180 confaccessor::get_commands()->push(new dbe::actions::ChangeDate<std::string>(Object, AttributeData, Value));
181 } else if (AttributeData.p_type == dunedaq::conffwk::time_type) {
182 confaccessor::get_commands()->push(new dbe::actions::ChangeTime<std::string>(Object, AttributeData, Value));
183 }
184
186 } catch (daq::dbe::ObjectChangeWasNotSuccessful const& dbe_err) {
187 WARN("The object attribute could not be changed", dbe::config::errors::parse(dbe_err).c_str());
188 }
189}
modification request
Type of modification.
std::string uid
Object Identification.

◆ modobj< std::vector< std::string > >() [1/2]

template<>
void dbe::config::api::commands::modobj< std::vector< std::string > > ( tref Object,
const dunedaq::conffwk::attribute_t & AttributeData,
std::vector< std::string > Value )

Definition at line 194 of file config_api_commands.cpp.

198{
199 try {
201 Change.uid = Object.UID();
202 Change.classname = Object.class_name();
204 Change.description = QString("Attribute ").append(AttributeData.p_name.c_str()).toStdString();
205
206 if (AttributeData.p_type == dunedaq::conffwk::string_type) {
208 new dbe::actions::ChangeAttribute<std::vector<std::string>>(Object, AttributeData, Value));
209 } else if (AttributeData.p_type == dunedaq::conffwk::enum_type) {
211 new dbe::actions::ChangeEnum<std::vector<std::string>>(Object, AttributeData, Value));
212 } else if (AttributeData.p_type == dunedaq::conffwk::class_type) {
214 new dbe::actions::ChangeClass<std::vector<std::string>>(Object, AttributeData, Value));
215 } else if (AttributeData.p_type == dunedaq::conffwk::date_type) {
217 new dbe::actions::ChangeDate<std::vector<std::string>>(Object, AttributeData, Value));
218 } else if (AttributeData.p_type == dunedaq::conffwk::time_type) {
220 new dbe::actions::ChangeTime<std::vector<std::string>>(Object, AttributeData, Value));
221 }
222
224 } catch (daq::dbe::ObjectChangeWasNotSuccessful const& dbe_err) {
225 WARN("The object attribute could not be changed", dbe::config::errors::parse(dbe_err).c_str());
226 }
227}

◆ modobj< std::vector< std::string > >() [2/2]

template<>
void dbe::config::api::commands::modobj< std::vector< std::string > > ( tref Object,
dunedaq::conffwk::attribute_t const & AttributeData,
std::vector< std::string > Value )

Definition at line 194 of file config_api_commands.cpp.

198{
199 try {
201 Change.uid = Object.UID();
202 Change.classname = Object.class_name();
204 Change.description = QString("Attribute ").append(AttributeData.p_name.c_str()).toStdString();
205
206 if (AttributeData.p_type == dunedaq::conffwk::string_type) {
208 new dbe::actions::ChangeAttribute<std::vector<std::string>>(Object, AttributeData, Value));
209 } else if (AttributeData.p_type == dunedaq::conffwk::enum_type) {
211 new dbe::actions::ChangeEnum<std::vector<std::string>>(Object, AttributeData, Value));
212 } else if (AttributeData.p_type == dunedaq::conffwk::class_type) {
214 new dbe::actions::ChangeClass<std::vector<std::string>>(Object, AttributeData, Value));
215 } else if (AttributeData.p_type == dunedaq::conffwk::date_type) {
217 new dbe::actions::ChangeDate<std::vector<std::string>>(Object, AttributeData, Value));
218 } else if (AttributeData.p_type == dunedaq::conffwk::time_type) {
220 new dbe::actions::ChangeTime<std::vector<std::string>>(Object, AttributeData, Value));
221 }
222
224 } catch (daq::dbe::ObjectChangeWasNotSuccessful const& dbe_err) {
225 WARN("The object attribute could not be changed", dbe::config::errors::parse(dbe_err).c_str());
226 }
227}

◆ movobj()

bool dbe::config::api::commands::movobj ( inner::configobject::tref obj,
std::string const & destination,
QUuid const & src )

Creates a command object holding move from current file to new file and undoing capabilities

Parameters
objan object copy shadowing the one to be moved
destinationthat the object is going to be moved to
Returns
true in case that the move was successful

Definition at line 118 of file config_api_commands.cpp.

119{
120 try {
121 std::string const description{ "Object " + obj.UID() + "@" + obj.class_name() + " contained in " +
122 obj.contained_in() + " moved to " + destination };
123
124 config_internal_change request{ config_internal_change::MOVED, description, obj.UID(), obj.class_name(), "" };
125
126 confaccessor::get_commands()->push(new dbe::actions::object::move(obj, destination, src));
128
129 return true;
130 } catch (daq::dbe::ObjectChangeWasNotSuccessful const& dbe_err) {
131 INFO("It was not possible to move object ",
132 dbe::config::errors::parse(dbe_err).c_str(),
133 "\n\nObject UID:",
134 obj.UID().c_str());
135 return false;
136 }
137}

◆ newobj()

void dbe::config::api::commands::newobj ( std::string const & fn,
std::string const & class_name,
std::string const & UID,
dbe::t_config_object_preimage::type_attrmap const & attributes,
dbe::t_config_object_preimage::type_relmap const & relations,
QUuid const & src )

Create a command that once activated will create an object and when undone it will remove the object from the database

emits an object_created signal

Parameters
fnis the file where it should be created
class_nameis the class it belongs to
UIDof the new UID of the object to be created
attributesis the attribute map
relationsis the relational map

Definition at line 55 of file config_api_commands.cpp.

61{
62 std::string description{ "Object created : " + name + "@" + cn };
63
64 config_internal_change request{ config_internal_change::CREATED, description, name, cn, "" };
65
67 new dbe::actions::object::create({ attributes, relations, { name, cn }, fn }, src));
68
70}

◆ renobj()

bool dbe::config::api::commands::renobj ( inner::configobject::tref obj,
std::string const & newuuid,
QUuid const & src )

Create a command that once activated will rename an object and when undone the object will be renamed to its old name.

emits an object_deleted signal

Parameters
objan object copy shadowing the one to be removed from the database
newuuidis the unique name assigned to the object
Returns
false in case of error

Definition at line 93 of file config_api_commands.cpp.

94{
95 try {
96 std::string const description = { "Object renamed : " + obj.UID() + "@" + obj.class_name() + " to " + newuuid +
97 "@" + obj.class_name() };
98
99 config_internal_change request{ config_internal_change::RENAMED, description, obj.UID(), obj.class_name(), "" };
100
101 confaccessor::get_commands()->push(new dbe::actions::object::rename(obj, newuuid, src));
102
104
105 return true;
106 } catch (daq::dbe::ObjectChangeWasNotSuccessful const& dbe_err) {
107 INFO("It was not possible to rename object ",
108 dbe::config::errors::parse(dbe_err).c_str(),
109 "\n\nObject UID:",
110 obj.UID().c_str());
111 return false;
112 }
113}