Commit bdeb01b7 authored by Pascal Noisette's avatar Pascal Noisette
Browse files

No commit message

No commit message
parent f4c6548a
......@@ -6,38 +6,38 @@ 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;
String source_container_type;
String dest_container_type;
String entity_type;
Date time;
String type;
String container;
String value_string;
String source_container_type;
String dest_container_type;
String entity_type;
Date time;
String type;
String container;
String value_string;
Double value_double;
String source_container;
String dest_container;
String source_container;
String dest_container;
String key;
vector<Value *> extra_fields;
int i = 1;
vector<field> fields = definition.get_fields();
int number_of_values = fields.size();
while(i < number_of_values) {
string current_value;
if (!line.item(i, current_value)) {
cout << "warning : missing values" << endl;
return;
}
else if (fields[i-1]._name == "Alias") {
alias = current_value;
alias_is_initialized = true;
......@@ -55,7 +55,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else if (fields[i-1]._name == "SourceContainerType") {
source_container_type = current_value;
}
else if (fields[i-1]._name == "DestContainerType") {
dest_container_type = current_value;
}
......@@ -106,15 +106,17 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else {
if(fields[i-1]._type == "string") {
String value = current_value;
extra_fields.push_back(value);
extra_fields.push_back(&value);
}
else if(fields[i-1]._type == "double") {
Double value;
if(!Double::instantiate(current_value, value)) {
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value);
extra_fields.push_back(&value);
}
else if(fields[i-1]._type == "hex") {
Hex value;
......@@ -122,7 +124,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value);
extra_fields.push_back(&value);
}
else if(fields[i-1]._type == "date") {
Date value;
......@@ -130,7 +132,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value);
extra_fields.push_back(&value);
}
else if(fields[i-1]._type == "integer") {
Integer value;
......@@ -138,7 +140,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value);
extra_fields.push_back(&value);
}
else if(fields[i-1]._type == "color") {
Color value;
......@@ -146,7 +148,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
cout << "warning : incompatible value" << endl;
return;
}
extra_fields.push_back(value);
extra_fields.push_back(&value);
}
else {
cout << "warning : unknown type" << endl;
......@@ -156,27 +158,20 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
i++;
}
if(line.length() > i) {
cout << "warning : extra value(s)" << endl;
}
Name alias_name;
if(alias_is_initialized && name_is_initialized){
alias_name = Name(name.to_string(), alias.to_string());
}
else if (alias_is_initialized && !name_is_initialized){
alias_name = Name(alias_only_t(), alias.to_string());
if(alias_is_initialized){
alias_name.set_alias(alias.to_string());
}
else if (!alias_is_initialized && name_is_initialized){
alias_name = Name(name_only_t(), name.to_string());
if (name_is_initialized){
alias_name.set_name(name.to_string());
}
else{ // One of the field should have been initialised
cerr << "BUG PARSER" << endl;
return;
}
string event_name = definition.get_event_name();
......@@ -247,7 +242,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
else {
cerr << "BUG PARSER BIS" << endl;
return;
return;
}
}
......@@ -12,7 +12,7 @@
#include "../../trace/src/values/Integer.hpp"
#include "../../trace/src/values/Name.hpp"
#include "../../trace/src/values/String.hpp"
#include "../../trace/src/Trace.hpp"
#include "../tests/stub/trace.hpp"
/**
* \class ParserEventDecoder
......
......@@ -24,50 +24,50 @@ std::string& to_string(const vector<Value*> &opt){
void define_container_type(Name alias, ContainerType *container_type_parent, const vector<Value> &opt){
cout << "define_container_type "
<< alias.to_string()
<< " "
<< container_type_parent->to_string()
<< " "
<< " "
<< container_type_parent->to_string()
<< " "
<< to_string(opt)
<< endl;
}
void create_container(Date time, Name alias, ContainerType *type, Container *parent, const vector<Value> &opt){
cout << "create_container "
<< time.to_string
<< " "
<< " "
<< alias.to_string()
<< " "
<< type->to_string()
<< " "
<< parent->to_string()
<< " "
<< " "
<< type->to_string()
<< " "
<< parent->to_string()
<< " "
<< to_string(opt)
<< endl;
}
void destroy_container(Date time, Name alias, ContainerType *type, const vector<Value> &opt){
cout << "destroy_container "
<< time.to_string
<< " "
<< " "
<< alias.to_string()
<< " "
<< type->to_string()
<< " "
<< " "
<< type->to_string()
<< " "
<< to_string(opt)
<< endl;
}
void define_event_type(Name alias, ContainerType *container_type, const vector<Value> &opt){
cout << "define_event_type "
<< alias.to_string()
<< " "
<< container_type->to_string()
<< " "
<< " "
<< container_type->to_string()
<< " "
<< to_string(opt)
<< endl;
}
......@@ -77,9 +77,9 @@ void define_container_type(Name alias, ContainerType *container_type_parent, con
void define_state_type(Name alias, ContainerType *container_type, const vector<Value> &opt){
cout << "define_state_type "
<< alias.to_string()
<< " "
<< container_type->to_string()
<< " "
<< " "
<< container_type->to_string()
<< " "
<< to_string(opt)
<< endl;
}
......@@ -88,43 +88,43 @@ void define_container_type(Name alias, ContainerType *container_type_parent, con
void define_variable_type(Name alias, ContainerType *container_type, const vector<Value> &opt){
cout << "define_variable_type "
<< alias.to_string()
<< " "
<< container_type->to_string()
<< " "
<< " "
<< container_type->to_string()
<< " "
<< to_string(opt)
<< endl;
}
void define_link_type(Name alias, ContainerType *ancestor, ContainerType *source, ContainerType *destination, const vector<Value> &opt){
cout << "define_link_type "
<< alias.to_string()
<< " "
<< ancestor->to_string()
<< " "
<< source->to_string()
<< " "
<< destination->to_string()
<< " "
<< " "
<< ancestor->to_string()
<< " "
<< source->to_string()
<< " "
<< destination->to_string()
<< " "
<< to_string(opt)
<< endl;
}
void define_entity_value(Name alias, EntityType *entity_type, const vector<Value> &opt){
cout << "define_entity_value "
<< alias.to_string()
<< " "
<< entity_type->to_string()
<< " "
<< " "
<< entity_type->to_string()
<< " "
<< to_string(opt)
<< endl;
}
void set_state(Date time, StateType *type, Container *container, EntityValue *value, const vector<Value> &op){
cout << "set_state "
<< time.to_string()
......@@ -140,7 +140,7 @@ void set_state(Date time, StateType *type, Container *container, EntityValue *va
}
void push_state(Date time, StateType *type, Container *container, EntityValue *value, const vector<Value> &opt){
cout << "push_state "
<< time.to_string()
......@@ -156,7 +156,7 @@ void push_state(Date time, StateType *type, Container *container, EntityValue *v
}
void pop_state(Date time, StateType *type, Container *container, const vector<Value> &opt){
cout << "pop_state "
......@@ -171,7 +171,7 @@ void pop_state(Date time, StateType *type, Container *container, const vector<Va
}
void new_event(Date time, EventType *type, Container *container, EntityValue *value, const vector<Value> &opt){
cout << "new_event "
<< time.to_string()
......@@ -187,7 +187,7 @@ void new_event(Date time, EventType *type, Container *container, EntityValue *va
}
void set_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value> &opt){
cout << "set_variable "
......@@ -220,7 +220,7 @@ void add_variable(Date time, VariableType *type, Container *container, Double va
}
void sub_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value> &opt){
cout << "sub_variable "
......@@ -257,7 +257,7 @@ void start_link(Date time, LinkType *type, Container *ancestor, Container *sourc
}
void end_link(Date time, LinkType *type, Container *ancestor, Container *destination, EntityValue *value, Integer key, const vector<Value> &opt){
cout << "start_link "
......@@ -278,34 +278,34 @@ void end_link(Date time, LinkType *type, Container *ancestor, Container *destina
}
list <Container *> get_root_containers(){}
Container *search_container_type(String name)
{
return "search(" + name + ")";
}
Container *search_container(String name)
{
return "search(" + name + ")";
}
Container *search_event_type(String name)
{
return "search(" + name + ")";
}
Container *search_state_type(String name)
{
return "search(" + name + ")";
}
Container *search_variable_type(String name) {
......@@ -313,15 +313,20 @@ void end_link(Date time, LinkType *type, Container *ancestor, Container *destina
}
Container *search_link_type(String name) {
return "search(" + name + ")";
}
Container *search_entity_value(String name) {
return "search(" + name + ")";
}
Container *search_entity_type(String name) const
{
return "search(" + name + ")";
}
#ifndef TRACE_HPP
#define TRACE_HPP
#include "string.hpp"
#include "name.hpp"
#include "date.hpp"
#include <vector>
/*!
*
* \file Trace.hpp
......@@ -17,11 +17,14 @@
*
*/
typedef Container std::string;
typedef ContainerType std::string;
typedef EntityType std::string;
typedef std::string Container ;
typedef std::string ContainerType ;
typedef std::string EntityType ;
typedef std::string StateType;
typedef std::string EntityValue;
typedef std::string EventType;
typedef std::string VariableType;
typedef std::string LinkType;
class Trace{
......@@ -36,7 +39,7 @@ public :
*\param Name : an object that can contain a name, an alias or both
*
*/
void define_container_type(Name alias, ContainerType *container_type_parent, const vector<Value> &opt);
void define_container_type(Name alias, ContainerType *container_type_parent, const std::vector<Value*> &opt);
/*!
*
......@@ -50,7 +53,7 @@ public :
*\param String : the parent of the container
*
*/
void create_container(Date time, Name alias, ContainerType *type, Container *parent, const vector<Value> &opt);
void create_container(Date time, Name alias, ContainerType *type, Container *parent, const std::vector<Value*> &opt);
/*!
*
......@@ -62,7 +65,7 @@ public :
*\param Sring : the type of the container
*
*/
void destroy_container(Date time, Name alias, ContainerType *type, const vector<Value> &opt);
void destroy_container(Date time, Name alias, ContainerType *type, const std::vector<Value*> &opt);
/*!
......@@ -74,7 +77,7 @@ public :
*\param String : the type of the container
*
*/
void define_event_type(Name alias, ContainerType *container_type, const vector<Value> &opt);
void define_event_type(Name alias, ContainerType *container_type, const std::vector<Value*> &opt);
/*!
......@@ -87,7 +90,7 @@ public :
*
*
*/
void define_state_type(Name alias, ContainerType *container_type, const vector<Value> &opt);
void define_state_type(Name alias, ContainerType *container_type, const std::vector<Value*> &opt);
/*!
......@@ -99,7 +102,7 @@ public :
*\param String : the type of the container
*
*/
void define_variable_type(Name alias, ContainerType *container_type, const vector<Value> &opt);
void define_variable_type(Name alias, ContainerType *container_type, const std::vector<Value*> &opt);
/*!
......@@ -113,7 +116,7 @@ public :
*\param String : the type of the container where the link goes
*
*/
void define_link_type(Name alias, ContainerType *ancestor, ContainerType *source, ContainerType *destination, const vector<Value> &opt);
void define_link_type(Name alias, ContainerType *ancestor, ContainerType *source, ContainerType *destination, const std::vector<Value*> &opt);
/*!
......@@ -125,7 +128,7 @@ public :
*\param String : the type of the entity
*
*/
void define_entity_value(Name alias, EntityType *entity_type, const vector<Value> &opt);
void define_entity_value(Name alias, EntityType *entity_type, const std::vector<Value*> &opt);
/*!
......@@ -139,7 +142,7 @@ public :
*\param String : the new value of the state
*
*/
void set_state(Date time, StateType *type, Container *container, EntityValue *value, const vector<Value> &opt);
void set_state(Date time, StateType *type, Container *container, EntityValue *value, const std::vector<Value*> &opt);
/*!
......@@ -153,7 +156,7 @@ public :
*\param String : the new value of the state
*
*/
void push_state(Date time, StateType *type, Container *container, EntityValue *value, const vector<Value> &opt);
void push_state(Date time, StateType *type, Container *container, EntityValue *value, const std::vector<Value*> &opt);
/*!
......@@ -166,7 +169,7 @@ public :
*\param String : the container
*
*/
void pop_state(Date time, StateType *type, Container *container, const vector<Value> &opt);
void pop_state(Date time, StateType *type, Container *container, const std::vector<Value*> &opt);
/*!
......@@ -180,7 +183,7 @@ public :
*\param String : the value of the event
*
*/
void new_event(Date time, EventType *type, Container *container, EntityValue *value, const vector<Value> &opt);
void new_event(Date time, EventType *type, Container *container, EntityValue *value, const std::vector<Value*> &opt);
/*!
......@@ -194,7 +197,7 @@ public :
*\param double : the value of the variable
*
*/
void set_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value> &opt);
void set_variable(Date time, VariableType *type, Container *container, Double value, const std::vector<Value*> &opt);
/*!
......@@ -208,7 +211,7 @@ public :
*\param double : the value of the variable
*
*/
void add_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value> &opt);
void add_variable(Date time, VariableType *type, Container *container, Double value, const std::vector<Value*> &opt);
/*!
......@@ -222,7 +225,7 @@ public :
*\param double : the value of the variable
*
*/
void sub_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value> &opt);
void sub_variable(Date time, VariableType *type, Container *container, Double value, const std::vector<Value*> &opt);
/*!
......@@ -237,7 +240,7 @@ public :
*\param String : the value of the variable
*
*/
void start_link(Date time, LinkType *type, Container *ancestor, Container *source, EntityValue value, Integer key, const vector<Value> &opt);
void start_link(Date time, LinkType *type, Container *ancestor, Container *source, EntityValue value, Integer key, const std::vector<Value*> &opt);
/*!
......@@ -252,38 +255,38 @@ public :
*\param String : the value of the variable
*
*/
void end_link(Date time, LinkType *type, Container *ancestor, Container *destination, EntityValue *value, Integer key, const vector<Value> &opt);
void end_link(Date time, LinkType *type, Container *ancestor, Container *destination, EntityValue *value, Integer key, const std::vector<Value*> &opt);
/*!
*
* \fn get_root_container
* \brief returns the list of the root container
*
*
*/
list <Container *> get_root_containers() const;
/*!
*
* \fn search_container_type
* \brief search a container type by his name or alias
*
*
*/
Container *search_container_type(String name) const;