forked from Conedy/Conedy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.cpp
167 lines (101 loc) · 2.93 KB
/
command.cpp
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "command.h"
#include "fullNetwork.h"
#include<iostream>
#include<fstream>
#include <sstream>
//#include <unistd.h>
#define MAXTIMESTEPS 1000
//#include <direct> // for getcwd
#include <stdlib.h> // for MAX_PATH
#include <iostream> // for cout and cin
// function to return the current working directory
// this is generally the application path
using namespace std;
map < string, int > command::varType;
map < string, baseType* > command::baseTypeVar;
map < string, bool* > command::boolVar;
map < string, int* > command::intVar;
map < string, networkTemplate* >command::networkVar;
map < string, nodeBlueprint** >command::nodeVar;
map < string, edgeBlueprint** >command::edgeVar;
map < string, string* >command::stringVar;
vector < string > command::inputFiles;
void emptyFunction () {}
void command::declare(string s, int type) // Meldet s als Variablenname an ( so wie bei "double d;")
{
if (varType.count(s) != 0)
{
// cout << "String:" << s << endl;
// cout << "VarType:" << varType[s] << endl;
// throw "Doppelt declared.";
}
varType [s] = type;
if (type == _network_)
{
networkTemplate n;
networkVar[s] = new networkTemplate(n);
}
if (type == _node_)
{
dynNode **n =new dynNode*();
// node *nod = new node();
// n = & nod;
nodeVar[s] = n;
}
if (type == _edge_)
{
edgeBlueprint **n =new edgeBlueprint*();
// edge *nod = new node();
// n = & nod;
edgeVar[s] = n;
}
if (type == _string_)
{
stringVar[s] = new string();
}
if (type == _baseType_) baseTypeVar[s] = new baseType();
if (type == _bool_) boolVar[s] = new bool();
if (type == _int_) intVar[s] = new int();
};
void command::clear()
{
node::theNodes.clear();
containerNode<baseType,1>::clear();
containerNode<baseType,2>::clear();
containerNode<baseType,3>::clear();
containerNode<baseType,4>::clear();
map <string,networkTemplate*>::iterator itnet, ienet;
itnet = networkVar.begin();
ienet = networkVar.end();
for (;itnet != ienet; itnet++)
itnet->second->clear();
}
void command::finalize()
{
map <string,networkTemplate*>::iterator itnet, ienet;
itnet = networkVar.begin();
ienet = networkVar.end();
for (;itnet != ienet; itnet++)
delete itnet->second;
map <string,edgeBlueprint**>::iterator itedge, ieedge;
itedge = edgeVar.begin();
ieedge = edgeVar.end();
for (;itedge != ieedge; itedge++)
delete itedge->second;
map <string,nodeBlueprint**>::iterator itnode, ienode;
itnode = nodeVar.begin();
ienode = nodeVar.end();
for (;itnode != ienode; itnode++)
delete itnode->second;
/* map <string,double*>::iterator itd, ied;
itd = doubleVar.begin();
ied = doubleVar.end();
for (;itd != ied; itd++)
delete itd->second;
map <string,int*>::iterator iti, iei;
iti = intVar.begin();
iei = intVar.end();
for (;iti != iei; iti++)
delete iti->second;
*/
}