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 79 of file config_api_commands.cpp.

80{
81 try
82 {
83 std::string const description
84 { "Object deleted : " + obj.UID() + "@" + obj.class_name()
85 };
87 { config_internal_change::DELETED, description, obj.UID(), obj.class_name(), "" };
90 }
91 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
92 {
93 INFO ( "Delete Object: The object could not be deleted!\n\n", dbe::config::errors::parse ( dbe_err ).c_str() );
94 return false;
95 }
96
97 return true;
98}
static t_undo_stack_cptr get_commands()
static t_internal_changes_stack_cptr get_internal_change_stack()
#define INFO(...)
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 160 of file config_api_commands.cpp.

162{
163 try
164 {
166 new dbe::actions::object::changerefs ( object, linkinfo, others_names ) );
167 std::string
168 const description (
169 others_names.size() != 1 ? "Multi Relationship : " + linkinfo.p_name :
170 "Single Relationship : " + linkinfo.p_name );
171
172 config_internal_change const change
173 {
174 config_internal_change::MODIFIED, description, object.UID(), object.class_name(), ""
175 };
176
178 }
179 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
180 {
181 WARN ( "The object reference could not be changed", dbe::config::errors::parse ( dbe_err ).c_str() );
182 }
183}
#define WARN(...)
Definition messenger.hpp:85

◆ 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 115 of file config_api.hpp.

116{
117 try
118 {
119 std::string const description = std::string ( "Attribute " ) + AttributeData.p_name;
120
122 {
124 description,
125 Object.UID(),
126 Object.class_name(),
127 Object.contained_in() };
128
130 new dbe::actions::ChangeAttribute<T> ( Object, AttributeData, Value ) );
132
133 }
134 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
135 {
136 WARN ( "The object attribute could not be changed", dbe::config::errors::parse ( dbe_err ).c_str() );
137 }
138 catch ( dunedaq::conffwk::Exception const & e )
139 {
140 WARN ( "Change Attribute: The attribute could not be changed",
141 dbe::config::errors::parse ( e ).c_str() );
142 }
143}

◆ 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 188 of file config_api_commands.cpp.

190{
191 try
192 {
194 Change.uid = Object.UID();
195 Change.classname = Object.class_name();
197 Change.description = QString ( "Attribute " ).append ( AttributeData.p_name.c_str() )
198 .toStdString();
199
200 if ( AttributeData.p_type == dunedaq::conffwk::string_type )
201 {
203 new dbe::actions::ChangeAttribute<std::string> ( Object, AttributeData, Value ) );
204 }
205 else if ( AttributeData.p_type == dunedaq::conffwk::enum_type )
206 {
208 new dbe::actions::ChangeEnum<std::string> ( Object, AttributeData, Value ) );
209 }
210 else if ( AttributeData.p_type == dunedaq::conffwk::class_type )
211 {
213 new dbe::actions::ChangeClass<std::string> ( Object, AttributeData, Value ) );
214 }
215 else if ( AttributeData.p_type == dunedaq::conffwk::date_type )
216 {
217
219 new dbe::actions::ChangeDate<std::string> ( Object, AttributeData, Value ) );
220 }
221 else if ( AttributeData.p_type == dunedaq::conffwk::time_type )
222 {
224 new dbe::actions::ChangeTime<std::string> ( Object, AttributeData, Value ) );
225 }
226
228 }
229 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
230 {
231 WARN ( "The object attribute could not be changed", dbe::config::errors::parse ( dbe_err ).c_str() );
232 }
233}
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 238 of file config_api_commands.cpp.

241{
242 try
243 {
245 Change.uid = Object.UID();
246 Change.classname = Object.class_name();
248 Change.description = QString ( "Attribute " ).append ( AttributeData.p_name.c_str() )
249 .toStdString();
250
251 if ( AttributeData.p_type == dunedaq::conffwk::string_type )
252 {
254 new dbe::actions::ChangeAttribute<std::vector<std::string>> ( Object, AttributeData,
255 Value ) );
256 }
257 else if ( AttributeData.p_type == dunedaq::conffwk::enum_type )
258 {
260 new dbe::actions::ChangeEnum<std::vector<std::string>> ( Object, AttributeData,
261 Value ) );
262 }
263 else if ( AttributeData.p_type == dunedaq::conffwk::class_type )
264 {
266 new dbe::actions::ChangeClass<std::vector<std::string>> ( Object, AttributeData,
267 Value ) );
268 }
269 else if ( AttributeData.p_type == dunedaq::conffwk::date_type )
270 {
272 new dbe::actions::ChangeDate<std::vector<std::string>> ( Object, AttributeData,
273 Value ) );
274 }
275 else if ( AttributeData.p_type == dunedaq::conffwk::time_type )
276 {
278 new dbe::actions::ChangeTime<std::vector<std::string>> ( Object, AttributeData,
279 Value ) );
280 }
281
283 }
284 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
285 {
286 WARN ( "The object attribute could not be changed", dbe::config::errors::parse ( dbe_err ).c_str() );
287 }
288}

◆ 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 238 of file config_api_commands.cpp.

241{
242 try
243 {
245 Change.uid = Object.UID();
246 Change.classname = Object.class_name();
248 Change.description = QString ( "Attribute " ).append ( AttributeData.p_name.c_str() )
249 .toStdString();
250
251 if ( AttributeData.p_type == dunedaq::conffwk::string_type )
252 {
254 new dbe::actions::ChangeAttribute<std::vector<std::string>> ( Object, AttributeData,
255 Value ) );
256 }
257 else if ( AttributeData.p_type == dunedaq::conffwk::enum_type )
258 {
260 new dbe::actions::ChangeEnum<std::vector<std::string>> ( Object, AttributeData,
261 Value ) );
262 }
263 else if ( AttributeData.p_type == dunedaq::conffwk::class_type )
264 {
266 new dbe::actions::ChangeClass<std::vector<std::string>> ( Object, AttributeData,
267 Value ) );
268 }
269 else if ( AttributeData.p_type == dunedaq::conffwk::date_type )
270 {
272 new dbe::actions::ChangeDate<std::vector<std::string>> ( Object, AttributeData,
273 Value ) );
274 }
275 else if ( AttributeData.p_type == dunedaq::conffwk::time_type )
276 {
278 new dbe::actions::ChangeTime<std::vector<std::string>> ( Object, AttributeData,
279 Value ) );
280 }
281
283 }
284 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
285 {
286 WARN ( "The object attribute could not be changed", dbe::config::errors::parse ( dbe_err ).c_str() );
287 }
288}

◆ 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 132 of file config_api_commands.cpp.

133{
134 try
135 {
136 std::string const description
137 { "Object " + obj.UID() + "@" + obj.class_name() + " contained in " + obj.contained_in()
138 + " moved to " + destination
139 };
140
142 { config_internal_change::MOVED, description, obj.UID(), obj.class_name(), "" };
143
145 new dbe::actions::object::move ( obj, destination, src ) );
146 confaccessor::get_internal_change_stack()->push ( request );
147
148 return true;
149 }
150 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
151 {
152 INFO ( "It was not possible to move object ", dbe::config::errors::parse ( dbe_err ).c_str(), "\n\nObject UID:",
153 obj.UID().c_str() );
154 return false;
155 }
156}

◆ 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 61 of file config_api_commands.cpp.

64{
65 std::string description
66 { "Object created : " + name + "@" + cn };
67
69 { config_internal_change::CREATED, description, name, cn, "" };
70
72 new dbe::actions::object::create ( { attributes, relations, { name, cn}, fn }, src ) );
73
75}

◆ 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 102 of file config_api_commands.cpp.

103{
104 try
105 {
106 std::string const description =
107 {
108 "Object renamed : " + obj.UID() + "@" + obj.class_name() + " to " + newuuid + "@"
109 + obj.class_name()
110 };
111
113 { config_internal_change::RENAMED, description, obj.UID(), obj.class_name(), "" };
114
116 new dbe::actions::object::rename ( obj, newuuid, src ) );
117
118 confaccessor::get_internal_change_stack()->push ( request );
119
120 return true;
121 }
122 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
123 {
124 INFO ( "It was not possible to rename object ", dbe::config::errors::parse ( dbe_err ).c_str(), "\n\nObject UID:",
125 obj.UID().c_str() );
126 return false;
127 }
128}