forked from jacyara/GenESyS-Reborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModelComponent.cpp
78 lines (65 loc) · 2.68 KB
/
ModelComponent.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: Element.cpp
* Author: cancian
*
* Created on 21 de Junho de 2018, 15:56
*/
#include "ModelComponent.h"
#include "Model.h"
ModelComponent::ModelComponent(Model* model) : ModelInfrastructure(typeid (this).name()) {
_model = model;
_nextComponents = new List<ModelComponent*>();
_checkedConnection = false;
}
ModelComponent::ModelComponent(const ModelComponent& orig) : ModelInfrastructure(orig) {
}
ModelComponent::~ModelComponent() {
}
void ModelComponent::Execute(Entity* entity, ModelComponent* component) {
component->_model->trace(Util::TraceLevel::TL_blockArrival, "Entity " + std::to_string(entity->getId()) + " has arrived at component \"" + component->_name + "\""); //std::to_string(component->_id));
try {
component->_execute(entity);
} catch (const std::exception& e) {
component->_model->traceError(e, "Error executing component " + component->show());
}
}
std::list<std::string>* ModelComponent::SaveInstance(ModelComponent* component) {
component->_model->trace(Util::TraceLevel::TL_blockArrival, "Writing component \"" + component->_name + "\""); //std::to_string(component->_id));
std::list<std::string>* words = new std::list<std::string>();
try {
words = component->_saveInstance();
} catch (const std::exception& e) {
component->_model->traceError(e, "Error executing component " + component->show());
}
return words;
}
bool ModelComponent::VerifySymbols(ModelComponent* component, std::string* errorMessage) {
component->_model->trace(Util::TraceLevel::TL_mostDetailed, "Verifying symbols of component " + component->_name); //std::to_string(component->_id));
bool res = false;
try {
res = component->_verifySymbols(errorMessage);
if (!res) {
component->_model->trace(Util::TraceLevel::TL_mostDetailed, "Verification of symbols of component \"" + component->_name + "\" has failed with message " + *errorMessage);
}
} catch (const std::exception& e) {
component->_model->traceError(e, "Error executing component " + component->show());
}
return res;
}
List<ModelComponent*>* ModelComponent::getNextComponents() const {
return _nextComponents;
}
std::string ModelComponent::show() {
return ModelInfrastructure::show(); // "{id=" + std::to_string(this->_id) + ",name=\""+this->_name + "\"}"; // , nextComponents[]=(" + _nextComponents->show() + ")}";
}
bool ModelComponent::getCheckedConnection(){
return this->_checkedConnection;
}
void ModelComponent::setCheckedConnection( bool _checkedConnection){
this->_checkedConnection = _checkedConnection;
}