-
Notifications
You must be signed in to change notification settings - Fork 371
Expand file tree
/
Copy pathprocessedFile.h
More file actions
87 lines (66 loc) · 1.74 KB
/
processedFile.h
File metadata and controls
87 lines (66 loc) · 1.74 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
#include "mLibInclude.h"
#define X_PROCESSED_FILE_STATE_FIELDS \
X(bool, valid) \
X(unsigned int, heapFreeCount) \
X(unsigned int, numValidOptTransforms) \
X(unsigned int, numTransforms) \
X(bool, aligned)
#ifndef VAR_NAME
#define VAR_NAME(x) #x
#endif
#define checkSizeArray(a, d)( (((sizeof a)/(sizeof a[0])) >= d))
class ProcessedFile
{
public:
#define X(type, name) type name;
X_PROCESSED_FILE_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() {
aligned = false;
#define X(type, name) \
if (!m_ParameterFile.readParameter(std::string(#name), name) && std::string(#name) != "aligned") {MLIB_WARNING(std::string(#name).append(" ").append("uninitialized")); name = type();}
X_PROCESSED_FILE_STATE_FIELDS
#undef X
m_bIsInitialized = true;
}
template<class T>
std::string makeString(const T& in) {
std::string ret = std::to_string(in);
return ret;
}
template <>
std::string makeString<bool>(const bool& in) {
if (in == true) return "true";
else return "false";
}
void saveToFile(const std::string& outFile) {
std::ofstream out(outFile);
#define X(type, name) \
{ out << #name << " = " << makeString(name) << std::endl; }
X_PROCESSED_FILE_STATE_FIELDS
#undef X
}
void print() const {
#define X(type, name) \
std::cout << #name " = " << name << std::endl;
X_PROCESSED_FILE_STATE_FIELDS
#undef X
}
//! constructor
ProcessedFile() {
m_bIsInitialized = false;
}
//! destructor
~ProcessedFile() {
}
private:
bool m_bIsInitialized;
ParameterFile m_ParameterFile;
};