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/config_api_commands.hpp
"
17
#include "
dbe/model_common_interface.hpp
"
18
#include "
dbe/treenode.hpp
"
19
20
#include <QUuid>
21
22
#include <boost/scope_exit.hpp>
23
24
//------------------------------------------------------------------------------------------
29
template
<
typename
T>
30
inline
void
31
dbe::model_common_async_operations<T>::model_common_connections
()
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
}
50
//------------------------------------------------------------------------------------------
51
52
//------------------------------------------------------------------------------------------
53
template
<
typename
T>
54
inline
void
55
dbe::model_common_async_operations<T>::remove_object
(type_object_info
const
& obj)
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
}
63
64
template
<
typename
T>
65
inline
void
66
dbe::model_common_async_operations<T>::rename_object
(type_object_info
const
& obj)
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
}
74
75
template
<
typename
T>
76
inline
void
77
dbe::model_common_async_operations<T>::update_object
(type_object_info
const
& obj)
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
}
85
86
template
<
typename
T>
87
inline
void
88
dbe::model_common_async_operations<T>::update_multiple_objects
(std::vector<type_object_info>
const
& objects)
89
{
90
BOOST_SCOPE_EXIT_TPL(this_)
91
{
92
emit
static_cast<
T*
>
(this_)->layoutChanged();
93
}
94
BOOST_SCOPE_EXIT_END
95
96
static_cast<
T*
>
(
this
)->layoutAboutToBeChanged();
97
98
{
99
BOOST_SCOPE_EXIT_TPL(this_)
100
{
101
static_cast<
T*
>
(this_)->blockSignals(
false
);
102
}
103
BOOST_SCOPE_EXIT_END
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
}
112
113
template
<
typename
T>
114
inline
void
115
dbe::model_common_async_operations<T>::create_object
(type_object_info
const
& obj)
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
}
123
124
template
<
typename
T>
125
inline
dbe::model_common_async_operations<T>::model_common_async_operations
()
126
:
MODEL_COMMON_INTERFACE_UUID_DECL
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
//------------------------------------------------------------------------------------------
159
template
<
typename
T>
160
inline
bool
161
dbe::model_common_impl<T>::delete_objects
(type_indices::iterator b, type_indices::iterator e)
162
{
163
typedef
std::set<
decltype
(b->row())> t_qrows;
164
typedef
std::vector<type_object_info> t_objects;
165
t_objects to_remove_objects;
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
177
t_objects removed_objects;
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
185
t_qrows to_remove_rows;
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
195
t_qrows::reverse_iterator uend = to_remove_rows.rbegin();
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
}
210
//------------------------------------------------------------------------------------------
211
212
//------------------------------------------------------------------------------------------
213
template
<
typename
T>
214
inline
bool
215
dbe::model_common_impl<T>::update_objects
(type_indices::iterator b, type_indices::iterator e)
216
{
217
Q_UNUSED(b);
218
Q_UNUSED(e);
219
return
false
;
220
}
221
//------------------------------------------------------------------------------------------
222
223
//------------------------------------------------------------------------------------------
224
template
<
typename
T>
225
inline
bool
226
dbe::model_common_impl<T>::create_objects
(type_indices::iterator b, type_indices::iterator e)
227
{
228
Q_UNUSED(b);
229
Q_UNUSED(e);
230
return
false
;
231
}
232
//------------------------------------------------------------------------------------------
233
234
#endif
/* DBE_MODEL_COMMON_OPERATIONS_HPP_ */
dbe::confaccessor::ref
static confaccessor & ref()
Definition
confaccessor.cpp:37
dbe::config_object_description::ref
inner::configobject::tref ref() const
Definition
dbcontroller.cpp:459
dbe::config_object_description::is_valid
bool is_valid() const
Definition
confobject_desc.hpp:77
dbe::model_common_async_operations::update_multiple_objects
void update_multiple_objects(std::vector< type_object_info > const &)
Definition
model_common_operations.hpp:88
dbe::model_common_async_operations::model_common_connections
void model_common_connections()
Definition
model_common_operations.hpp:31
dbe::model_common_async_operations::remove_object
void remove_object(type_object_info const &)
Definition
model_common_operations.hpp:55
dbe::model_common_async_operations::rename_object
void rename_object(type_object_info const &)
Definition
model_common_operations.hpp:66
dbe::model_common_async_operations::update_object
void update_object(type_object_info const &)
Definition
model_common_operations.hpp:77
dbe::model_common_async_operations::model_common_async_operations
MODEL_COMMON_TYPES_TOPLEVEL_DEFINITIONS model_common_async_operations()
Definition
model_common_operations.hpp:125
dbe::model_common_async_operations::create_object
void create_object(type_object_info const &)
Definition
model_common_operations.hpp:115
dbe::model_common_impl::create_objects
bool create_objects(type_indices::iterator, type_indices::iterator) override
Definition
model_common_operations.hpp:226
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:215
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:75
dbe::dref
config_object_description dref
Definition
confobject_desc.hpp:90
treenode.hpp
Generated on
for DUNE-DAQ by
1.18.0