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 259 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 124 of file model_common_operations.hpp.

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

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

◆ 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 30 of file model_common_operations.hpp.

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

◆ 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 49 of file model_common_operations.hpp.

51{
52 type_index oid ( static_cast<T *> ( this )->lookup ( obj ) );
53
54 if ( oid.isValid() )
55 {
56 static_cast<T *> ( this )->remove_deleted_object ( oid );
57 }
58}

◆ rename_object()

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

Definition at line 61 of file model_common_operations.hpp.

63{
64 type_index oid ( static_cast<T *> ( this )->lookup ( obj ) );
65
66 if ( oid.isValid() )
67 {
68 static_cast<T *> ( this )->rename_contained_object ( oid, obj );
69 }
70}

◆ 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 85 of file model_common_operations.hpp.

87{
89 {
90 emit static_cast<T *> ( this_ )->layoutChanged();
91 }
93
94 static_cast<T *> ( this )->layoutAboutToBeChanged();
95
96 {
98 {
99 static_cast<T *> ( this_ )->blockSignals(false);
100 }
102
103 static_cast<T *> ( this )->blockSignals(true);
104
105 for(const auto& obj : objects) {
106 static_cast<T *> ( this )->update_object(obj);
107 }
108 }
109}
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 73 of file model_common_operations.hpp.

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

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