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 120 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 353 of file Command.cpp.

356 : onobject ( object, parent, src ),
357 oldname ( this->checkedref().UID() ),
358 newname ( Id )
359{
360 setText (
361 QObject::tr ( "Object changed ID from %1 to %2" ).arg ( this->checkedref().UID().c_str() )
362 .arg ( newname.c_str() ) );
363}
tref checkedref() const
Definition Command.cpp:518
onobject(tref obj, QUndoCommand *parent=nullptr, QUuid const &uuid=0)
Definition Command.cpp:510

Member Function Documentation

◆ redo()

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

Definition at line 367 of file Command.cpp.

368{
369 try
370 {
371 if ( redoable() )
372 {
373 failed();
374 dref object_before_change ( checkedref() );
376
377 confaccessor::ref().force_emit_object_renamed ( source().toString(), object_before_change );
378
379 std::vector<tref> tonotify
380 { this->checkedref().referenced_by ( "*", false ) };
381
382 std::for_each ( tonotify.begin(), tonotify.end(), [&] ( tref const & x )
383 {
384 confaccessor::ref().force_emit_object_changed ( source().toString(), x );
385 } );
386 toggle();
387 }
388 }
389 catch ( dunedaq::conffwk::Exception const & e )
390 {
391 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, dbe::config::errors::parse ( e ) );
392 }
393 catch ( daq::dbe::config_object_retrieval_result_is_null const & e )
394 {
395 FAIL ( "Operation did not complete because a lookup in the underlying database failed",
396 e.what() );
397 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, e );
398 }
399
400}
#define ERS_HERE
void failed() const
Definition Command.cpp:541
bool redoable() const
Definition Command.cpp:568
QUuid const & source() const
Definition Command.cpp:573
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:35
config_object_description dref

◆ undo()

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

Definition at line 404 of file Command.cpp.

405{
406 try
407 {
408 if ( undoable() )
409 {
410 failed();
411 dref object_before_rename ( checkedref() );
413 confaccessor::ref().force_emit_object_renamed ( source().toString(), object_before_rename );
414
415 std::vector<tref> tonotify = checkedref().referenced_by ( "*", false );
416
417 std::for_each ( tonotify.begin(), tonotify.end(), [&] ( tref const & x )
418 {
419 confaccessor::ref().force_emit_object_changed ( source().toString(), x );
420 } );
421 toggle();
422 }
423 }
424 catch ( dunedaq::conffwk::Exception const & e )
425 {
426 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, dbe::config::errors::parse ( e ) );
427 }
428 catch ( daq::dbe::config_object_retrieval_result_is_null const & e )
429 {
430 FAIL ( "Operation did not complete because a lookup in the underlying database failed",
431 e.what() );
432 throw daq::dbe::ObjectChangeWasNotSuccessful ( ERS_HERE, e );
433 }
434
435}
bool undoable() const
Definition Command.cpp:563

Member Data Documentation

◆ newname

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

Definition at line 130 of file Command.hpp.

◆ oldname

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

Definition at line 129 of file Command.hpp.


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