ATLAS Offline Software
VP1Serialise.h
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 // Header file for class VP1Serialise //
9 // //
10 // Description: Helper class for serialisation. //
11 // //
12 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
13 // Initial version: June 2008 //
14 // //
16 
17 #ifndef VP1PERSISTIFY_H
18 #define VP1PERSISTIFY_H
19 
21 #include "VP1Base/VP1Msg.h"
22 #include <typeinfo>
23 #include <QDataStream>
24 class VP1EtaPhiCutWidget;
26 class PhiSectionWidget;
27 class VP1MaterialButton;
30 //class JetCollectionSettingsButton;
32 class SoMaterial;
33 class QCheckBox;
34 class QGroupBox;
35 class QComboBox;
36 class QLineEdit;
37 class QDoubleSpinBox;
38 class QSpinBox;
39 class QSlider;
40 class QToolBox;
41 class QRadioButton;
42 class QWidget;
43 class QObject;
44 
46 public:
47 
48  VP1Serialise(qint32 version, IVP1System * sys = 0);//sys!=0 for messages in gui
49  virtual ~VP1Serialise();
50 
51  const QByteArray& result();
52  qint32 version() const;
53 
54  void ignoreWidget(const QWidget*);//Ignores widget and all children.
55  void widgetHandled(const QWidget*);//Indicates that the widget should be considered as handled.
56  void warnUnsaved(const QObject*);//Any (stateful) widget children whose state was not saved result in a warning!
57  void disableUnsavedChecks();//In the rare case where you really do not want to call the previous method, disable warnings by calling this.
58 
59  //Fixme: pointers->const ??
60 
61  //Bools:
62  void save(bool);
63  void save(QCheckBox*);
64  void save(QGroupBox*);//Checkable groupboxes only
65 
66  //Strings:
67  void save(const QString&);
68  void save(QComboBox*);
69  void save(QLineEdit*);
70  void saveByTitle(QToolBox*);//Better if number of pages is not constant.
71 
72  //Doubles:
73  void save(const double&);
74  void save(QDoubleSpinBox*, const double& unit = 1.0 );
75 
76  //Ints:
77  void save(qint32);
78  void save(QSpinBox*);
79  void save(QSlider*);
80  void save(QToolBox*);
81  //fixme tabwidget
82  void save( QRadioButton * rb0,//Add all radio buttons in a given group here.
83  QRadioButton * rb1,//We save an integer indicating which is checked.
84  QRadioButton * rb2 = 0,//Any NULL values will be taken to indicate "unchecked".
85  QRadioButton * rb3 = 0,
86  QRadioButton * rb4 = 0,
87  QRadioButton * rb5 = 0,
88  QRadioButton * rb6 = 0,
89  QRadioButton * rb7 = 0,
90  QRadioButton * rb8 = 0,
91  QRadioButton * rb9 = 0 );
92 
93  //ByteArrays:
94  void save(const QByteArray&);
95  void save(const VP1MaterialButton*);//Persistifies values of first handled material (saves empty byte array if none handled)
96  void save(SoMaterial*);
97  void save(const VP1CollectionWidget*);
98 // void save(const JetCollectionSettingsButton* jcb);
99  void save(const VP1CollectionSettingsButtonBase* jcb);
100  void save(const VP1EtaPhiCutWidget*);
101  void save(const VP1DrawOptionsWidget*);
102  void save(const PhiSectionWidget*);//Used to be QPair<int,QList<int> >
103 
104  //QColor's:
105  void save(const QColor&);
106  void save(VP1ColorSelectButton*);
107 
108  //Custom (with datastream):
109  template <class T>
110  void save(const T& t);
111  template <class T>
112  void save( T* t);//To keep previous template from swallowing const pointers constness.
113 
114  static unsigned numberOfInstantiations();//Number of times the constructor was invoked.
115  static void decrementNumberOfInstantiations();//Only ever call this from code in VP1Base!!
116 private:
117 
118  class Imp;
119  Imp * m_d;
120  QDataStream * stream();
121 
122 };
123 
125 // INLINES //
127 
128 template <class T>
129 void VP1Serialise::save(const T& t) {//Fallback template method
130  if (VP1Msg::verbose())
131  messageVerbose("Saving "+QString(typeid(T).name())+" via datastream operator");
132  *(stream()) << t;
133 }
134 
135 template <class T>
137 {
138  save((const T*)t);
139 }
140 
141 #endif
VP1Serialise
Definition: VP1Serialise.h:45
VP1Msg.h
VP1MaterialButton
Definition: VP1MaterialButton.h:46
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
VP1Serialise::decrementNumberOfInstantiations
static void decrementNumberOfInstantiations()
Definition: VP1Serialise.cxx:81
VP1Serialise::warnUnsaved
void warnUnsaved(const QObject *)
Definition: VP1Serialise.cxx:481
VP1Serialise::widgetHandled
void widgetHandled(const QWidget *)
Definition: VP1Serialise.cxx:443
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
VP1Serialise::m_d
Imp * m_d
Definition: VP1Serialise.h:118
VP1EtaPhiCutWidget
Definition: VP1EtaPhiCutWidget.h:26
VP1ColorSelectButton
Definition: VP1ColorSelectButton.h:20
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
IVP1System
Definition: IVP1System.h:36
VP1Serialise::numberOfInstantiations
static unsigned numberOfInstantiations()
Definition: VP1Serialise.cxx:75
VP1Serialise::save
void save(bool)
Definition: VP1Serialise.cxx:207
VP1CollectionSettingsButtonBase
Definition: VP1CollectionSettingsButtonBase.h:17
VP1Serialise::VP1Serialise
VP1Serialise(qint32 version, IVP1System *sys=0)
Definition: VP1Serialise.cxx:87
VP1Serialise::Imp
Definition: VP1Serialise.cxx:42
PhiSectionWidget
Definition: PhiSectionWidget.h:26
VP1HelperClassBase
Definition: VP1HelperClassBase.h:28
VP1Serialise::~VP1Serialise
virtual ~VP1Serialise()
Definition: VP1Serialise.cxx:101
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
VP1Serialise::saveByTitle
void saveByTitle(QToolBox *)
Definition: VP1Serialise.cxx:262
VP1HelperClassBase.h
VP1Serialise::ignoreWidget
void ignoreWidget(const QWidget *)
Definition: VP1Serialise.cxx:433
VP1Serialise::disableUnsavedChecks
void disableUnsavedChecks()
Definition: VP1Serialise.cxx:475
VP1CollectionWidget
Definition: VP1CollectionWidget.h:32
VP1DrawOptionsWidget
Definition: VP1DrawOptionsWidget.h:25
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:21
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
VP1Serialise::stream
QDataStream * stream()
Definition: VP1Serialise.cxx:115
VP1Serialise::result
const QByteArray & result()
Definition: VP1Serialise.cxx:129
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
VP1Serialise::version
qint32 version() const
Definition: VP1Serialise.cxx:122