roviz  0.7
Code Documentation of roviz
startup_helper_p.h
1 #ifndef STARTUP_HELPER_P_H
2 #define STARTUP_HELPER_P_H
3 
5 #include <QSharedPointer>
6 #include <QMutex>
7 
12 {
13 public:
18  ObjectState(const QMetaObject& metaobj);
25  ObjectState(const QMetaObject& metaobj, internal::VoidFnPtr initFunc, internal::VoidFnPtr deinitFunc);
26 
31  QString className() const;
36  QStringList dependencies() const;
37 
42  QStringList optionalDependencies() const;
43 
48  bool initialized() const;
49 
50 
55  bool guiModule() const;
56 
61  bool init();
66  bool postInit();
71  bool preDestroy();
76  bool destroy();
77 
78 private:
79  const QMetaObject _metaObject;
80  bool _initialized;
81  bool _guiModule;
82  QStringList _dependencies;
83  QStringList _optionalDependencies;
84  const bool _isSingleton;
85  AbstractSingleton* _instance;
86  internal::VoidFnPtr _initFunc;
87  internal::VoidFnPtr _deinitFunc;
88 };
89 
90 
92 {
93 public:
94 
100  static bool start();
101 
107  static bool stop();
108 
113  static void registerHandlers();
114 
122  static bool getClassesRecursive(QStringList backtrace, QStringList& globalDependencies, const ObjectState& object);
123 
130  static void addComponentHelper(const QMetaObject& metaobj, internal::VoidFnPtr initFunc, internal::VoidFnPtr deinitFunc);
131 
136  static void addSingletonHelper(const QMetaObject& metaobj);
137 
143  static ObjectState* findClass(QString classname);
144 private:
145 
146  static QVector<QSharedPointer<ObjectState>> _classes;
147  static bool _initalized;
148  static QStringList _orderedClasses;
149  static QMutex _registredMutex;
150  static bool _registred;
151 };
152 
153 #endif // STARTUP_HELPER_P_H
154 
bool guiModule() const
Whether or not the represented class is a gui module (= it requires a Q(Gui)Application to run) ...
Definition: startup_helper.cpp:300
QString className() const
Returns the name of the class represented by the ObjectState.
Definition: startup_helper.cpp:280
bool initialized() const
Whether or not the represented class has already been initialized.
Definition: startup_helper.cpp:295
bool init()
Tries to construct the represented singleton or call init() on the represented component.
Definition: startup_helper.cpp:305
bool destroy()
Tries to delete the represented singleton or call deinit() on the represented component.
Definition: startup_helper.cpp:365
bool preDestroy()
Tries to call preDestroy() on the represented singleton. Does nothing if the represented class is a c...
Definition: startup_helper.cpp:352
bool postInit()
Tries to call postInit() on the represented singleton. Does nothing if the represented class is a com...
Definition: startup_helper.cpp:339
The ObjectState class represents the State of a Singleton or Component and helps calling create/delet...
Definition: startup_helper_p.h:11
The AbstractSingleton class defines functions that every singleton must implement Every Singleton mus...
Definition: singleton.h:12
ObjectState(const QMetaObject &metaobj)
Constructs a ObjectState for a Singleton.
Definition: startup_helper.cpp:233
QStringList dependencies() const
Returns a list of all dependencies of the represented class.
Definition: startup_helper.cpp:285
Definition: startup_helper_p.h:91
QStringList optionalDependencies() const
Returns a list of all optional dependencies of the represented class.
Definition: startup_helper.cpp:290