forked from jacyara/GenESyS-Reborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModelPersistenceMyImpl1.cpp
78 lines (62 loc) · 2.24 KB
/
ModelPersistenceMyImpl1.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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: ModelPersistence.cpp
* Author: cancian
*
* Created on 24 de Agosto de 2018, 19:22
*/
#include <iostream>
#include "ModelPersistenceMyImpl1.h"
#include "ModelComponent.h"
ModelPersistenceMyImpl1::ModelPersistenceMyImpl1(Model* model) {
_model = model;
}
ModelPersistenceMyImpl1::ModelPersistenceMyImpl1(const ModelPersistenceMyImpl1& orig) {
}
ModelPersistenceMyImpl1::~ModelPersistenceMyImpl1() {
}
bool ModelPersistenceMyImpl1::saveAsTXT(std::string filename) {
bool res = true;
std::list<std::string>* words;
// save model own infos
// ...
// save components
List<ModelComponent*>* components = this->_model->getComponents();
for (std::list<ModelComponent*>::iterator it = components->getList()->begin(); it != components->getList()->end(); it++) {
words = (*it)->SaveInstance((*it));
_saveLine(words);
}
// save infras
std::list<std::string>* infraTypenames = _model->getInfrastructureTypenames();
for (std::list<std::string>::iterator itTypenames=infraTypenames->begin(); itTypenames!=infraTypenames->end(); itTypenames++) {
List<ModelInfrastructure*>* infras = _model->getInfrastructures((*itTypenames));
for (std::list<ModelInfrastructure*>::iterator it=infras->getList()->begin(); it!=infras->getList()->end(); it++) {
_model->trace(Util::TraceLevel::TL_blockArrival, "Writing infrastructure \"" + (*it)->getName() + "\"");
words = (*it)->SaveInstance((*it));
_saveLine(words);
}
}
}
bool ModelPersistenceMyImpl1::loadAsTXT(std::string filename) {
}
bool ModelPersistenceMyImpl1::saveAsXML(std::string filename) {
}
bool ModelPersistenceMyImpl1::loadAsXML(std::string filename) {
}
void ModelPersistenceMyImpl1::_saveLine(std::list<std::string>* words) {
std::string line = "";
for (std::list<std::string>::iterator it = words->begin(); it != words->end(); it++) {
line += (*it) + " ; ";
}
_model->trace(Util::TL_mostDetailed, line);
}
bool ModelPersistenceMyImpl1::save(std::string filename) {
return this->saveAsTXT(filename);
}
bool ModelPersistenceMyImpl1::load(std::string filename) {
return this->loadAsTXT(filename);
}