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

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

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

109{
110 type_index oid ( static_cast<T *> ( this )->lookup ( obj ) );
111
112 if ( not oid.isValid() )
113 {
114 static_cast<T *> ( this )->create_contained_object ( oid, obj );
115 }
116}

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

26{
27 static_cast<T *> ( this )->connect (
28 &confaccessor::ref(), SIGNAL ( object_deleted ( QString const &, dref const & ) ),
29 static_cast<T *> ( this ), SLOT ( slot_remove_object ( QString const &, dref const & ) ) );
30 static_cast<T *> ( this )->connect (
31 &confaccessor::ref(), SIGNAL ( object_renamed ( QString const &, dref const & ) ),
32 static_cast<T *> ( this ), SLOT ( slot_rename_object ( QString const &, dref const & ) ) );
33 static_cast<T *> ( this )->connect (
34 &confaccessor::ref(), SIGNAL ( object_changed ( QString const &, dref const & ) ),
35 static_cast<T *> ( this ), SLOT ( slot_update_object ( QString const &, dref const & ) ) );
36 static_cast<T *> ( this )->connect (
37 &confaccessor::ref(), SIGNAL ( object_created ( QString const &, dref const & ) ),
38 static_cast<T *> ( this ), SLOT ( slot_create_object ( QString const &, dref const & ) ) );
39}
static confaccessor & ref()

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

46{
47 type_index oid ( static_cast<T *> ( this )->lookup ( obj ) );
48
49 if ( oid.isValid() )
50 {
51 static_cast<T *> ( this )->remove_deleted_object ( oid );
52 }
53}

◆ rename_object()

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

Definition at line 56 of file model_common_operations.hpp.

58{
59 type_index oid ( static_cast<T *> ( this )->lookup ( obj ) );
60
61 if ( oid.isValid() )
62 {
63 static_cast<T *> ( this )->rename_contained_object ( oid, obj );
64 }
65}

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

82{
83 BOOST_SCOPE_EXIT_TPL(this_)
84 {
85 emit static_cast<T *> ( this_ )->layoutChanged();
86 }
87 BOOST_SCOPE_EXIT_END
88
89 static_cast<T *> ( this )->layoutAboutToBeChanged();
90
91 {
92 BOOST_SCOPE_EXIT_TPL(this_)
93 {
94 static_cast<T *> ( this_ )->blockSignals(false);
95 }
96 BOOST_SCOPE_EXIT_END
97
98 static_cast<T *> ( this )->blockSignals(true);
99
100 for(const auto& obj : objects) {
101 static_cast<T *> ( this )->update_object(obj);
102 }
103 }
104}
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 68 of file model_common_operations.hpp.

70{
71 type_index oid ( static_cast<T *> ( this )->lookup ( obj ) );
72
73 if ( oid.isValid() )
74 {
75 static_cast<T *> ( this )->update_contained_object ( oid, obj );
76 }
77}

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