Commit a94264e6 authored by Arthur Redondy's avatar Arthur Redondy
Browse files

fin d'implementation du parser d'evenements

parent 59ec5fac
#include "ParserEventDecoder.hpp"
//#define INSTANCIATE(nom_de_champPaje,type,nom_variable,nom_variable_is_initialized) if (fields[i-1].name == nom_de_champPaje) { \
// if(!String::instanciate(current_value, nom_variable)) { \
// cout << "warning : incompatible value" << endl; \
// return; \
// } \
// nom_variable_is_initialized = true; \
// }
using namespace std;
ParserEventDecoder::ParserEventDecoder(){
}
void ParserEventDecoder::store_event(const Definition &definition, Line &line, Trace &trace){
String alias;
bool alias_is_initialized = false;
String name;
bool name_is_initialized = false;
String container_type;
bool container_type_is_initialized = false;
String source_container_type;
bool source_container_type_is_initialized = false;
String dest_container_type;
bool dest_container_type_is_initialized = false;
String entity_type;
bool entity_type_is_initialized = false;
Date time;
bool time_is_initialized = false;
String type;
bool type_is_initialized = false;
String container;
bool container_is_initialized = false;
String value_string;
bool value_string_is_initialized = false;
String source_container_type;
String dest_container_type;
String entity_type;
Date time;
String type;
String container;
String value_string;
Double value_double;
bool value_double_is_initialized = false;
String source_container;
bool source_container_is_initialized = false;
String dest_container;
bool dest_container_is_initialized = false;
String source_container;
String dest_container;
String key;
bool key_is_initialized = false;
vector<Value> extra_fields; ///// Il faut un vector de Value * -> Interface...
vector<Value *> extra_fields;
int i = 1;
vector<field> fields = definition.get_fields();
......@@ -85,22 +50,18 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else if (fields[i-1]._name == "ContainerType") {
container_type = current_value;
container_type_is_initialized = true;
}
else if (fields[i-1]._name == "SourceContainerType") {
source_container_type = current_value;
source_container_type_is_initialized = true;
}
else if (fields[i-1]._name == "DestContainerType") {
dest_container_type = current_value;
dest_container_type_is_initialized = true;
}
else if (fields[i-1]._name == "EntityType") {
entity_type = current_value;
entity_type_is_initialized = true;
}
else if (fields[i-1]._name == "Time") {
......@@ -108,17 +69,14 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
cout << "warning : incompatible value" << endl;
return;
}
time_is_initialized = true;
}
else if (fields[i-1]._name == "Type") {
type = current_value;
type_is_initialized = true;
}
else if (fields[i-1]._name == "Container") {
container = current_value;
container_is_initialized = true;
}
else if (fields[i-1]._name == "Value") {
......@@ -127,27 +85,22 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
cout << "warning : incompatible value" << endl;
return;
}
value_double_is_initialized = true;
}
else {
value_string = current_value;
value_string_is_initialized = true;
}
}
else if (fields[i-1]._name == "SourceContainer") {
source_container = current_value;
source_container_is_initialized = true;
}
else if (fields[i-1]._name == "DestContainer") {
dest_container = current_value;
dest_container_is_initialized = true;
}
else if (fields[i-1]._name == "Key") {
key = current_value;
key_is_initialized = true;
}
else {
......@@ -208,7 +161,6 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
cout << "warning : extra value(s)" << endl;
}
//////A faire : remplir un "Name alias_name" avec alias et name
Name alias_name;
if(alias_is_initialized && name_is_initialized){
......@@ -221,7 +173,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
alias_name = Name(name_only_t(), name.to_string());
}
else{ // One of the field should have been initialised
cerr << "The event has no name and no alias." << endl;
cerr << "BUG PARSER" << endl;
return;
}
......@@ -230,108 +182,71 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
string event_name = definition.get_event_name();
if(event_name == "PajeDefineContainerType") {
if(// alias_name_is_initialized && //// On en a pas besoin car si c'est pas initialisé on le voit avant
container_type_is_initialized) {
trace.define_container_type(alias_name, container_type, extra_fields);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
trace.define_container_type(alias_name, trace.search_container_type(container_type), extra_fields);
}
else if(event_name == "PajeCreateContainer") {
if(time_is_initialized &&// alias_name_is_initialized &&
type_is_initialized && container_is_initialized) {
trace.create_container(time, alias_name, type, container, extra_fields);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
trace.create_container(time, alias_name, trace.search_container_type(type), trace.search_container(container), extra_fields);
}
else if(event_name == "PajeDestroyContainer") {
if(time_is_initialized && // alias_name_is_initialized &&
type_is_initialized) {
trace.destroy_container(time, alias_name, type, extra_fields);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
trace.destroy_container(time, alias_name, trace.search_container_type(type), extra_fields);
}
else if(event_name == "PajeDefineEventType") {
if(// alias_name_is_initialized &&
container_type_is_initialized) {
trace.define_event_type(alias_name, container_type, extra_fields);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
trace.define_event_type(alias_name, trace.search_container_type(container_type), extra_fields);
}
else if(event_name == "PajeDefineStateType") {
if(// alias_name_is_initialized &&
container_type_is_initialized) {
trace.define_state_type(alias_name, container_type, extra_fields);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
trace.define_state_type(alias_name, trace.search_container_type(container_type), extra_fields);
}
else if(event_name == "PajeDefineVariableType") {
if(// alias_name_is_initialized &&
container_type_is_initialized) {
trace.define_variable_type(alias_name, container_type, extra_fields);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
trace.define_variable_type(alias_name, trace.search_container_type(container_type), extra_fields);
}
else if(event_name == "PajeDefineLinkType") {
if(// alias_name_is_initialized &&
container_type_is_initialized && source_container_type_is_initialized && dest_container_type_is_initialized) {
trace.define_variable_type(alias_name, container_type, source_container_type, dest_container_type, extra_fields);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
trace.define_link_type(alias_name, trace.search_container_type(container_type), trace.search_container_type(source_container_type), trace.search_container_type(dest_container_type), extra_fields);
}
else if(event_name == "PajeDefineEntityValue") {
if(// alias_name_is_initialized &&
entity_type_is_initialized) {
trace.define_variable_type(alias_name, entity_type, extra_fields);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
trace.define_entity_value(alias_name, trace.search_entity_type(entity_type), extra_fields);
}
else if(event_name == "PajeSetState") {
if(time_is_initialized && type_is_initialized// && value_is_initialized
) {
trace.define_variable_type(time, type, extra_fields);
}
else {
cout << "warning : incompatible evenement" << endl;
return;
}
trace.set_state(time, trace.search_state_type(type), trace.search_container(container), trace.search_entity_value(value_string), extra_fields);
}
else if(event_name == "PajePushState") {
trace.push_state(time, trace.search_state_type(type), trace.search_container(container), trace.search_entity_value(value_string), extra_fields);
}
else if(event_name == "PajePopState") {
trace.pop_state(time, trace.search_state_type(type), trace.search_container(container), extra_fields);
}
else if(event_name == "PajeNewEvent") {
trace.new_event(time, trace.search_event_type(type), trace.search_container(container), trace.search_entity_value(value_string), extra_fields);
}
//A faire : encore des type d'evenement a definir + chercher les parents et types des parents quand il le faut
else if(event_name == "PajeSetVariable") {
trace.set_variable(time, trace.search_variable_type(type), trace.search_container(container), value_double, extra_fields);
}
else if(event_name == "PajeAddVariable") {
trace.add_variable(time, trace.search_variable_type(type), trace.search_container(container), value_double, extra_fields);
}
else if(event_name == "PajeSubVariable") {
trace.add_variable(time, trace.search_variable_type(type), trace.search_container(container), value_double, extra_fields);
}
else if(event_name == "PajeStartLink") {
trace.add_variable(time, trace.search_link_type(type), trace.search_container(container), trace.search_container(source_container), trace.search_entity_value(value_string), key, extra_fields);
}
else {
cout << "warning : unknown evenement" << endl;
cerr << "BUG PARSER BIS" << endl;
return;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment