-
Notifications
You must be signed in to change notification settings - Fork 1
/
docu.h
94 lines (75 loc) · 2.21 KB
/
docu.h
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
87
88
89
90
91
92
93
94
#ifndef DOKU_H_INCLUDED
#define DOKU_H_INCLUDED
#include <list>
#include <string>
#include <iostream>
#include <typeinfo>
#include <tuple>
#include "configuration.h"
#define CreateDocuClass(part, content...) template<>\
class DocuElement<part>{\
public:\
static string getSegmentName(){\
return #part;\
}\
static string getSegmentContent(){\
return #content;\
}\
};
class Dummy{};
template<template<class> class Part>
class DocuElement{
public:
static string getSegmentName(){
string result = "unknown part, techid = ";
result = result+(typeid(Part<Dummy>).name());
return result;
}
static string getSegmentContent(){
return "";
}
};
//custom DocuElements
template<>
class DocuElement<parts::ElectroEngine>{
public:
static string getSegmentName(){
return "ElectroEngine";
}
static string getSegmentContent(){
return "a engine driven by electric.";
}
};
CreateDocuClass(parts::AutoPilot,
ein autopilot, der dynamisch auf transmission reagiert
aber bla \nzeilenumbruch)
//end custom DocuElements
template<template<class> class... Parts>
class Documentation{
private:
list<tuple<string, string>> docuElementContent;
//static constexpr DocuElementBase docuElementContent[sizeof...(Parts<Dummy>)] = {DocuElement<Parts>()...};
public:
Documentation():docuElementContent({make_tuple(DocuElement<Parts>::getSegmentName(), DocuElement<Parts>::getSegmentContent())...}){}
list<tuple<string, string>>& getDocuElements(){
return docuElementContent;
}
string getTxtDocu(){
string result = "";
for(const auto & element : docuElementContent){
result = result + "name: " + get<0>(element) + "\n";
result = result + "content: " + get<1>(element) + "\n";
result = result + "\n";
}
return result;
}
template<template<class> class part>
static constexpr bool containsPart(){
return Config<Parts...>::template containsPart<part>();
}
template<class part>
static constexpr bool containsPart(){
return Config<Parts...>::template containsPart<part>();
}
};
#endif // DOKU_H_INCLUDED