DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::model_common_async_operations< T > Class Template Reference

#include <model_common_interface.hpp>

Public Member Functions

MODEL_COMMON_TYPES_TOPLEVEL_DEFINITIONS model_common_async_operations ()
void model_common_connections ()

Protected Member Functions

void remove_object (type_object_info const &)
void create_object (type_object_info const &)
void rename_object (type_object_info const &)
void update_object (type_object_info const &)
void update_multiple_objects (std::vector< type_object_info > const &)

Detailed Description

template<typename T>
class dbe::model_common_async_operations< T >

Provides a unified manner to handle implemented methods in derived classes of model_common_slots::slot_... methods (e.g. defined with MODEL_COMMON_INTERFACE_SLOTS... macros ) by first looking up for the object at hand.

Each of the methods in this class are called from the derived class causing a call chain Derived::slot -> model_common_async_operations method -> implemented method in Derived class

e.g. for object deletion

T::slot_remove_object -> remove_object -> T::remove_deleted_object

Definition at line 254 of file model_common_interface.hpp.

Constructor & Destructor Documentation

◆ model_common_async_operations()

template<typename T>
dbe::model_common_async_operations< T >::model_common_async_operations ( )
inline

Definition at line 125 of file model_common_operations.hpp.

127{
128}
129//------------------------------------------------------------------------------------------
130
131//------------------------------------------------------------------------------------------
132// FOR FUTURE USE
133// template<typename T> inline std::vector<dbe::dref> dbe::model_common_impl<T>::filter_indices(
134// type_indices::iterator b, type_indices::iterator e)
135//{
136// typedef std::set<decltype(b->row())> t_qrows;
137// typedef std::vector<dref> t_objects;
138//
139// t_objects objects_to_act_upon;
140// t_indices indices_to_check;
141//
142// for(t_indices::iterator iter = b ; iter != e ; ++iter)
143// {
144// if(iter->isValid() and iter->column() == 0)
145// {
146// dref o = static_cast<T *>(this)->getobject(*iter);
147// if(o.is_valid())
148// {
149// indices_to_check.push_back(*iter);
150// objects_to_act_upon.push_back(o);
151// }
152// }
153// }
154//
155//}
156//------------------------------------------------------------------------------------------
157
158//------------------------------------------------------------------------------------------
159template<typename T>
160inline bool
162{
163 typedef std::set<decltype(b->row())> t_qrows;
166
167 for (type_indices::iterator iter = b; iter != e; ++iter) {
168 if (iter->isValid() and iter->column() == 0) {
169 dref o = static_cast<T*>(this)->getobject(*iter);
170
171 if (o.is_valid()) {
172 to_remove_objects.push_back(o);
173 }
174 }
175 }
176
178
179 for (auto const& o : to_remove_objects) {
180 if (dbe::config::api::commands::delobj(o.ref(), static_cast<T*>(this)->uuid)) {
181 removed_objects.push_back(o);
182 }
183 }
184
186
187 for (auto const& o : removed_objects) {
188 QModelIndex newloc = static_cast<T*>(this)->lookup(o);
189
190 if (newloc.isValid()) {
191 to_remove_rows.insert(newloc.row());
192 }
193 }
194
196
197 if (uend != to_remove_rows.rend()) {
198 for (int count = 0, bottom = *uend, last = bottom; uend != to_remove_rows.rend(); count = 0, bottom = *uend) {
199 for (; uend != to_remove_rows.rend() and count == bottom - *uend; last = *uend, ++uend, ++count)
200 ;
201
202 static_cast<T*>(this)->removeRows(last, count, b->parent());
203 }
204
205 return true;
206 }
207
208 return false;
209}
bool delete_objects(type_indices::iterator, type_indices::iterator) override

Member Function Documentation

◆ create_object()

template<typename T>
void dbe::model_common_async_operations< T >::create_object ( type_object_info const & obj)
inlineprotected

Definition at line 115 of file model_common_operations.hpp.

116{
117 type_index oid(static_cast<T*>(this)->lookup(obj));
118
119 if (not oid.isValid()) {
120 static_cast<T*>(this)->create_contained_object(oid, obj);
121 }
122}

◆ model_common_connections()

template<typename T>
void dbe::model_common_async_operations< T >::model_common_connections ( )
inline

Setup the necessary connections to signals from confaccessor to the derived object

THIS HAS TO BE CALLED FROM THE DERIVED CLASS otherwise it will have no effect

Needs be to called from the derived class constructor to setup the connection to slots defined in the derived class, since they cannot be know before.

Definition at line 31 of file model_common_operations.hpp.

32{
33 static_cast<T*>(this)->connect(&confaccessor::ref(),
34 SIGNAL(object_deleted(QString const&, dref const&)),
35 static_cast<T*>(this),
36 SLOT(slot_remove_object(QString const&, dref const&)));
37 static_cast<T*>(this)->connect(&confaccessor::ref(),
38 SIGNAL(object_renamed(QString const&, dref const&)),
39 static_cast<T*>(this),
40 SLOT(slot_rename_object(QString const&, dref const&)));
41 static_cast<T*>(this)->connect(&confaccessor::ref(),
42 SIGNAL(object_changed(QString const&, dref const&)),
43 static_cast<T*>(this),
44 SLOT(slot_update_object(QString const&, dref const&)));
45 static_cast<T*>(this)->connect(&confaccessor::ref(),
46 SIGNAL(object_created(QString const&, dref const&)),
47 static_cast<T*>(this),
48 SLOT(slot_create_object(QString const&, dref const&)));
49}

◆ remove_object()

template<typename T>
void dbe::model_common_async_operations< T >::remove_object ( type_object_info const & obj)
inlineprotected

Actually calls the derived class implementation of the prototype remove_deleted_object

Parameters
theobject to be matched and removed from the index

Definition at line 55 of file model_common_operations.hpp.

56{
57 type_index oid(static_cast<T*>(this)->lookup(obj));
58
59 if (oid.isValid()) {
60 static_cast<T*>(this)->remove_deleted_object(oid);
61 }
62}

◆ rename_object()

template<typename T>
void dbe::model_common_async_operations< T >::rename_object ( type_object_info const & obj)
inlineprotected

Definition at line 66 of file model_common_operations.hpp.

67{
68 type_index oid(static_cast<T*>(this)->lookup(obj));
69
70 if (oid.isValid()) {
71 static_cast<T*>(this)->rename_contained_object(oid, obj);
72 }
73}

◆ update_multiple_objects()

template<typename T>
void dbe::model_common_async_operations< T >::update_multiple_objects ( std::vector< type_object_info > const & objects)
inlineprotected

Definition at line 88 of file model_common_operations.hpp.

89{
91 {
92 emit static_cast<T*>(this_)->layoutChanged();
93 }
95
96 static_cast<T*>(this)->layoutAboutToBeChanged();
97
98 {
100 {
101 static_cast<T*>(this_)->blockSignals(false);
102 }
104
105 static_cast<T*>(this)->blockSignals(true);
106
107 for (const auto& obj : objects) {
108 static_cast<T*>(this)->update_object(obj);
109 }
110 }
111}
void update_object(type_object_info const &)

◆ update_object()

template<typename T>
void dbe::model_common_async_operations< T >::update_object ( type_object_info const & obj)
inlineprotected

Definition at line 77 of file model_common_operations.hpp.

78{
79 type_index oid(static_cast<T*>(this)->lookup(obj));
80
81 if (oid.isValid()) {
82 static_cast<T*>(this)->update_contained_object(oid, obj);
83 }
84}

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