-
Notifications
You must be signed in to change notification settings - Fork 371
Expand file tree
/
Copy pathglobalAppState.h
More file actions
72 lines (53 loc) · 1.33 KB
/
globalAppState.h
File metadata and controls
72 lines (53 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#ifndef _GLOBAL_APP_STATE_H_
#define _GLOBAL_APP_STATE_H_
#include "mLibInclude.h"
#define X_GLOBAL_APP_STATE_FIELDS \
X(std::string, s_inputTestFile) \
X(std::string, s_sourceDirectory) \
X(std::vector<string>, s_methods)
#ifndef VAR_NAME
#define VAR_NAME(x) #x
#endif
#define checkSizeArray(a, d)( (((sizeof a)/(sizeof a[0])) >= d))
class GlobalAppState
{
public:
#define X(type, name) type name;
X_GLOBAL_APP_STATE_FIELDS
#undef X
//! sets the parameter file and reads
void readMembers(const ParameterFile& parameterFile) {
m_ParameterFile = parameterFile;
readMembers();
}
//! reads all the members from the given parameter file (could be called for reloading)
void readMembers() {
#define X(type, name) \
if (!m_ParameterFile.readParameter(std::string(#name), name)) {MLIB_WARNING(std::string(#name).append(" ").append("uninitialized")); name = type();}
X_GLOBAL_APP_STATE_FIELDS
#undef X
m_bIsInitialized = true;
}
void print() const {
#define X(type, name) \
std::cout << #name " = " << name << std::endl;
X_GLOBAL_APP_STATE_FIELDS
#undef X
}
static GlobalAppState& get() {
static GlobalAppState s;
return s;
}
//! constructor
GlobalAppState() {
m_bIsInitialized = false;
}
//! destructor
~GlobalAppState() {
}
private:
bool m_bIsInitialized;
ParameterFile m_ParameterFile;
};
#endif