ATLAS Offline Software
Loading...
Searching...
No Matches
VP1Serialise.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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>
30//class JetCollectionSettingsButton;
32class SoMaterial;
33class QCheckBox;
34class QGroupBox;
35class QComboBox;
36class QLineEdit;
37class QDoubleSpinBox;
38class QSpinBox;
39class QSlider;
40class QToolBox;
41class QRadioButton;
42class QWidget;
43class QObject;
44
46public:
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);
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&);
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!!
116private:
117
118 class Imp;
120 QDataStream * stream();
121
122};
123
125// INLINES //
127
128template <class T>
129void 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
135template <class T>
137{
138 save(const_cast<const T*>(t));
139}
140
141#endif
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")
void messageVerbose(const QString &) const
static bool verbose()
Definition VP1Msg.h:31
void saveByTitle(QToolBox *)
void disableUnsavedChecks()
void save(bool)
static unsigned numberOfInstantiations()
void ignoreWidget(const QWidget *)
qint32 version() const
VP1Serialise(qint32 version, IVP1System *sys=0)
QDataStream * stream()
static void decrementNumberOfInstantiations()
void warnUnsaved(const QObject *)
void widgetHandled(const QWidget *)
virtual ~VP1Serialise()
const QByteArray & result()