DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::actions::object::rename Class Reference

#include <Command.hpp>

Inheritance diagram for dbe::actions::object::rename:
[legend]
Collaboration diagram for dbe::actions::object::rename:
[legend]

Public Member Functions

 rename (tref object, std::string const &Id, QUuid const &src=0, QUndoCommand *parent=nullptr)
void redo ()
void undo ()
Public Member Functions inherited from dbe::actions::onobject
 onobject (tref obj, QUndoCommand *parent=nullptr, QUuid const &uuid=0)
Public Member Functions inherited from dbe::actions::state
bool isvalid () const
void toggle ()
void failed () const
void setundoable (bool s=true) const
void setredoable (bool s=true) const
bool undoable () const
bool redoable () const
void reload () const
QUuid const & source () const

Private Attributes

std::string oldname
std::string newname

Additional Inherited Members

Protected Member Functions inherited from dbe::actions::onobject
tref checkedref () const
Protected Member Functions inherited from dbe::actions::state
 state (QUndoCommand *parent=nullptr, QUuid const &uuid=0)

Detailed Description

Definition at line 113 of file Command.hpp.

Constructor & Destructor Documentation

◆ rename()

dbe::actions::object::rename::rename ( tref object,
std::string const & Id,
QUuid const & src = 0,
QUndoCommand * parent = nullptr )

Definition at line 285 of file Command.cpp.

286 : onobject(object, parent, src)
287 , oldname(this->checkedref().UID())
288 , newname(Id)
289{
290 setText(QObject::tr("Object changed ID from %1 to %2").arg(this->checkedref().UID().c_str()).arg(newname.c_str()));
291}
tref checkedref() const
Definition Command.cpp:412
onobject(tref obj, QUndoCommand *parent=nullptr, QUuid const &uuid=0)
Definition Command.cpp:403

Member Function Documentation

◆ redo()

void dbe::actions::object::rename::redo ( )

Definition at line 296 of file Command.cpp.

297{
298 try {
299 if (redoable()) {
300 failed();
301 dref object_before_change(checkedref());
303
304 confaccessor::ref().force_emit_object_renamed(source().toString(), object_before_change);
305
306 std::vector<tref> tonotify{ this->checkedref().referenced_by("*", false) };
307
308 std::for_each(tonotify.begin(), tonotify.end(), [&](tref const& x) {
309 confaccessor::ref().force_emit_object_changed(source().toString(), x);
310 });
311 toggle();
312 }
313 } catch (dunedaq::conffwk::Exception const& e) {
314 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, dbe::config::errors::parse(e));
315 } catch (daq::dbe::config_object_retrieval_result_is_null const& e) {
316 FAIL("Operation did not complete because a lookup in the underlying database failed", e.what());
317 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, e);
318 }
319}
#define ERS_HERE
void failed() const
Definition Command.cpp:437
bool redoable() const
Definition Command.cpp:469
QUuid const & source() const
Definition Command.cpp:475
void force_emit_object_renamed(QString const &, dref const)
static confaccessor & ref()
std::vector< T > referenced_by(std::string const &name="*", bool check_composite_only=true) const
static configobject::tref rename_object_request(configobject::tref objref, std::string const &newname)
#define FAIL(...)
std::string const parse(ers::Issue const &)
inner::configobject::tref tref
Definition tref.hpp:36
config_object_description dref

◆ undo()

void dbe::actions::object::rename::undo ( )

Definition at line 324 of file Command.cpp.

325{
326 try {
327 if (undoable()) {
328 failed();
329 dref object_before_rename(checkedref());
331 confaccessor::ref().force_emit_object_renamed(source().toString(), object_before_rename);
332
333 std::vector<tref> tonotify = checkedref().referenced_by("*", false);
334
335 std::for_each(tonotify.begin(), tonotify.end(), [&](tref const& x) {
336 confaccessor::ref().force_emit_object_changed(source().toString(), x);
337 });
338 toggle();
339 }
340 } catch (dunedaq::conffwk::Exception const& e) {
341 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, dbe::config::errors::parse(e));
342 } catch (daq::dbe::config_object_retrieval_result_is_null const& e) {
343 FAIL("Operation did not complete because a lookup in the underlying database failed", e.what());
344 throw daq::dbe::ObjectChangeWasNotSuccessful(ERS_HERE, e);
345 }
346}
bool undoable() const
Definition Command.cpp:463

Member Data Documentation

◆ newname

std::string dbe::actions::object::rename::newname
private

Definition at line 122 of file Command.hpp.

◆ oldname

std::string dbe::actions::object::rename::oldname
private

Definition at line 121 of file Command.hpp.


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