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

75{
76 try
77 {
78 std::string const description
79 { "Object deleted : " + obj.UID() + "@" + obj.class_name()
80 };
82 { config_internal_change::DELETED, description, obj.UID(), obj.class_name() };
83 confaccessor::get_commands()->push ( new dbe::actions::object::remove ( obj, src ) );
84 confaccessor::get_internal_change_stack()->push ( request );
85 }
86 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
87 {
88 INFO ( "Delete Object: The object could not be deleted!\n\n", dbe::config::errors::parse ( dbe_err ).c_str() );
89 return false;
90 }
91
92 return true;
93}
#define INFO(...)
Definition messenger.hpp:96
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 155 of file config_api_commands.cpp.

157{
158 try
159 {
160 confaccessor::get_commands()->push (
161 new dbe::actions::object::changerefs ( object, linkinfo, others_names ) );
162 std::string
163 const description (
164 others_names.size() != 1 ? "Multi Relationship : " + linkinfo.p_name :
165 "Single Relationship : " + linkinfo.p_name );
166
167 config_internal_change const change
168 {
169 config_internal_change::MODIFIED, description, object.UID(), object.class_name()
170 };
171
172 confaccessor::get_internal_change_stack()->push ( change );
173 }
174 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
175 {
176 WARN ( "The object reference could not be changed", dbe::config::errors::parse ( dbe_err ).c_str() );
177 }
178}
#define WARN(...)
Definition messenger.hpp:80

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

111{
112 try
113 {
114 std::string const description = std::string ( "Attribute " ) + AttributeData.p_name;
115
117 {
119 description,
120 Object.UID(),
121 Object.class_name(),
122 Object.contained_in() };
123
124 confaccessor::get_commands()->push (
125 new dbe::actions::ChangeAttribute<T> ( Object, AttributeData, Value ) );
126 confaccessor::get_internal_change_stack()->push ( Change );
127
128 }
129 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & dbe_err )
130 {
131 WARN ( "The object attribute could not be changed", dbe::config::errors::parse ( dbe_err ).c_str() );
132 }
133 catch ( dunedaq::conffwk::Exception const & e )
134 {
135 WARN ( "Change Attribute: The attribute could not be changed",
136 dbe::config::errors::parse ( e ).c_str() );
137 }
138}

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

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

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

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

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

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

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

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

59{
60 std::string description
61 { "Object created : " + name + "@" + cn };
62
64 { config_internal_change::CREATED, description, name, cn };
65
66 confaccessor::get_commands()->push (
67 new dbe::actions::object::create ( { attributes, relations, { name, cn}, fn }, src ) );
68
69 confaccessor::get_internal_change_stack()->push ( request );
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 97 of file config_api_commands.cpp.

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