Commit 7daa38e3 authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

Suppression des ^M dans la trace et ajout de fonctions pour les

définitions
parent 77d3d72f
......@@ -36,3 +36,315 @@ const vector<field> &Definition::get_fields() const{
string Definition::get_event_name() const{
return _event_name;
}
bool Definition::check_definition() const{
const int number_of_fields = _fields.size();
// Name - string or integer
// ContainerType - string or integer
// Alias - string or integer
if(_event_name == "PajeDefineContainerType" || _event_name == "PajeDefineEventType" || _event_name == "PajeDefineStateType" || _event_name == "PajeDefineVariableType"){
bool has_name_or_alias = false;
bool has_container_type = false;
for(int i = 0 ; i < number_of_fields ; i ++){
// We check if we have the name or the alias
if((_fields[i]._name == "Name" || _fields[i]._name == "Alias") && (_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_name_or_alias = true;
}
// We check if we have the ContainerType
else if(_fields[i]._name == "ContainerType" && (_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_container_type = true;
}
// We return true if we have the compulsory fields and we don't care of others
if(has_name_or_alias && has_container_type){
return true;
}
}
}
// Time - date, Name - string or integer, Type - string or integer,
// Container - string or integer, Alias - string or integer
else if(_event_name == "PajeCreateContainer"){
bool has_name_or_alias = false;
bool has_time = false;
bool has_type = false;
bool has_container = false;
for(int i = 0 ; i < number_of_fields ; i ++){
// We check if we have the name or the alias
if((_fields[i]._name == "Name" || _fields[i]._name == "Alias") && (_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_name_or_alias = true;
}
// We check if we have the container
else if(_fields[i]._name == "Container" && (_fields[i]._type == "string" || _fields[i]._type == "integer")){
has_container = true;
}
// We check if we have the time
else if(_fields[i]._name == "Time" && _fields[i]._type == "date"){
has_time = true;
}
// We check if we have the type
else if(_fields[i]._name == "Type" && (_fields[i]._type == "string" || _fields[i]._type == "integer")){
has_type = true;
}
// We return true if we have the compulsory fields and we don't care of others
if(has_name_or_alias && has_container && has_time && has_type){
return true;
}
}
}
// Time - date, Name - string or integer
// Type - string or integer
else if(_event_name == "PajeDestroyContainer"){
bool has_name_or_alias = false;
bool has_time = false;
bool has_type = false;
for(int i = 0 ; i < number_of_fields ; i ++){
// We check if we have the name or the alias
if((_fields[i]._name == "Name" || _fields[i]._name == "Alias") && (_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_name_or_alias = true;
}
// We check if we have the time
else if(_fields[i]._name == "Time" && _fields[i]._type == "date"){
has_time = true;
}
// We check if we have the type
else if(_fields[i]._name == "Type" && (_fields[i]._type == "string" || _fields[i]._type == "integer")){
has_type = true;
}
// We return true if we have the compulsory fields and we don't care of others
if(has_name_or_alias && has_time && has_type){
return true;
}
}
}
// Name - string or integer, ContainerType - string or integer
// SourceContainerType - string or integer, DestContainerType - string or integer
// Alias - string or integer
else if(_event_name == "PajeDefineLinkType"){
bool has_name_or_alias = false;
bool has_ContainerType = false;
bool has_SourceContainerType = false;
bool has_DestContainerType = false;
for(int i = 0 ; i < number_of_fields ; i ++){
// We check if we have the name or the alias
if((_fields[i]._name == "Name" || _fields[i]._name == "Alias") && (_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_name_or_alias = true;
}
// We check if we have the ContainerType
else if(_fields[i]._name == "ContainerType" && (_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_ContainerType = true;
}
// We check if we have the SourceContainerType
else if(_fields[i]._name == "SourceContainerType" && (_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_SourceContainerType = true;
}
// We check if we have the DestContainerType
else if(_fields[i]._name == "DestContainerType" && (_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_DestContainerType = true;
}
// We return true if we have the compulsory fields and we don't care of others
if(has_name_or_alias && has_ContainerType && has_SourceContainerType && has_DestContainerType){
return true;
}
}
}
// Name - string or integer, EntityType - string or integer, Alias - string or integer
else if(_event_name == "PajeDefineEntityValue"){
bool has_name_or_alias = false;
bool has_EntityType = false;
for(int i = 0 ; i < number_of_fields ; i ++){
// We check if we have the name or the alias
if((_fields[i]._name == "Name" || _fields[i]._name == "Alias") && (_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_name_or_alias = true;
}
// We check if we have the time
else if(_fields[i]._name == "EntityType" && (_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_EntityType = true;
}
// We return true if we have the compulsory fields and we don't care of others
if(has_name_or_alias && has_EntityType){
return true;
}
}
}
// Time - date, Type - string or integer, Container - string or integer, Value - string or integer
else if(_event_name == "PajeSetState" || _event_name == "PajePushState" ||
_event_name == "PajeNewEvent"){
bool has_Container = false;
bool has_time = false;
bool has_Value = false;
bool has_type = false;
for(int i = 0 ; i < number_of_fields ; i ++){
// We check if we have the name or the alias
if(_fields[i]._name == "Container" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_Container = true;
}
// We check if we have the time
else if(_fields[i]._name == "Time" && _fields[i]._type == "date"){
has_time = true;
}
// We check if we have the type
else if(_fields[i]._name == "Type" && (_fields[i]._type == "string" || _fields[i]._type == "integer")){
has_type = true;
}
// We check if we have the value
else if(_fields[i]._name == "Value" && (_fields[i]._type == "string" || _fields[i]._type == "integer")){
has_Value = true;
} // We return true if we have the compulsory fields and we don't care of others
if(has_Container && has_time && has_type && has_Value){
return true;
}
}
}
// Time - date, Type - string or integer, Container - string or integer
else if(_event_name == "PajePopState"){
bool has_Container = false;
bool has_time = false;
bool has_type = false;
for(int i = 0 ; i < number_of_fields ; i ++){
// We check if we have the time
if(_fields[i]._name == "Time" && _fields[i]._type == "date"){
has_time = true;
}
// We check if we have the type
else if(_fields[i]._name == "Type" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_type = true;
}
// We check if we have the value
else if(_fields[i]._name == "Container" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_Container = true;
} // We return true if we have the compulsory fields and we don't care of others
if(has_Container && has_time && has_type){
return true;
}
}
}
// Time - date, Type - string or integer, Container - string or integer, Value - double
else if(_event_name == "PajeSetVariable" || _event_name == "PajeAddVariable" ||
_event_name == "PajeSubVariable"){
bool has_Container = false;
bool has_time = false;
bool has_Value = false;
bool has_type = false;
for(int i = 0 ; i < number_of_fields ; i ++){
// We check if we have the name or the alias
if(_fields[i]._name == "Container" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_Container = true;
}
// We check if we have the time
else if(_fields[i]._name == "Time" && _fields[i]._type == "date"){
has_time = true;
}
// We check if we have the type
else if(_fields[i]._name == "Type" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_type = true;
}
// We check if we have the value
else if(_fields[i]._name == "Value" && _fields[i]._type == "double"){
has_Value = true;
} // We return true if we have the compulsory fields and we don't care of others
if(has_Container && has_time && has_type && has_Value){
return true;
}
}
}
// Container - string or integer, Time - date, Type - string or integer
// SourceContainer - string or integer, Value - string or integer, Key - string or integer
else if(_event_name == "PajeStartLink"){
bool has_Container = false;
bool has_time = false;
bool has_type = false;
bool has_Value = false;
bool has_key = false;
bool has_SourceContainer = false;
for(int i = 0 ; i < number_of_fields ; i ++){
// We check if we have the name or the alias
if(_fields[i]._name == "Container" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_Container = true;
}
// We check if we have the time
else if(_fields[i]._name == "Time" && _fields[i]._type == "date"){
has_time = true;
}
// We check if we have the type
else if(_fields[i]._name == "Type" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_type = true;
}
// We check if we have the key
else if(_fields[i]._name == "Key" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_key = true;
}
// We check if we have the SourceContainer
else if(_fields[i]._name == "SourceContainer" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_SourceContainer = true;
}
// We check if we have the value
else if(_fields[i]._name == "Value" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_Value = true;
} // We return true if we have the compulsory fields and we don't care of others
if(has_Container && has_time && has_type && has_Value && has_key && has_SourceContainer){
return true;
}
}
}
// Container - string or integer, Time - date, Type - string or integer
// DestContainer - string or integer, Value - string or integer, Key - string or integer
else if(_event_name == "PajeEndLink"){
bool has_Container = false;
bool has_time = false;
bool has_type = false;
bool has_Value = false;
bool has_key = false;
bool has_DestContainer = false;
for(int i = 0 ; i < number_of_fields ; i ++){
// We check if we have the name or the alias
if(_fields[i]._name == "Container" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_Container = true;
}
// We check if we have the time
else if(_fields[i]._name == "Time" && _fields[i]._type == "date"){
has_time = true;
}
// We check if we have the type
else if(_fields[i]._name == "Type" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_type = true;
}
// We check if we have the key
else if(_fields[i]._name == "Key" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_key = true;
}
// We check if we have the SourceContainer
else if(_fields[i]._name == "DestContainer" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_DestContainer = true;
}
// We check if we have the value
else if(_fields[i]._name == "Value" &&
(_fields[i]._type == "string" || _fields[i]._type == "integer" || _fields[i]._type == "int")){
has_Value = true;
} // We return true if we have the compulsory fields and we don't care of others
if(has_Container && has_time && has_type && has_Value && has_key && has_DestContainer){
return true;
}
}
}
else{
cerr << "Unknown type" << endl;
return false;
}
return false;
}
#ifndef DEFINITION_HPP
#define DEFINITION_HPP
#include <vector>
#include <iostream>
/*! \class Definition Definition.hpp "../parser/src/Definition.hpp"
* Contains the definition of a definition.
*/
#include <vector>
#include <iostream>
#include <string>
......@@ -53,7 +52,7 @@ public:
* \param name : the name of the event
* \param value : the type of the event
*/
void store(std::string name,std::string value);
void store(std::string name, std::string value);
......@@ -76,6 +75,12 @@ public:
*
*/
std::string get_event_name() const;
/*! \fn check_definition
* \brief Check if the definition stored is correct.
* \return true if the definition is correct.
*/
bool check_definition() const;
};
#endif // DEFINITION_HPP
......
......@@ -23,59 +23,50 @@ int ParserDefinitionDecoder::definitions_number(){
void ParserDefinitionDecoder::enter_definition(Line &line){
DIE_IF(_state == IN_A_DEFINITION,"expected %EndDef");
DIE_IF(_state == IN_A_DEFINITION, "expected %EndEventDef");
string definition_name;
DIE_IF(!line.item(2,definition_name),"a definition has no name");
DIE_IF(!line.item(2, definition_name), "a definition has no name");
int definition_identity;
string definition_identity_string;
DIE_IF(!line.item(3,definition_identity_string),"definition has no identifier");
DIE_IF(sscanf(definition_identity_string.c_str(),"%d",&definition_identity)!=1,"expected identifier for a definition");
DIE_IF(!line.item(3, definition_identity_string), "definition has no identifier");
DIE_IF(sscanf(definition_identity_string.c_str(), "%d", &definition_identity) != 1, "expected identifier for a definition");
Definition current_definition = Definition(definition_name);
_definitions.insert(pair<int,Definition>(definition_identity, current_definition));
_current_definition = definition_identity;
WARN_IF((line.length()>4),"warning extra token in %EvenDef");
WARN_IF((line.length() > 4), "warning extra token in %EventDef");
_state = IN_A_DEFINITION;
return;
}
void ParserDefinitionDecoder::leave_definition(Line&line){
DIE_IF(_state != IN_A_DEFINITION,"expected %EventDef");
_state = OUT_A_DEFINITION;
WARN_IF((line.length()>2),"warning extra token in %EvenDef");
DIE_IF(_state != IN_A_DEFINITION, "expected %EventDef");
_state = OUT_A_DEFINITION;
WARN_IF((line.length() > 2), "warning extra token in %EventDef");
}
void ParserDefinitionDecoder::add_field_to_definition(std::string& first_token,Line& line){
DIE_IF(_state == OUT_A_DEFINITION,"expected %EventDef2");
DIE_IF(_state == OUT_A_DEFINITION, "expected %EventDef2");
string field_value;
DIE_IF(!line.item(2,field_value),"A field type is missing.");
_definitions[_current_definition].store(first_token,field_value);
DIE_IF(!line.item(2, field_value), "A field type is missing.");
_definitions[_current_definition].store(first_token, field_value);
}
void ParserDefinitionDecoder::store_definition(Line &line){
string first_token;
DIE_IF(!line.item(1,first_token),"error : a definition line is empty");
DIE_IF(!line.item(1,first_token), "error : a definition line is empty");
if (first_token == "EventDef"){
enter_definition(line);
}
......
......@@ -5,13 +5,13 @@
#include <map>
#include "Definition.hpp"
#include "Line.hpp"
#include "../../values/color.hpp"
#include "../../values/date.hpp"
#include "../../values/double.hpp"
#include "../../values/hex.hpp"
#include "../../values/integer.hpp"
#include "../../values/name.hpp"
#include "../../values/string.hpp"
#include "../../trace/src/values/Color.hpp"
#include "../../trace/src/values/Date.hpp"
#include "../../trace/src/values/Double.hpp"
#include "../../trace/src/values/Hex.hpp"
#include "../../trace/src/values/Integer.hpp"
#include "../../trace/src/values/Name.hpp"
#include "../../trace/src/values/String.hpp"
#include "../../trace/src/Trace.hpp"
/**
......
......@@ -27,5 +27,5 @@ void ParserPaje::parse(string filename, Trace &trace){
}
}
delete parser_event_decoder;
}
#ifndef CONTAINER_HPP
#define CONTAINER_HPP
/*!
*
* \file container.hpp
* \author Clément Vuchener
* \brief Contains the definition of the class Container
* \date 2009 January 30th
*
*/
#ifndef CONTAINER_HPP
#define CONTAINER_HPP
/*!
*
* \file container.hpp
* \author Clément Vuchener
* \brief Contains the definition of the class Container
* \date 2009 January 30th
*
*/
#include <list>
using std::list;
#include "values/Name.hpp"
#include "values/Date.hpp"
#include "ContainerType.hpp"
#include "values/Name.hpp"
#include "values/Date.hpp"
#include "ContainerType.hpp"
class Container;
#include "State.hpp"
#include "EntityList.hpp"
/*!
*
* \class Container
* \brief contains others containers or entities
*
*/
#include "State.hpp"
#include "EntityList.hpp"
/*!
*
* \class Container
* \brief contains others containers or entities
*
*/
class Container {
friend class State;
private:
......@@ -39,77 +39,77 @@ private:
Container *_parent;
list<Container *> _children;
EntityList _states;
public:
Container(Name &name, Date &creation_time, ContainerType *type, Container *parent);
public:
Container(Name &name, Date &creation_time, ContainerType *type, Container *parent);
~Container();
/*!
*
* \fn get_name
* \brief Returns the name and the alias of the container
*
*/
const Name &get_name() const;
/*!
*
* \fn get_parent
* \brief Returns the parent container
*
*/
const Container *get_parent() const;
/*!
*
* \fn get_type
* \brief Returns the type of the container
*
*/
const ContainerType *get_type() const;
/*!
*
* \fn get_children
* \brief Returns the list of the child containers
*
*/
const list<Container *> &get_children() const;
/*!
*
* \fn get_creation_time
* \brief Returns the time when the container was created
*
*/
const Date &get_creation_time() const;
/*!
*
* \fn get_destruction_time
* \brief Returns the time when the container was destroyed
*
*/
const Date &get_destruction_time() const;
/*!
*
* \fn get_states
* \brief Returns the list of the states between min and max
* \param min Time of the beginning of the list
* \param max Time of the end of the list
*
*/
const EntityList &get_states(Date &min, Date &max) const;
/*!
*
* \fn destroy
* \brief Sets the destruction time of the container
* \param date destruction time
*
*/
void destroy(Date &time);
};
#endif
/*!