ATLAS Offline Software
Loading...
Searching...
No Matches
IVP1System.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7// //
8// Implementation of class IVP1System //
9// //
10// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
11// //
12// Initial version: April 2007 //
13// //
15
16#include "VP1Base/IVP1System.h"
18#include "VP1Base/VP1QtUtils.h"
19#include "VP1Base/VP1Msg.h"
21
22#include <QApplication>
23#include <QWidget>
24
25#include <cassert>
26#include <iostream>
27
28const bool IVP1System::s_vp1verbose = VP1QtUtils::environmentVariableIsOn("VP1_VERBOSE_OUTPUT"); // TODO: is this used at all?
29
31public:
32 Imp(const QString & n, const QString & i, const QString & c)
33 : name(n), information(i), contact_info(c), channel(0),
35 controller(0),refreshing(false),
37 const QString name;
38 const QString information;
39 const QString contact_info;
44 QWidget * controller;
47};
48
49//________________________________________________________
50const QString& IVP1System::name() const
51{
52 return m_d->name;
53}
54
55//________________________________________________________
56const QString& IVP1System::information() const
57{
58 return m_d->information;
59}
60
61//________________________________________________________
62const QString& IVP1System::contact_info() const
63{
64 return m_d->contact_info;
65}
66
67//________________________________________________________
68IVP1System::IVP1System(const QString & n, const QString & i, const QString & c)
69 : m_d(new Imp(n,i,c))
70{
71 if (VP1Msg::verbose()){
72 messageVerbose("IVP1System()");
73 }
74 setObjectName("IVP1System:"+n);
75
76}
77
78//________________________________________________________
80{
81 if (VP1Msg::verbose()){
82 messageVerbose("IVP1System() Destructor. Start...");
83 }
84
85 assert(m_d->state==UNCREATED||m_d->state==CONSTRUCTED);
86 assert(!m_d->controller);
87
88 delete m_d;
89 m_d=nullptr;
90 VP1Msg::messageDebug("IVP1System() Destructor. END.");
91}
92
93//_______________________________________________________
95{
96 if (VP1Msg::verbose()) {
97 messageVerbose("setChannel ");
98 messageVerbose("setChannel m_d->state==CONSTRUCTED = "+QString(m_d->state==CONSTRUCTED?"true":"false"));
99 messageVerbose("setChannel cw!=0 = "+QString(cw!=0?"true":"false"));
100 }
101 assert(!m_d->channel);
102 assert(cw);
103 assert(m_d->state==CONSTRUCTED);
104 m_d->channel = cw;
105}
106
107//________________________________________________________
109{
110 return m_d->refreshing;
111}
112
113//________________________________________________________
114void IVP1System::setRefreshing(const bool& b)
115{
116 if (VP1Msg::verbose()){
117 messageVerbose("setRefreshing() called with b="+QString(b?"true":"false"));
118 }
119 if (b) {
120 assert(m_d->state==ERASED);
121 } else {
122 assert(m_d->state==REFRESHED);
123 }
124 m_d->refreshing = b;
125}
126
127
128//________________________________________________________
130{
131 return m_d->state;
132}
133
134//________________________________________________________
136{
137 return m_d->activeState;
138}
139
140//________________________________________________________
142{
143#ifndef NDEBUG
144 assert (m_d->state != s);
145 assert(s!=CONSTRUCTED);
146 if (s==REFRESHED) {
147 assert(m_d->state==ERASED);
148 }
149 if (s==ERASED) {
150 assert(m_d->state==REFRESHED||m_d->state==CONSTRUCTED);
151 }
152 if (s==UNCREATED) {
153 assert(m_d->state==ERASED);
154 }
155#endif
156 m_d->state = s;
157 if (s==REFRESHED||s==ERASED)
158 m_d->channel->emitRefreshInfoChanged();
159}
160
161//________________________________________________________
162void IVP1System::setActiveState(const ActiveState&s,const bool& donttriggererase)
163{
164 //First handle case where we dont actually change state. Only
165 //special consideration is OFF->OFF where we have to do something if
166 //we need to erase:
167 if (m_d->activeState==OFF&&s==OFF&&(m_d->state==REFRESHED||m_d->refreshing)&&!donttriggererase) {
168 needErase();
169 m_d->channel->emitRefreshInfoChanged();
170 return;
171 } else if (m_d->activeState==s) {
172 m_d->channel->emitRefreshInfoChanged();
173 return;
174 }
175
176 //Ok, we know that we are either ON->OFF or OFF->ON.
177 m_d->activeState = s;
178
179 if (s==ON) {
180 //OFF->ON: We might need a refresh, so send out a signal for the scheduler:
182 } else {
183 //ON->OFF: We might need an erase signal:
184 if ((m_d->state==REFRESHED||m_d->refreshing)&&!donttriggererase) {
185 needErase();
186 }
187 }
188 m_d->channel->emitRefreshInfoChanged();
189}
190
191//________________________________________________________
193{
194 if (VP1Msg::verbose()) {
195 messageVerbose("uncreate() base implementation");
196 messageVerbose("registerController m_d->state==ERASED = "+QString(m_d->state==ERASED?"true":"false"));
197 }
198 assert(m_d->state==ERASED);
199}
200
201//________________________________________________________
203 if (VP1Msg::verbose()) {
204 messageVerbose("controllerWidget()");
205 messageVerbose("registerController m_d->state==ERASED = "+QString(m_d->state==ERASED?"true":"false"));
206 messageVerbose("registerController m_d->state==REFRESHED = "+QString(m_d->state==REFRESHED?"true":"false"));
207 }
208 assert(m_d->state==REFRESHED||m_d->state==ERASED);
209 return m_d->controller;
210 }
211
212//_______________________________________________________
214{
215 if (VP1Msg::verbose()){
216 messageVerbose("deleteController()");
217 }
218 if (m_d->controller)
219 m_d->controller->deleteLater();
220 m_d->controller = 0;
221}
222
223//________________________________________________________
225{
226 if (VP1Msg::verbose()) {
227 messageVerbose("registerController ");
228 messageVerbose("registerController m_d->canregistercontroller = "+QString(m_d->canregistercontroller?"true":"false"));
229 messageVerbose("registerController m_d->state==CONSTRUCTED = "+QString(m_d->state==CONSTRUCTED?"true":"false"));
230 messageVerbose("registerController m_d->controller==0 = "+QString(m_d->controller==0?"true":"false"));
231 messageVerbose("registerController w!=0 = "+QString(w!=0?"true":"false"));
232 }
233 if (!m_d->canregistercontroller)
234 message("ERROR: Please don't register controllers after create().");
235 if (m_d->state!=CONSTRUCTED)
236 message("ERROR: Please only register controllers in CONSTRUCTED state.");
237 if (!w) {
238 message("ERROR: Attempt to register null controller.");
239 return;
240 }
241 if (m_d->controller) {
242 message("ERROR: Attempt to register controller twice.");
243 return;
244 }
245 m_d->controller = w;
246 w->setParent(0);
247}
248
249//________________________________________________________
251{
252 m_d->allowupdategui=false;
253}
254
255//________________________________________________________
257{
258 m_d->allowupdategui=true;
259}
260
261//________________________________________________________
263// messageDebug("IVP1System::updateGUI() - START");
264 //assert(m_d->allowupdategui);
265 //assert(m_d->state==ERASED);
266
267 if ( m_d->allowupdategui ) {
268 qApp->processEvents();
269 }
270
271// messageDebug("IVP1System::updateGUI() - END");
272}
273
274//________________________________________________________
276{
277 if (VP1Msg::verbose()&&!m_d->channel){
278 messageVerbose("WARNING channel() returning NULL");
279 }
280 assert(m_d->channel);
281 return m_d->channel;
282}
283
284//_______________________________________________________
286{
287 if (VP1Msg::verbose()){
288 messageVerbose("setCanRegisterController called with"+QString(c?"true":"false"));
289 }
290 m_d->canregistercontroller=c;
291}
292
293//_______________________________________________________
295 if (VP1Msg::verbose()){
296 messageVerbose("base saveState called [IVP1System]");
297 }
298 return QByteArray();
299}
300
301//_______________________________________________________
303{
304 if (VP1Msg::verbose()){
305 messageVerbose("base restoreFromState called");
306 }
307 if (!ba.isEmpty())
308 message("Error in IVP1System::restoreFromState: Received non-empty saved state.");
309}
310
311//_______________________________________________________
316
317//_______________________________________________________
322
323//_______________________________________________________
324ISvcLocator * IVP1System::serviceLocator() const
325{
327}
328
329//_______________________________________________________
330IToolSvc * IVP1System::toolSvc() const
331{
332 return VP1AthenaPtrs::toolSvc();
333}
334
335//_______________________________________________________
336void IVP1System::message(const QString& str) const
337{
338 if (receivers(SIGNAL(sysmessage(QString))) > 0){
340 }
341 else{
342 std::cout<<VP1Msg::prefix_msg()<<" ["<<m_d->name.toStdString()<<"]: "<<str.toStdString()<<std::endl;
343 }
344}
345
346//_______________________________________________________
347void IVP1System::messageDebug(const QString& str) const
348{
349 if (VP1Msg::debug())
350 std::cout<<VP1Msg::prefix_debug()<<" ["<<m_d->name.toStdString()<<"]: "<<str.toStdString()<<std::endl;
351}
352
353//_______________________________________________________
354void IVP1System::messageVerbose(const QString& str) const
355{
356 if (VP1Msg::verbose())
357 std::cout<<VP1Msg::prefix_verbose()<<" ["<<m_d->name.toStdString()<<"]: "<<str.toStdString()<<std::endl;
358}
359
360
361//____________________________________________________________________
362void IVP1System::message(const QStringList& l, const QString& addtoend ) const
363{
364 if (addtoend.isEmpty()) {
365 for (const QString& s : l)
366 message(s);
367 } else {
368 for (const QString& s : l)
369 message(s+addtoend);
370 }
371}
372
373//____________________________________________________________________
374void IVP1System::messageDebug(const QStringList& l, const QString& addtoend ) const
375{
376 if (addtoend.isEmpty()) {
377 for (const QString& s : l)
378 messageDebug(s);
379 } else {
380 for (const QString& s : l)
381 messageDebug(s+addtoend);
382 }
383}
384
385//____________________________________________________________________
386void IVP1System::messageVerbose(const QStringList& l, const QString& addtoend ) const
387{
388 if (!VP1Msg::verbose())
389 return;
390 if (addtoend.isEmpty()) {
391 for (const QString& s : l)
393 } else {
394 for (const QString& s : l)
395 messageVerbose(s+addtoend);
396 }
397}
398
399//____________________________________________________________________
400void IVP1System::message(const QString& addtostart, const QStringList& l, const QString& addtoend ) const
401{
402 if (addtostart.isEmpty()) {
403 message(l,addtoend);
404 return;
405 }
406 if (addtoend.isEmpty()) {
407 for (const QString& s : l)
408 message(addtostart+s);
409 } else {
410 for (const QString& s : l)
411 message(addtostart+s+addtoend);
412 }
413}
414
415//____________________________________________________________________
416void IVP1System::messageDebug(const QString& addtostart, const QStringList& l, const QString& addtoend ) const
417{
418 if (addtostart.isEmpty()) {
419 messageDebug(l,addtoend);
420 return;
421 }
422 if (addtoend.isEmpty()) {
423 for (const QString& s : l)
424 messageDebug(addtostart+s);
425 } else {
426 for (const QString& s : l)
427 messageDebug(addtostart+s+addtoend);
428 }
429}
430
431//____________________________________________________________________
432void IVP1System::messageVerbose(const QString& addtostart, const QStringList& l, const QString& addtoend ) const
433{
434 if (!VP1Msg::verbose())
435 return;
436 if (addtostart.isEmpty()) {
437 messageVerbose(l,addtoend);
438 return;
439 }
440 if (addtoend.isEmpty()) {
441 for (const QString& s : l)
442 messageVerbose(addtostart+s);
443 } else {
444 for (const QString& s : l)
445 messageVerbose(addtostart+s+addtoend);
446 }
447}
448
449#ifdef BUILDVP1LIGHT
450//____________________________________________________________________
451xAOD::TEvent* IVP1System::getEvent(){
452 return m_event;
453}
454
455void IVP1System::setEvent( xAOD::TEvent* event ){
456 m_event = event;
457}
458
459//____________________________________________________________________
460QStringList IVP1System::getObjectList(xAOD::Type::ObjectType type){
461 if( type == xAOD::Type::Vertex ) {
462
463 message("(((((((((())))))))))))))))");
464 message(m_list[0]);
465 return m_list[0];
466 }
467 else if ( type == xAOD::Type::Other ) {
468 return m_list[1];
469 }
470 else if ( type == xAOD::Type::Jet ){
471 return m_list[2];
472 }
473 else if ( type == xAOD::Type::CaloCluster ) {
474 return m_list[3];
475 }
476 else if ( type == xAOD::Type::TrackParticle ) {
477 return m_list[4];
478 }
479 else if ( type == xAOD::Type::Muon ) {
480 return m_list[5];
481 }
482 else if ( type == xAOD::Type::Electron ) {
483 return m_list[6];
484 }
485 else {
486 message("Unknown xAOD type requested");
487 return QStringList {};
488 }
489}
490
491void IVP1System::setObjectList(QList<QStringList> list){
492 m_list = list;
493}
494
495
496#endif // BUILDVP1LIGHT
QWidget * controller
const QString contact_info
ActiveState activeState
bool canregistercontroller
const QString name
const QString information
Imp(const QString &n, const QString &i, const QString &c)
IVP1ChannelWidget * channel
IToolSvc * toolSvc() const
friend class IVP1ChannelWidget
Definition IVP1System.h:134
void messageVerbose(const QString &) const
ActiveState activeState() const
virtual void restoreFromState(QByteArray)
void allowUpdateGUI()
StoreGateSvc * detectorStore() const
void messageDebug(const QString &) const
const QString & name() const
State state() const
virtual void uncreate()
StoreGateSvc * eventStore() const
void setCanRegisterController(const bool &)
QWidget * controllerWidget()
void updateGUI()
void deleteController()
IVP1System(const QString &name, const QString &information, const QString &contact_info)
void message(const QString &) const
void setChannel(IVP1ChannelWidget *)
static const bool s_vp1verbose
Definition IVP1System.h:158
virtual ~IVP1System()
IVP1ChannelWidget * channel() const
void inactiveSystemTurnedActive()
void sysmessage(QString) const
void registerController(QWidget *)
void setRefreshing(const bool &)
void setState(const State &)
void disallowUpdateGUI()
const QString & information() const
const QString & contact_info() const
void needErase()
ISvcLocator * serviceLocator() const
bool isRefreshing()
virtual QByteArray saveState()
void setActiveState(const ActiveState &, const bool &donttriggererase=true)
The Athena Transient Store API.
static StoreGateSvc * eventStore()
static IToolSvc * toolSvc()
static ISvcLocator * serviceLocator()
static StoreGateSvc * detectorStore()
static bool debug()
Definition VP1Msg.h:32
static bool verbose()
Definition VP1Msg.h:31
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39
static const char * prefix_msg()
Definition VP1Msg.h:56
static const char * prefix_debug()
Definition VP1Msg.h:57
static const char * prefix_verbose()
Definition VP1Msg.h:59
static bool environmentVariableIsOn(const QString &name)
Tool for accessing xAOD files outside of Athena.
list(name, path='/')
Definition histSizes.py:38
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
@ TrackParticle
The object is a charged track particle.
Definition ObjectType.h:43
@ Jet
The object is a jet.
Definition ObjectType.h:40
@ Other
An object not falling into any of the other categories.
Definition ObjectType.h:34
@ CaloCluster
The object is a calorimeter cluster.
Definition ObjectType.h:39
@ Muon
The object is a muon.
Definition ObjectType.h:48
@ Electron
The object is an electron.
Definition ObjectType.h:46
@ Vertex
The object is a vertex.
Definition ObjectType.h:59