DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
include
dbe
model_common_operations.hpp
Go to the documentation of this file.
1
// DUNE DAQ modification notice:
2
// This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
3
// Fork baseline commit: dbe-02-12-17 (2022-05-12).
4
// Renamed since fork: yes (from dbe/model_common_operations.hpp to include/dbe/model_common_operations.hpp).
5
6
/*
7
* model_common_operations.hpp
8
*
9
* Created on: Dec 7, 2015
10
* Author: lgeorgop
11
*/
12
13
#ifndef DBE_MODEL_COMMON_OPERATIONS_HPP_
14
#define DBE_MODEL_COMMON_OPERATIONS_HPP_
15
16
#include "
dbe/model_common_interface.hpp
"
17
#include "
dbe/treenode.hpp
"
18
#include "
dbe/config_api_commands.hpp
"
19
20
#include <QUuid>
21
22
#include <boost/scope_exit.hpp>
23
24
//------------------------------------------------------------------------------------------
29
template
<
typename
T>
30
inline
void
dbe::model_common_async_operations<T>::model_common_connections
()
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
}
45
//------------------------------------------------------------------------------------------
46
47
//------------------------------------------------------------------------------------------
48
template
<
typename
T>
49
inline
void
dbe::model_common_async_operations<T>::remove_object
(
50
type_object_info
const
& obj )
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
}
59
60
template
<
typename
T>
61
inline
void
dbe::model_common_async_operations<T>::rename_object
(
62
type_object_info
const
& obj )
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
}
71
72
template
<
typename
T>
73
inline
void
dbe::model_common_async_operations<T>::update_object
(
74
type_object_info
const
& obj )
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
}
83
84
template
<
typename
T>
85
inline
void
dbe::model_common_async_operations<T>::update_multiple_objects
(
86
std::vector<type_object_info>
const
& objects )
87
{
88
BOOST_SCOPE_EXIT_TPL(this_)
89
{
90
emit
static_cast<
T *
>
( this_ )->layoutChanged();
91
}
92
BOOST_SCOPE_EXIT_END
93
94
static_cast<
T *
>
( this )->layoutAboutToBeChanged();
95
96
{
97
BOOST_SCOPE_EXIT_TPL(this_)
98
{
99
static_cast<
T *
>
( this_ )->blockSignals(
false
);
100
}
101
BOOST_SCOPE_EXIT_END
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
}
110
111
template
<
typename
T>
112
inline
void
dbe::model_common_async_operations<T>::create_object
(
113
type_object_info
const
& obj )
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
}
122
123
template
<
typename
T>
inline
124
dbe::model_common_async_operations<T>::model_common_async_operations
()
125
:
MODEL_COMMON_INTERFACE_UUID_DECL
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
//------------------------------------------------------------------------------------------
158
template
<
typename
T>
inline
bool
dbe::model_common_impl<T>::delete_objects
(
159
type_indices::iterator b, type_indices::iterator e )
160
{
161
typedef
std::set <
decltype
( b->row() ) > t_qrows;
162
typedef
std::vector<type_object_info> t_objects;
163
t_objects to_remove_objects;
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
178
t_objects removed_objects;
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
188
t_qrows to_remove_rows;
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
200
t_qrows::reverse_iterator uend = to_remove_rows.rbegin();
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
}
219
//------------------------------------------------------------------------------------------
220
221
//------------------------------------------------------------------------------------------
222
template
<
typename
T>
inline
bool
dbe::model_common_impl<T>::update_objects
(
223
type_indices::iterator b, type_indices::iterator e )
224
{
225
Q_UNUSED ( b );
226
Q_UNUSED ( e );
227
return
false
;
228
}
229
//------------------------------------------------------------------------------------------
230
231
//------------------------------------------------------------------------------------------
232
template
<
typename
T>
inline
bool
dbe::model_common_impl<T>::create_objects
(
233
type_indices::iterator b, type_indices::iterator e )
234
{
235
Q_UNUSED ( b );
236
Q_UNUSED ( e );
237
return
false
;
238
}
239
//------------------------------------------------------------------------------------------
240
241
#endif
/* DBE_MODEL_COMMON_OPERATIONS_HPP_ */
dbe::confaccessor::ref
static confaccessor & ref()
Definition
confaccessor.cpp:36
dbe::config_object_description::ref
inner::configobject::tref ref() const
Definition
dbcontroller.cpp:500
dbe::config_object_description::is_valid
bool is_valid() const
Definition
confobject_desc.hpp:92
dbe::model_common_async_operations::update_multiple_objects
void update_multiple_objects(std::vector< type_object_info > const &)
Definition
model_common_operations.hpp:85
dbe::model_common_async_operations::model_common_connections
void model_common_connections()
Definition
model_common_operations.hpp:30
dbe::model_common_async_operations::remove_object
void remove_object(type_object_info const &)
Definition
model_common_operations.hpp:49
dbe::model_common_async_operations::rename_object
void rename_object(type_object_info const &)
Definition
model_common_operations.hpp:61
dbe::model_common_async_operations::update_object
void update_object(type_object_info const &)
Definition
model_common_operations.hpp:73
dbe::model_common_async_operations::model_common_async_operations
MODEL_COMMON_TYPES_TOPLEVEL_DEFINITIONS model_common_async_operations()
Definition
model_common_operations.hpp:124
dbe::model_common_async_operations::create_object
void create_object(type_object_info const &)
Definition
model_common_operations.hpp:112
dbe::model_common_impl::create_objects
bool create_objects(type_indices::iterator, type_indices::iterator) override
Definition
model_common_operations.hpp:232
dbe::model_common_impl::delete_objects
bool delete_objects(type_indices::iterator, type_indices::iterator) override
dbe::model_common_impl::update_objects
bool update_objects(type_indices::iterator, type_indices::iterator) override
Definition
model_common_operations.hpp:222
config_api_commands.hpp
model_common_interface.hpp
MODEL_COMMON_INTERFACE_UUID_DECL
#define MODEL_COMMON_INTERFACE_UUID_DECL
Definition
model_common_interface.hpp:27
dbe::config::api::commands::delobj
bool delobj(inner::configobject::tref obj, QUuid const &src)
Definition
config_api_commands.cpp:79
dbe::dref
config_object_description dref
Definition
confobject_desc.hpp:109
treenode.hpp
Generated on
for DUNE-DAQ by
1.17.0