diff --git a/parser/src/ParserEventDecoder.cpp b/parser/src/ParserEventDecoder.cpp index e1ebf25836a4bf6679e27db5dcec1764cf95ae81..11129d65acd4a15508f0ee66637c97d468ec7ae3 100644 --- a/parser/src/ParserEventDecoder.cpp +++ b/parser/src/ParserEventDecoder.cpp @@ -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; } } diff --git a/parser/src/ParserEventDecoder.hpp b/parser/src/ParserEventDecoder.hpp index 5a59576cd72b9bed05798f4aa450ca836db697e2..9fc68f08f3a1cd882f3098a70ce91db3000c29ad 100644 --- a/parser/src/ParserEventDecoder.hpp +++ b/parser/src/ParserEventDecoder.hpp @@ -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 diff --git a/parser/tests/stub/trace.cpp b/parser/tests/stub/trace.cpp index 97cf529e2c83cc3274361abff893d4f942d0d085..818e040e77c8b26777410aa6318454ee15933704 100644 --- a/parser/tests/stub/trace.cpp +++ b/parser/tests/stub/trace.cpp @@ -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 + ")"; + } + + diff --git a/parser/tests/stub/trace.hpp b/parser/tests/stub/trace.hpp index 69fc1481ea8abb52a9c866f7071f2dacdd5a5391..61c7fdb2cfc4f2aa502a6b67f47f01854bf045ad 100644 --- a/parser/tests/stub/trace.hpp +++ b/parser/tests/stub/trace.hpp @@ -1,12 +1,12 @@ - - - #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; - + /*! * * \fn search_container * \brief search a container by his name or alias - * + * */ Container *search_container(String name) const; - + /*! * * \fn search_event_type * \brief search a event type by his name or alias - * + * */ Container *search_event_type(String name) const; @@ -292,7 +295,7 @@ public : * * \fn search_state_type * \brief search a container by his name or alias - * + * */ Container *search_state_type(String name) const; @@ -301,7 +304,7 @@ public : * * \fn search_variable_type * \brief search a variable type by his name or alias - * + * */ Container *search_variable_type(String name) const; @@ -310,17 +313,18 @@ public : * * \fn search_link_type * \brief search a container by his name or alias - * + * */ Container *search_link_type(String name) const; - + /*! * * \fn search_entity_value * \brief search a container by his name or alias - * + * */ Container *search_entity_value(String name) const; + Container *search_entity_type(String name) const; };//end class diff --git a/trace/src/values/Name.cpp b/trace/src/values/Name.cpp index cc30d23cca209ab81977c94a635ab446f9a96be5..fa0a6db9e3e87fcbe4c90165c2682922654cf700 100644 --- a/trace/src/values/Name.cpp +++ b/trace/src/values/Name.cpp @@ -18,11 +18,11 @@ Name::Name(name_only_t name_only, std::string name) { _alias.clear(); } -void Name::set_name(std::string &name) { +void Name::set_name(std::string name) { _name = name; } -void Name::set_alias(std::string &alias) { +void Name::set_alias(std::string alias) { _alias = alias; } diff --git a/trace/src/values/Name.hpp b/trace/src/values/Name.hpp index 49e0d2c5e59dd0de4d8fff0675765809622345d7..f338726a1f65dbf608e61029f67044cd607c498d 100644 --- a/trace/src/values/Name.hpp +++ b/trace/src/values/Name.hpp @@ -4,9 +4,9 @@ * * \file Name.hpp * \author Clément Vuchener - * \brief + * \brief * \date 2009 January 30th - * + * */ #include "Value.hpp" @@ -18,28 +18,28 @@ struct name_only_t {}; /*! * * \brief Used to construct a Name object with only an alias - * - */ + * + */ extern const alias_only_t alias_only; /*! * * \Brief Used to construct a Name object with only a name - * - */ + * + */ extern const name_only_t name_only; /*! * * \class Name * \brief Store a name and/or an alias for trace objects - * + * */ class Name: public Value { private: std::string _alias, _name; -public: +public: /*! * \brief Constructor */ @@ -50,28 +50,28 @@ public: * \brief Define with both name and alias * \param name Name of the object * \param alias Alias of the object - * + * */ Name(std::string name, std::string alias); - + /*! * * \brief Define with only a name * \param name_only Must be name_only - * \param name Name of the object - * + * \param name Name of the object + * */ Name(name_only_t name_only, std::string name); - + /*! * * \brief Define with only a alias * \param alias_anly Must be alias_only - * \param alias Alias of the object - * + * \param alias Alias of the object + * */ Name(alias_only_t, std::string alias); - + /*! * * \brief Copy constructor @@ -82,36 +82,36 @@ public: /*! * \fn set_name(std::string &name) * \brief Set the name - * \param name Name of the object - * + * \param name Name of the object + * */ - void set_name(std::string &name); + void set_name(std::string name); /*! * \fn set_alias(std::string &alias) * \brief Set the alias - * \param alias Alias of the object - * + * \param alias Alias of the object + * */ - void set_alias(std::string &alias); + void set_alias(std::string alias); /*! * * \fn to_string() const - * \return The name of the object, if it exists, the alias otherwise - * - */ + * \return The name of the object, if it exists, the alias otherwise + * + */ std::string to_string() const; - + /*! * * \fn operator== (String &) const * \brief Compare the string with the name or the alias - * \return true if the string equals the name or the alias + * \return true if the string equals the name or the alias * */ - bool operator== (String &) const; + bool operator== (String &) const; }; #endif // NAME_HPP diff --git a/trace/src/values/Value.hpp b/trace/src/values/Value.hpp index 2e5400400877c4063d119719eacf631b26c81edf..89c4b14161209856c197fcf2a4c7bda021944b5c 100644 --- a/trace/src/values/Value.hpp +++ b/trace/src/values/Value.hpp @@ -7,7 +7,7 @@ * \author Clément Vuchener * \brief Contains the definition of the class Value * \date 2009 January 30th - * + * */ @@ -16,17 +16,18 @@ * * \class Value * \brief Abstract class to store calue used in the trace - * + * */ class Value { -public: +public: /*! * * \fn to_string - * - */ + * + */ virtual std::string to_string() const = 0; + virtual ~Value(); }; #endif // VALUE_HPP