ATLAS Offline Software
VP1Deserialise.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Header file for class VP1Deserialise //
9 // //
10 // Description: ... //
11 // //
12 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
13 // Initial version: June 2008 //
14 // //
16 
17 #ifndef VP1DESERIALISE_H
18 #define VP1DESERIALISE_H
19 
21 #include "VP1Base/VP1Msg.h"
22 #include <typeinfo>
23 class VP1EtaPhiCutWidget;
25 class PhiSectionWidget;
26 class VP1MaterialButton;
29 //class JetCollectionSettingsButton;
31 class SoMaterial;
32 class QCheckBox;
33 class QGroupBox;
34 class QComboBox;
35 class QLineEdit;
36 class QDoubleSpinBox;
37 class QSpinBox;
38 class QSlider;
39 class QToolBox;
40 class QRadioButton;
41 class QObject;
42 class QWidget;
43 
45 public:
46 
47  VP1Deserialise(const QByteArray &, IVP1System * sys = 0);//sys!=0 for messages in gui
48  virtual ~VP1Deserialise();
49 
50  qint32 version() const;//Negative version indicates an error.
51 
52  void ignoreWidget(QWidget*);//Ignores widget and all children.
53  void widgetHandled(QWidget*);//Indicates that the widget should be considered as handled.
54  void warnUnrestored(QObject*);//Any (stateful) widget children whose state was not saved result in a warning!
55  void disableUnrestoredChecks();//In the rare case where you really do not want to call the previous method, disable warnings by calling this.
56 
57  bool atEnd() const;
58 
59  //Bools:
60  bool restoreBool();
61  void restore(QCheckBox *sb);
62  void restore(QGroupBox*);//Checkable groupboxes only
63 
64  //Strings:
65  QString restoreString();
66  void restore(QComboBox *sb);
67  void restore(QLineEdit*);
68  void restoreByTitle(QToolBox*);//Better if number of pages is not constant.
69 
70  //Doubles:
71  double restoreDouble();
72  void restore(QDoubleSpinBox *sb, const double& unit = 1.0 );
73 
74  //Ints:
75  qint32 restoreInt();
76  void restore(QSpinBox *sb);
77  void restore(QSlider*);
78  void restore(QToolBox *tb);
79  void restore( QRadioButton * rb0,//Add all radio buttons in a given group here.
80  QRadioButton * rb1,//We save an integer indicating which is checked.
81  QRadioButton * rb2 = 0,
82  QRadioButton * rb3 = 0,
83  QRadioButton * rb4 = 0,
84  QRadioButton * rb5 = 0,
85  QRadioButton * rb6 = 0,
86  QRadioButton * rb7 = 0,
87  QRadioButton * rb8 = 0,
88  QRadioButton * rb9 = 0 );
89 
90  //ByteArrays:
91  QByteArray restoreByteArray();
93  void restore(SoMaterial*);
95 // void restore(JetCollectionSettingsButton*w);
100 
101  //QColor's:
102  QColor restoreColor();
104 
105  //Custom (with datastream):
106  template <class T>
107  T restore();
108 
109 
110  //When ensuring backwards compatibility, older version()'s might
111  //require calls to one of the following to ignore parts of the data
112  //in the stream:
113  void ignoreBool();
114  void ignoreInt();
115  void ignoreDouble();
116  void ignoreString();
117  void ignoreByteArray();
118  void ignoreColor();
119  void ignoreObsoletePhiSectionWidgetState();//QPair<int,QList<int> >
120 
121  static unsigned numberOfInstantiations();//Number of times the constructor was invoked.
122  static void decrementNumberOfInstantiations();//Only ever call this from code in VP1Base!!
123 
124 private:
125 
126  class Imp;
127  Imp * m_d;
128  QDataStream * stream();
129 
130 };
131 
133 // INLINES //
135 
136 template <class T>
137 T VP1Deserialise::restore() {//Fallback template method
138  if (verbose())
139  messageVerbose("Restoring "+QString(typeid(T).name())+" via datastream operator");
140  T t;
141  *(stream()) >> t;
142  return t;
143 }
144 
145 #endif
VP1Deserialise::~VP1Deserialise
virtual ~VP1Deserialise()
Definition: VP1Deserialise.cxx:122
VP1Deserialise::VP1Deserialise
VP1Deserialise(const QByteArray &, IVP1System *sys=0)
Definition: VP1Deserialise.cxx:102
VP1Deserialise::ignoreInt
void ignoreInt()
Definition: VP1Deserialise.cxx:598
VP1Deserialise::ignoreString
void ignoreString()
Definition: VP1Deserialise.cxx:618
VP1Msg.h
VP1MaterialButton
Definition: VP1MaterialButton.h:46
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
VP1Deserialise::disableUnrestoredChecks
void disableUnrestoredChecks()
Definition: VP1Deserialise.cxx:690
VP1HelperClassBase::verbose
static bool verbose()
Definition: VP1HelperClassBase.h:32
VP1Deserialise::restoreByTitle
void restoreByTitle(QToolBox *)
Definition: VP1Deserialise.cxx:386
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
VP1Deserialise::restoreDouble
double restoreDouble()
Definition: VP1Deserialise.cxx:429
VP1Deserialise::decrementNumberOfInstantiations
static void decrementNumberOfInstantiations()
Definition: VP1Deserialise.cxx:96
VP1EtaPhiCutWidget
Definition: VP1EtaPhiCutWidget.h:26
VP1ColorSelectButton
Definition: VP1ColorSelectButton.h:20
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
VP1Deserialise::atEnd
bool atEnd() const
Definition: VP1Deserialise.cxx:137
VP1Deserialise::version
qint32 version() const
Definition: VP1Deserialise.cxx:143
Execution.tb
tb
Definition: Execution.py:15
VP1Deserialise::ignoreColor
void ignoreColor()
IVP1System
Definition: IVP1System.h:36
VP1Deserialise::restoreBool
bool restoreBool()
Definition: VP1Deserialise.cxx:419
VP1Deserialise::stream
QDataStream * stream()
Definition: VP1Deserialise.cxx:149
VP1CollectionSettingsButtonBase
Definition: VP1CollectionSettingsButtonBase.h:17
VP1Deserialise::ignoreBool
void ignoreBool()
Definition: VP1Deserialise.cxx:588
VP1Deserialise
Definition: VP1Deserialise.h:44
PhiSectionWidget
Definition: PhiSectionWidget.h:26
VP1HelperClassBase
Definition: VP1HelperClassBase.h:28
VP1Deserialise::numberOfInstantiations
static unsigned numberOfInstantiations()
Definition: VP1Deserialise.cxx:90
VP1Deserialise::Imp
Definition: VP1Deserialise.cxx:44
keylayer_zslicemap.sb
sb
Definition: keylayer_zslicemap.py:192
VP1Deserialise::restore
T restore()
Definition: VP1Deserialise.h:137
VP1Deserialise::restoreInt
qint32 restoreInt()
Definition: VP1Deserialise.cxx:440
VP1Deserialise::restoreColor
QColor restoreColor()
Definition: VP1Deserialise.cxx:191
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
VP1Deserialise::widgetHandled
void widgetHandled(QWidget *)
Definition: VP1Deserialise.cxx:658
VP1HelperClassBase.h
VP1Deserialise::warnUnrestored
void warnUnrestored(QObject *)
Definition: VP1Deserialise.cxx:696
VP1CollectionWidget
Definition: VP1CollectionWidget.h:32
VP1DrawOptionsWidget
Definition: VP1DrawOptionsWidget.h:25
VP1Deserialise::m_d
Imp * m_d
Definition: VP1Deserialise.h:126
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:21
VP1Deserialise::ignoreDouble
void ignoreDouble()
Definition: VP1Deserialise.cxx:608
VP1Deserialise::ignoreObsoletePhiSectionWidgetState
void ignoreObsoletePhiSectionWidgetState()
Definition: VP1Deserialise.cxx:638
VP1Deserialise::ignoreByteArray
void ignoreByteArray()
Definition: VP1Deserialise.cxx:628
VP1Deserialise::ignoreWidget
void ignoreWidget(QWidget *)
Definition: VP1Deserialise.cxx:648
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
VP1Deserialise::restoreByteArray
QByteArray restoreByteArray()
Definition: VP1Deserialise.cxx:234
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
VP1Deserialise::restoreString
QString restoreString()
Definition: VP1Deserialise.cxx:409