Commit 500d1fe5 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Take into accounbt PajeResetState, and fix indentation/whitespace cleanup on the fly

parent 55e668ed
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
#include <vector>
#include <iostream>
......@@ -55,70 +55,70 @@ using namespace std;
namespace PajeDef {
void print(std::vector<PajeFieldName>* fields, PajeDefinition *def) {
unsigned int i;
size_t size = def->_fields.size();
void print(std::vector<PajeFieldName>* fields, PajeDefinition *def) {
unsigned int i;
size_t size = def->_fields.size();
cout << def->_trid << " : " << def->_name << endl;
cout << def->_trid << " : " << def->_name << endl;
for(i=0 ; i < size ; i ++){
for(i=0 ; i < size ; i ++){
PajeFieldName p;
try{
p = (*fields).at( def->_fields[i]._idname);
cout << " " << p._name;
}catch(out_of_range& e){
cout << " " << "name not found";
try{
p = (*fields).at( def->_fields[i]._idname);
cout << " " << p._name;
}catch(out_of_range& e){
cout << " " << "name not found";
}
string s;
//as this won't change in the future, we can use a switch
string s;
//as this won't change in the future, we can use a switch
switch(def->_fields[i]._idtype){
case(1<<0) :
s="int";
break;
case(1<<1) :
s="hex";
break;
case(1<<2) :
s="date";
break;
case(1<<3) :
s="double";
break;
case(1<<4) :
s="string";
break;
case(1<<5) :
s="color";
break;
case(1<<0) :
s="int";
break;
case(1<<1) :
s="hex";
break;
case(1<<2) :
s="date";
break;
case(1<<3) :
s="double";
break;
case(1<<4) :
s="string";
break;
case(1<<5) :
s="color";
break;
default:
s="error : wrong type";
break;
}
}
cout << " " << s << endl;
}
}
}
string print_string(std::vector<PajeFieldName>* fields, PajeDefinition *def) {
unsigned int i;
size_t size = def->_fields.size();
//string out;
stringstream outstream;
outstream << def->_name;
outstream << "\n";
for(i=0 ; i < size ; i ++){
string print_string(std::vector<PajeFieldName>* fields, PajeDefinition *def) {
unsigned int i;
size_t size = def->_fields.size();
//string out;
stringstream outstream;
outstream << def->_name;
outstream << "\n";
for(i=0 ; i < size ; i ++){
//try to find the name of the field we want to print
//try to find the name of the field we want to print
PajeFieldName p;
try{
p = (*fields).at( def->_fields[i]._idname);
outstream << " " << p._name;
}catch(out_of_range& e){
outstream << " " << "name not found";
}
string s;
//as this won't change in the future, we can use a switch
switch(def->_fields[i]._idtype){
PajeFieldName p;
try{
p = (*fields).at( def->_fields[i]._idname);
outstream << " " << p._name;
}catch(out_of_range& e){
outstream << " " << "name not found";
}
string s;
//as this won't change in the future, we can use a switch
switch(def->_fields[i]._idtype){
case(1<<0) :
s="int";
break;
......@@ -137,33 +137,33 @@ string print_string(std::vector<PajeFieldName>* fields, PajeDefinition *def) {
case(1<<5) :
s="color";
break;
default:
s="error : wrong type";
break;
}
outstream << " " << s;
outstream << "\n";
default:
s="error : wrong type";
break;
}
outstream << " " << s;
outstream << "\n";
}
return outstream.str();
}
return outstream.str();
}
bool check_definition(PajeDefinition *def) {
int fdpresent = def->_fdpresent;
bool check_definition(PajeDefinition *def) {
int fdpresent = def->_fdpresent;
// If the definition requires Alias or Name,
// and the trace provide only one the both, it's ok
if ( ((def->_fdrequired & CODE(_PajeFN_Alias)) ||
(def->_fdrequired & CODE(_PajeFN_Name ))) &&
((def->_fdpresent & CODE(_PajeFN_Alias)) ||
(def->_fdpresent & CODE(_PajeFN_Name ))) ) {
fdpresent = fdpresent | CODE(_PajeFN_Alias);
fdpresent = fdpresent | CODE(_PajeFN_Name );
}
// If the definition requires Alias or Name,
// and the trace provide only one the both, it's ok
if ( ((def->_fdrequired & CODE(_PajeFN_Alias)) ||
(def->_fdrequired & CODE(_PajeFN_Name ))) &&
((def->_fdpresent & CODE(_PajeFN_Alias)) ||
(def->_fdpresent & CODE(_PajeFN_Name ))) ) {
fdpresent = fdpresent | CODE(_PajeFN_Alias);
fdpresent = fdpresent | CODE(_PajeFN_Name );
if ( (fdpresent & def->_fdrequired) == def->_fdrequired )
return true;
else
return false;
}
if ( (fdpresent & def->_fdrequired) == def->_fdrequired )
return true;
else
return false;
}
}
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
/*!
* \file PajeDefinition.hpp
......@@ -54,24 +54,27 @@
* This names are the names allowed to defined the events in Paje
* format. This list can't be extended in the trace.
*/
#define PAJE_EVENTDEF_SIZE 17
#define _PajeDefineContainerType 0
#define _PajeDefineEventType 1
#define _PajeDefineStateType 2
#define _PajeDefineVariableType 3
#define _PajeDefineLinkType 4
#define _PajeDefineEntityValue 5
#define _PajeCreateContainer 6
#define _PajeDestroyContainer 7
#define _PajeNewEvent 8
#define _PajeSetState 9
#define _PajePushState 10
#define _PajePopState 11
#define _PajeSetVariable 12
#define _PajeAddVariable 13
#define _PajeSubVariable 14
#define _PajeStartLink 15
#define _PajeEndLink 16
typedef enum paje_eventdef_e {
_PajeDefineContainerType,
_PajeDefineEventType,
_PajeDefineStateType,
_PajeDefineVariableType,
_PajeDefineLinkType,
_PajeDefineEntityValue,
_PajeCreateContainer,
_PajeDestroyContainer,
_PajeNewEvent,
_PajeSetState,
_PajePushState,
_PajePopState,
_PajeResetState,
_PajeSetVariable,
_PajeAddVariable,
_PajeSubVariable,
_PajeStartLink,
_PajeEndLink,
PAJE_EVENTDEF_SIZE
} paje_eventdef_t;
/*!
* \brief Names of the fields describing events
......@@ -83,17 +86,17 @@
*/
#define FIELDNAME_SIZEMAX 32
#define FIELDNAME_SIZE 14
#define _PajeFN_Time 0
#define _PajeFN_Time 0
#define _PajeFN_Name 1
#define _PajeFN_Alias 2
#define _PajeFN_Type 3
#define _PajeFN_Container 4
#define _PajeFN_Type 3
#define _PajeFN_Container 4
#define _PajeFN_StartContainerType 5
#define _PajeFN_EndContainerType 6
#define _PajeFN_StartContainer 7
#define _PajeFN_EndContainer 8
#define _PajeFN_Color 9
#define _PajeFN_Value 10
#define _PajeFN_Color 9
#define _PajeFN_Value 10
#define _PajeFN_Key 11
#define _PajeFN_File 12
#define _PajeFN_Line 13
......@@ -102,8 +105,8 @@
* Former type that are no longer used in Paje Format.
* Kept here for compatibility
*/
#define _PajeFN_ContainerType 3
#define _PajeFN_EntityType 3
#define _PajeFN_ContainerType 3
#define _PajeFN_EntityType 3
#define _PajeFN_SourceContainerType 5
#define _PajeFN_DestContainerType 6
#define _PajeFN_SourceContainer 7
......@@ -115,8 +118,8 @@
* fields of each event. This list can't be extended.
*/
#define FIELDTYPE_SIZE 6
#define _FieldType_Int 1<<0
#define _FieldType_Hex 1<<1
#define _FieldType_Int 1<<0
#define _FieldType_Hex 1<<1
#define _FieldType_Date 1<<2
#define _FieldType_Double 1<<3
#define _FieldType_String 1<<4
......@@ -126,31 +129,30 @@
#define CODE2(name) ( 1 << _PajeFN_##name )
struct Field {
int _idname;
int _idtype;
int _idname;
int _idtype;
};
struct PajeFieldName {
const char *_name;
int _id;
int _code;
int _allowed;
const char *_name;
int _id;
int _code;
int _allowed;
};
struct PajeDefinition {
const char *_name;
int _id;
int _trid;
int _fdpresent;
int _fdrequired;
std::vector< Field > _fields;
const char *_name;
int _id;
int _trid;
int _fdpresent;
int _fdrequired;
std::vector< Field > _fields;
};
namespace PajeDef {
void print (std::vector<PajeFieldName>* fields, PajeDefinition *def);
std::string print_string (std::vector<PajeFieldName>* fields, PajeDefinition *def);
bool check_definition(PajeDefinition *def);
void print (std::vector<PajeFieldName>* fields, PajeDefinition *def);
std::string print_string (std::vector<PajeFieldName>* fields, PajeDefinition *def);
bool check_definition(PajeDefinition *def);
};
#endif // DEFINITION_HPP
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
#include <string>
#include <cstring>
......@@ -66,23 +66,23 @@ using namespace std;
#define _IN_A_DEFINITION 1
#define INSERT_FNAME(name, allowed) \
{ \
_FieldNames[_PajeFN_##name]._name = #name; \
_FieldNames[_PajeFN_##name]._id = _PajeFN_##name; \
_FieldNames[_PajeFN_##name]._code = CODE(_PajeFN_##name); \
_FieldNames[_PajeFN_##name]._allowed = allowed; \
i++; \
}
{ \
_FieldNames[_PajeFN_##name]._name = #name; \
_FieldNames[_PajeFN_##name]._id = _PajeFN_##name; \
_FieldNames[_PajeFN_##name]._code = CODE(_PajeFN_##name); \
_FieldNames[_PajeFN_##name]._allowed = allowed; \
i++; \
}
#define INSERT_EVENT(name, required) \
{ \
_EventDefs[_##name]._name = #name; \
_EventDefs[_##name]._id = _##name; \
_EventDefs[_##name]._trid = -1; \
_EventDefs[_##name]._fdpresent = 0; \
_EventDefs[_##name]._fdrequired = required; \
i++; \
}
{ \
_EventDefs[_##name]._name = #name; \
_EventDefs[_##name]._id = _##name; \
_EventDefs[_##name]._trid = -1; \
_EventDefs[_##name]._fdpresent = 0; \
_EventDefs[_##name]._fdrequired = required; \
i++; \
}
std::map<std::string, int> ParserDefinitionPaje::_EvDefStr2Id;
......@@ -113,6 +113,7 @@ ParserDefinitionPaje::ParserDefinitionPaje() {
_EvDefStr2Id.insert(pair<string, int>("PajeSetState" , _PajeSetState ));