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 115 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 348 of file Command.cpp.

351 : onobject ( object, parent, src ),
352 oldname ( this->checkedref().UID() ),
353 newname ( Id )
354{
355 setText (
356 QObject::tr ( "Object changed ID from %1 to %2" ).arg ( this->checkedref().UID().c_str() )
357 .arg ( newname.c_str() ) );
358}
tref checkedref() const
Definition Command.cpp:513
onobject(tref obj, QUndoCommand *parent=nullptr, QUuid const &uuid=0)
Definition Command.cpp:505

Member Function Documentation

◆ redo()

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

Definition at line 362 of file Command.cpp.

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

◆ undo()

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

Definition at line 399 of file Command.cpp.

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

Member Data Documentation

◆ newname

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

Definition at line 125 of file Command.hpp.

◆ oldname

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

Definition at line 124 of file Command.hpp.


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