diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6946bc255295a5e4034fa799a9d438c57b31eb0b..bf21fa0b5b0e3700be47dabf123bb4e8463e1df6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -111,7 +111,7 @@ SET(VITE_HDRS parser/ParsingThread.hpp parser/Parser.hpp parser/ParserFactory.hpp - # Paje + # Paje parser/PajeParser/PajeDefinition.hpp parser/PajeParser/PajeFileManager.hpp parser/PajeParser/ParserDefinitionPaje.hpp @@ -150,7 +150,7 @@ SET(VITE_UIS ) SET(VITE_SRCS - # Messages & Errors + # Messages & Errors common/Message.cpp common/Errors.cpp common/Tools.cpp @@ -268,7 +268,7 @@ IF(VITE_ENABLE_VBO) ${VITE_SRCS} render/vbo.cpp render/Render_alternate.cpp - ) + ) ENDIF(VITE_ENABLE_VBO) ############################################# @@ -325,7 +325,7 @@ ENDIF(VITE_ENABLE_TAU) #ADD_DEFINITIONS(-DMEMORY_USAGE) #ADD_DEFINITIONS(-DMEMORY_TRACE) - + ############################################# # BOOST ############################################# @@ -333,23 +333,23 @@ IF(VITE_ENABLE_SERIALIZATION) link_directories ( ${Boost_LIBRARY_DIRS} ) include_directories ( ${Boost_INCLUDE_DIRS} ) add_definitions("-DUSE_ITC -DBOOST_SERIALIZE") - + SET(VITE_HDRS ${VITE_HDRS} - parser/ParserSplitted.hpp - trace/IntervalOfContainer.hpp - trace/SerializerWriter.hpp + parser/ParserSplitted.hpp + trace/IntervalOfContainer.hpp + trace/SerializerWriter.hpp trace/SerializerDispatcher.hpp ) - + SET(VITE_SRCS ${VITE_SRCS} - parser/ParserSplitted.cpp - trace/IntervalOfContainer.cpp - trace/SerializerWriter.cpp + parser/ParserSplitted.cpp + trace/IntervalOfContainer.cpp + trace/SerializerWriter.cpp trace/SerializerDispatcher.cpp - ) - + ) + ENDIF(VITE_ENABLE_SERIALIZATION) @@ -386,7 +386,7 @@ if( APPLE ) SET( OSX_ICON_FILES "interface/icon/mac_logo.icns") set_source_files_properties(${OSX_ICON_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) ADD_EXECUTABLE(vite MACOSX_BUNDLE ${VITE_SRCS} ${VITE_MOC} ${VITE_RCC_SRCS} ${OSX_ICON_FILES}) - SET_TARGET_PROPERTIES(vite PROPERTIES + SET_TARGET_PROPERTIES(vite PROPERTIES MACOSX_BUNDLE_INFO_STRING "ViTE" MACOSX_BUNDLE_ICON_FILE "mac_logo.icns" MACOSX_BUNDLE_LONG_VERSION_STRING "Visual Trace Explorer - version ${VITE_VERSION_MAJOR}.${VITE_VERSION_MINOR}" @@ -394,7 +394,7 @@ if( APPLE ) MACOSX_BUNDLE_SHORT_VERSION_STRING "ViTE-${VITE_VERSION_MAJOR}.${VITE_VERSION_MINOR}" MACOSX_BUNDLE_BUNDLE_VERSION "1.0" MACOSX_BUNDLE_COPYRIGHT "INRIA 2006-2012" - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/vite-info.plist.in) + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/vite-info.plist.in) else( APPLE ) ADD_EXECUTABLE(vite ${VITE_SRCS} ${VITE_MOC} ${VITE_RCC_SRCS}) endif( APPLE ) @@ -410,7 +410,7 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") rt ) ADD_DEFINITIONS("-DBOOST_GZIP") -ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") +ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") IF(VITE_ENABLE_VBO) TARGET_LINK_LIBRARIES(vite diff --git a/src/parser/PajeParser/PajeDefinition.cpp b/src/parser/PajeParser/PajeDefinition.cpp index 498d7d9d6a9908e9c40c30973fba4d98b01eaa0f..3c565b8ddcd37093d767fb24241ba35f32353e0e 100644 --- a/src/parser/PajeParser/PajeDefinition.cpp +++ b/src/parser/PajeParser/PajeDefinition.cpp @@ -60,41 +60,41 @@ void print(std::vector<PajeFieldName>* fields, PajeDefinition *def) { size_t size = def->_fields.size(); cout << def->_trid << " : " << def->_name << endl; - + for(i=0 ; i < size ; i ++){ - PajeFieldName p; + PajeFieldName p; try{ p = (*fields).at( def->_fields[i]._idname); cout << " " << p._name; }catch(out_of_range& e){ cout << " " << "name not found"; } - string s; + 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; + 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; default: s="error : wrong type"; break; } - cout << " " << s << endl; + cout << " " << s << endl; } } @@ -106,7 +106,7 @@ string print_string(std::vector<PajeFieldName>* fields, PajeDefinition *def) { outstream << def->_name; outstream << "\n"; for(i=0 ; i < size ; i ++){ - + //try to find the name of the field we want to print PajeFieldName p; @@ -116,33 +116,33 @@ string print_string(std::vector<PajeFieldName>* fields, PajeDefinition *def) { }catch(out_of_range& e){ outstream << " " << "name not found"; } - string s; + 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; + 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; default: s="error : wrong type"; break; } - outstream << " " << s; - outstream << "\n"; + outstream << " " << s; + outstream << "\n"; } return outstream.str(); @@ -150,19 +150,19 @@ string print_string(std::vector<PajeFieldName>* fields, PajeDefinition *def) { 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 ); + (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; + return true; else return false; } diff --git a/src/parser/PajeParser/PajeDefinition.hpp b/src/parser/PajeParser/PajeDefinition.hpp index 66594452d2eb55e5df100bf23737b1ec850428df..5dd53a712d58e8b724d77008e71f35fec96cffcc 100644 --- a/src/parser/PajeParser/PajeDefinition.hpp +++ b/src/parser/PajeParser/PajeDefinition.hpp @@ -82,23 +82,32 @@ * the need of the user. */ #define FIELDNAME_SIZEMAX 32 -#define FIELDNAME_SIZE 16 +#define FIELDNAME_SIZE 14 #define _PajeFN_Time 0 #define _PajeFN_Name 1 #define _PajeFN_Alias 2 +#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_Key 11 +#define _PajeFN_File 12 +#define _PajeFN_Line 13 + +/* + * Former type that are no longer used in Paje Format. + * Kept here for compatibility + */ #define _PajeFN_ContainerType 3 -#define _PajeFN_EntityType 4 -#define _PajeFN_Type 5 -#define _PajeFN_Container 6 -#define _PajeFN_SourceContainerType 7 -#define _PajeFN_DestContainerType 8 -#define _PajeFN_SourceContainer 9 -#define _PajeFN_DestContainer 10 -#define _PajeFN_Color 11 -#define _PajeFN_Value 12 -#define _PajeFN_Key 13 -#define _PajeFN_File 14 -#define _PajeFN_Line 15 +#define _PajeFN_EntityType 3 +#define _PajeFN_SourceContainerType 5 +#define _PajeFN_DestContainerType 6 +#define _PajeFN_SourceContainer 7 +#define _PajeFN_DestContainer 8 /*! * \brief Types for the fields diff --git a/src/parser/PajeParser/ParserDefinitionPaje.cpp b/src/parser/PajeParser/ParserDefinitionPaje.cpp index 2c58d571a0b29db2ced373e473632cc063314559..82bdeeaa4343f43e5615acc4ab2ec43d3b98113b 100644 --- a/src/parser/PajeParser/ParserDefinitionPaje.cpp +++ b/src/parser/PajeParser/ParserDefinitionPaje.cpp @@ -6,13 +6,13 @@ ** 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, @@ -23,7 +23,7 @@ ** 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. ** @@ -37,7 +37,7 @@ ** - MARCOUEILLE Jule ** - NOISETTE Pascal ** - REDONDY Arthur -** - VUCHENER Clément +** - VUCHENER Clément ** */ @@ -83,7 +83,7 @@ using namespace std; _EventDefs[_##name]._fdrequired = required; \ i++; \ } - + std::map<std::string, int> ParserDefinitionPaje::_EvDefStr2Id; std::map<std::string, int> ParserDefinitionPaje::_FTypeStr2Code; @@ -98,34 +98,34 @@ ParserDefinitionPaje::ParserDefinitionPaje() { _nbparsers++; if ( !_initialized ) { - _initialized = true; - - // Initialize the list of EventDef's names - _EvDefStr2Id.insert(pair<string, int>("PajeDefineContainerType", _PajeDefineContainerType )); - _EvDefStr2Id.insert(pair<string, int>("PajeDefineEventType" , _PajeDefineEventType )); - _EvDefStr2Id.insert(pair<string, int>("PajeDefineStateType" , _PajeDefineStateType )); - _EvDefStr2Id.insert(pair<string, int>("PajeDefineVariableType" , _PajeDefineVariableType )); - _EvDefStr2Id.insert(pair<string, int>("PajeDefineLinkType" , _PajeDefineLinkType )); - _EvDefStr2Id.insert(pair<string, int>("PajeDefineEntityValue" , _PajeDefineEntityValue )); - _EvDefStr2Id.insert(pair<string, int>("PajeCreateContainer" , _PajeCreateContainer )); - _EvDefStr2Id.insert(pair<string, int>("PajeDestroyContainer" , _PajeDestroyContainer )); - _EvDefStr2Id.insert(pair<string, int>("PajeNewEvent" , _PajeNewEvent )); - _EvDefStr2Id.insert(pair<string, int>("PajeSetState" , _PajeSetState )); - _EvDefStr2Id.insert(pair<string, int>("PajePushState" , _PajePushState )); - _EvDefStr2Id.insert(pair<string, int>("PajePopState" , _PajePopState )); - _EvDefStr2Id.insert(pair<string, int>("PajeSetVariable" , _PajeSetVariable )); - _EvDefStr2Id.insert(pair<string, int>("PajeAddVariable" , _PajeAddVariable )); - _EvDefStr2Id.insert(pair<string, int>("PajeSubVariable" , _PajeSubVariable )); - _EvDefStr2Id.insert(pair<string, int>("PajeStartLink" , _PajeStartLink )); - _EvDefStr2Id.insert(pair<string, int>("PajeEndLink" , _PajeEndLink )); - - // Initialize the list of types available for field in EventDef declaration - _FTypeStr2Code.insert(pair<string, int>("int" ,_FieldType_Int )); - _FTypeStr2Code.insert(pair<string, int>("hex" ,_FieldType_Hex )); - _FTypeStr2Code.insert(pair<string, int>("date" ,_FieldType_Date )); - _FTypeStr2Code.insert(pair<string, int>("double",_FieldType_Double )); - _FTypeStr2Code.insert(pair<string, int>("string",_FieldType_String )); - _FTypeStr2Code.insert(pair<string, int>("color" ,_FieldType_Color )); + _initialized = true; + + // Initialize the list of EventDef's names + _EvDefStr2Id.insert(pair<string, int>("PajeDefineContainerType", _PajeDefineContainerType )); + _EvDefStr2Id.insert(pair<string, int>("PajeDefineEventType" , _PajeDefineEventType )); + _EvDefStr2Id.insert(pair<string, int>("PajeDefineStateType" , _PajeDefineStateType )); + _EvDefStr2Id.insert(pair<string, int>("PajeDefineVariableType" , _PajeDefineVariableType )); + _EvDefStr2Id.insert(pair<string, int>("PajeDefineLinkType" , _PajeDefineLinkType )); + _EvDefStr2Id.insert(pair<string, int>("PajeDefineEntityValue" , _PajeDefineEntityValue )); + _EvDefStr2Id.insert(pair<string, int>("PajeCreateContainer" , _PajeCreateContainer )); + _EvDefStr2Id.insert(pair<string, int>("PajeDestroyContainer" , _PajeDestroyContainer )); + _EvDefStr2Id.insert(pair<string, int>("PajeNewEvent" , _PajeNewEvent )); + _EvDefStr2Id.insert(pair<string, int>("PajeSetState" , _PajeSetState )); + _EvDefStr2Id.insert(pair<string, int>("PajePushState" , _PajePushState )); + _EvDefStr2Id.insert(pair<string, int>("PajePopState" , _PajePopState )); + _EvDefStr2Id.insert(pair<string, int>("PajeSetVariable" , _PajeSetVariable )); + _EvDefStr2Id.insert(pair<string, int>("PajeAddVariable" , _PajeAddVariable )); + _EvDefStr2Id.insert(pair<string, int>("PajeSubVariable" , _PajeSubVariable )); + _EvDefStr2Id.insert(pair<string, int>("PajeStartLink" , _PajeStartLink )); + _EvDefStr2Id.insert(pair<string, int>("PajeEndLink" , _PajeEndLink )); + + // Initialize the list of types available for field in EventDef declaration + _FTypeStr2Code.insert(pair<string, int>("int" ,_FieldType_Int )); + _FTypeStr2Code.insert(pair<string, int>("hex" ,_FieldType_Hex )); + _FTypeStr2Code.insert(pair<string, int>("date" ,_FieldType_Date )); + _FTypeStr2Code.insert(pair<string, int>("double",_FieldType_Double )); + _FTypeStr2Code.insert(pair<string, int>("string",_FieldType_String )); + _FTypeStr2Code.insert(pair<string, int>("color" ,_FieldType_Color )); } @@ -135,14 +135,12 @@ ParserDefinitionPaje::ParserDefinitionPaje() { INSERT_FNAME(Time, _FieldType_Date ); INSERT_FNAME(Name, _FieldType_Int | _FieldType_String ); INSERT_FNAME(Alias, _FieldType_Int | _FieldType_String ); - INSERT_FNAME(ContainerType, _FieldType_Int | _FieldType_String ); - INSERT_FNAME(EntityType, _FieldType_Int | _FieldType_String ); INSERT_FNAME(Type, _FieldType_Int | _FieldType_String ); INSERT_FNAME(Container, _FieldType_Int | _FieldType_String ); - INSERT_FNAME(SourceContainerType, _FieldType_Int | _FieldType_String ); - INSERT_FNAME(DestContainerType, _FieldType_Int | _FieldType_String ); - INSERT_FNAME(SourceContainer, _FieldType_Int | _FieldType_String ); - INSERT_FNAME(DestContainer, _FieldType_Int | _FieldType_String ); + INSERT_FNAME(StartContainerType, _FieldType_Int | _FieldType_String ); + INSERT_FNAME(EndContainerType, _FieldType_Int | _FieldType_String ); + INSERT_FNAME(StartContainer, _FieldType_Int | _FieldType_String ); + INSERT_FNAME(EndContainer, _FieldType_Int | _FieldType_String ); INSERT_FNAME(Color, _FieldType_Color ); INSERT_FNAME(Value, _FieldType_Int | _FieldType_String | _FieldType_Double); INSERT_FNAME(Key, _FieldType_Int | _FieldType_String ); @@ -152,20 +150,28 @@ ParserDefinitionPaje::ParserDefinitionPaje() { // Initialize the map between the field names and the associated id _nbFieldNames = FIELDNAME_SIZE; for(i=0; i<FIELDNAME_SIZE; i++) { - _FNameStr2Id.insert(pair<string, int>(_FieldNames[i]._name, i)); + _FNameStr2Id.insert(pair<string, int>(_FieldNames[i]._name, i)); } - + + // Former types no longer used in Paje format + _FNameStr2Id.insert(pair<string, int>("ContainerType" , _PajeFN_ContainerType )); + _FNameStr2Id.insert(pair<string, int>("EntityType" , _PajeFN_EntityType )); + _FNameStr2Id.insert(pair<string, int>("SourceContainerType", _PajeFN_SourceContainerType )); + _FNameStr2Id.insert(pair<string, int>("DestContainerType" , _PajeFN_DestContainerType )); + _FNameStr2Id.insert(pair<string, int>("SourceContainer" , _PajeFN_SourceContainer )); + _FNameStr2Id.insert(pair<string, int>("DestContainer" , _PajeFN_DestContainer )); + // Initialize the list of Events available i = 0; _EventDefs.resize(PAJE_EVENTDEF_SIZE); - INSERT_EVENT(PajeDefineContainerType, CODE2(Name) | CODE2(Alias) | CODE2(ContainerType) ); - INSERT_EVENT(PajeDefineEventType , CODE2(Name) | CODE2(Alias) | CODE2(ContainerType) ); - INSERT_EVENT(PajeDefineStateType , CODE2(Name) | CODE2(Alias) | CODE2(ContainerType) ); - INSERT_EVENT(PajeDefineVariableType , CODE2(Name) | CODE2(Alias) | CODE2(ContainerType) ); - INSERT_EVENT(PajeDefineEntityValue , CODE2(Name) | CODE2(Alias) | CODE2(EntityType) ); + INSERT_EVENT(PajeDefineContainerType, CODE2(Name) | CODE2(Alias) | CODE2(Type) ); + INSERT_EVENT(PajeDefineEventType , CODE2(Name) | CODE2(Alias) | CODE2(Type) ); + INSERT_EVENT(PajeDefineStateType , CODE2(Name) | CODE2(Alias) | CODE2(Type) ); + INSERT_EVENT(PajeDefineVariableType , CODE2(Name) | CODE2(Alias) | CODE2(Type) ); + INSERT_EVENT(PajeDefineEntityValue , CODE2(Name) | CODE2(Alias) | CODE2(Type) ); INSERT_EVENT(PajeDestroyContainer , CODE2(Name) | CODE2(Alias) | CODE2(Time) | CODE2(Type) ); INSERT_EVENT(PajeCreateContainer , CODE2(Name) | CODE2(Alias) | CODE2(Time) | CODE2(Type) | CODE2(Container) ); - INSERT_EVENT(PajeDefineLinkType , CODE2(Name) | CODE2(Alias) | CODE2(ContainerType) | CODE2(SourceContainerType) | CODE2(DestContainerType) ); + INSERT_EVENT(PajeDefineLinkType , CODE2(Name) | CODE2(Alias) | CODE2(Type) | CODE2(StartContainerType) | CODE2(EndContainerType) ); INSERT_EVENT(PajePopState , CODE2(Time) | CODE2(Type) | CODE2(Container) ); INSERT_EVENT(PajeSetState , CODE2(Time) | CODE2(Type) | CODE2(Container) | CODE2(Value) ); INSERT_EVENT(PajePushState , CODE2(Time) | CODE2(Type) | CODE2(Container) | CODE2(Value) ); @@ -173,9 +179,8 @@ ParserDefinitionPaje::ParserDefinitionPaje() { INSERT_EVENT(PajeSetVariable , CODE2(Time) | CODE2(Type) | CODE2(Container) | CODE2(Value) ); INSERT_EVENT(PajeAddVariable , CODE2(Time) | CODE2(Type) | CODE2(Container) | CODE2(Value) ); INSERT_EVENT(PajeSubVariable , CODE2(Time) | CODE2(Type) | CODE2(Container) | CODE2(Value) ); - INSERT_EVENT(PajeStartLink , CODE2(Time) | CODE2(Type) | CODE2(Container) | CODE2(Value) | CODE2(Key) | CODE2(SourceContainer) ); - INSERT_EVENT(PajeEndLink , CODE2(Time) | CODE2(Type) | CODE2(Container) | CODE2(Value) | CODE2(Key) | CODE2(DestContainer) ); - + INSERT_EVENT(PajeStartLink , CODE2(Time) | CODE2(Type) | CODE2(Container) | CODE2(Value) | CODE2(Key) | CODE2(StartContainer) ); + INSERT_EVENT(PajeEndLink , CODE2(Time) | CODE2(Type) | CODE2(Container) | CODE2(Value) | CODE2(Key) | CODE2(EndContainer) ); } ParserDefinitionPaje::~ParserDefinitionPaje() { @@ -183,7 +188,7 @@ ParserDefinitionPaje::~ParserDefinitionPaje() { // Free the string to store extra names for( i=FIELDNAME_SIZE ; i<_nbFieldNames; i++) { - delete[] _FieldNames[i]._name; + delete[] _FieldNames[i]._name; } _FieldNames.clear(); _EventDefs.clear(); @@ -192,9 +197,9 @@ ParserDefinitionPaje::~ParserDefinitionPaje() { _nbparsers--; if ( (_nbparsers == 0) && _initialized ) { - _FTypeStr2Code.clear(); - _EvDefStr2Id.clear(); - _initialized = false; + _FTypeStr2Code.clear(); + _EvDefStr2Id.clear(); + _initialized = false; } } @@ -202,20 +207,20 @@ void ParserDefinitionPaje::enter_definition(const PajeLine_t *line){ int defid, trid; char *defname = line->_tokens[2]; char *tridstr = line->_tokens[3]; - + // The name is missing if(defname == NULL) { Error::set(Error::VITE_ERR_EXPECT_NAME_DEF, line->_id, Error::VITE_ERRCODE_ERROR); return; } - + // The id is missing if(tridstr == NULL) { Error::set(Error::VITE_ERR_EXPECT_ID_DEF, line->_id, Error::VITE_ERRCODE_ERROR); return; } - // If we are already trying to define an event, + // If we are already trying to define an event, // we close it before starting a new one if(_state == _IN_A_DEFINITION){ Error::set(Error::VITE_ERR_EXPECT_END_DEF, line->_id, Error::VITE_ERRCODE_WARNING); @@ -234,7 +239,7 @@ void ParserDefinitionPaje::enter_definition(const PajeLine_t *line){ return; } - defid = _EvDefStr2Id[defname]; + defid = _EvDefStr2Id[defname]; // Check if it is the first time we see this Event if ( _EventDefs[defid]._trid != -1 ) { @@ -252,12 +257,12 @@ void ParserDefinitionPaje::enter_definition(const PajeLine_t *line){ _defid = defid; _state = _IN_A_DEFINITION; _EvDefTrId2Id.insert(pair<int, int>(trid, defid)); - + return; } void ParserDefinitionPaje::leave_definition(const PajeLine_t *line){ - + // We can't end a definition if we are not in one !!! if(_state != _IN_A_DEFINITION){ Error::set(Error::VITE_ERR_EXPECT_EVENT_DEF, line->_id, Error::VITE_ERRCODE_WARNING); @@ -268,14 +273,14 @@ void ParserDefinitionPaje::leave_definition(const PajeLine_t *line){ // Check that the event has been correctly defined if( !(PajeDef::check_definition(&_EventDefs[_defid])) ) { - Error::set(Error::VITE_ERR_EVENT_NOT_CORRECT - + PajeDef::print_string(&_FieldNames, &_EventDefs[_defid]), - line->_id, Error::VITE_ERRCODE_ERROR); - - // We remove the definition - _EvDefTrId2Id.erase(_EventDefs[_defid]._trid); - _EventDefs[_defid]._fields.clear(); - _EventDefs[_defid]._trid = -1; + Error::set(Error::VITE_ERR_EVENT_NOT_CORRECT + + PajeDef::print_string(&_FieldNames, &_EventDefs[_defid]), + line->_id, Error::VITE_ERRCODE_ERROR); + + // We remove the definition + _EvDefTrId2Id.erase(_EventDefs[_defid]._trid); + _EventDefs[_defid]._fields.clear(); + _EventDefs[_defid]._trid = -1; return; } @@ -314,36 +319,36 @@ void ParserDefinitionPaje::add_field_to_definition(const PajeLine_t *line){ // Type unknown if ( idtype == 0 ) { - Error::set(Error::VITE_ERR_FIELD_TYPE_UNKNOWN + fieldtype, line->_id, Error::VITE_ERRCODE_ERROR); - return; + Error::set(Error::VITE_ERR_FIELD_TYPE_UNKNOWN + fieldtype, line->_id, Error::VITE_ERRCODE_ERROR); + return; } // Name unknown, we have to store it if ( _FNameStr2Id.find(fieldname) == _FNameStr2Id.end() ) { - int size = strlen(fieldname)+1; - char *newfn = new char[size]; + int size = strlen(fieldname)+1; + char *newfn = new char[size]; #ifndef WIN32 - strcpy(newfn, fieldname); + strcpy(newfn, fieldname); #else - strcpy_s(newfn, size, fieldname); + strcpy_s(newfn, size, fieldname); #endif - _FieldNames[_nbFieldNames]._name = newfn; - _FieldNames[_nbFieldNames]._id = _nbFieldNames; - _FieldNames[_nbFieldNames]._code = (1 << _nbFieldNames); - _FieldNames[_nbFieldNames]._allowed = idtype; - idname = _nbFieldNames; - _nbFieldNames++; + _FieldNames[_nbFieldNames]._name = newfn; + _FieldNames[_nbFieldNames]._id = _nbFieldNames; + _FieldNames[_nbFieldNames]._code = (1 << _nbFieldNames); + _FieldNames[_nbFieldNames]._allowed = idtype; + idname = _nbFieldNames; + _nbFieldNames++; } else { - idname =_FNameStr2Id[fieldname]; + idname =_FNameStr2Id[fieldname]; } // check if type is allowed if ( !( idtype & _FieldNames[idname]._allowed ) ) { - Error::set(Error::VITE_ERR_FIELD_NOT_ALLOWED + "(" + fieldname + "," + fieldtype + ")", line->_id, Error::VITE_ERRCODE_ERROR); - return; + Error::set(Error::VITE_ERR_FIELD_NOT_ALLOWED + "(" + fieldname + "," + fieldtype + ")", line->_id, Error::VITE_ERRCODE_ERROR); + return; } - + // Extra tokens are not supported if(line->_nbtks > 3){ Error::set(Error::VITE_ERR_EXTRA_TOKEN, line->_id, Error::VITE_ERRCODE_WARNING); @@ -359,10 +364,10 @@ void ParserDefinitionPaje::add_field_to_definition(const PajeLine_t *line){ void ParserDefinitionPaje::store_definition(const PajeLine_t *line){ string token = line->_tokens[1]; - + // We need almost two tokens '%' and "[End]EventDef" if(line->_nbtks < 2){ - Error::set(Error::VITE_ERR_EMPTY_DEF, line->_id, Error::VITE_ERRCODE_WARNING); + Error::set(Error::VITE_ERR_EMPTY_DEF, line->_id, Error::VITE_ERRCODE_WARNING); return; } @@ -375,20 +380,20 @@ void ParserDefinitionPaje::store_definition(const PajeLine_t *line){ leave_definition(line); if(line->_nbtks > 2){ Error::set(Error::VITE_ERR_EXTRA_TOKEN, line->_id, Error::VITE_ERRCODE_WARNING); - } + } } // Add a field to the definition else{ add_field_to_definition(line); } - + } PajeDefinition *ParserDefinitionPaje::getDefFromTrid(int trid) { if ( _EvDefTrId2Id.find(trid) == _EvDefTrId2Id.end() ) { - return NULL; + return NULL; } else { - return &(_EventDefs[_EvDefTrId2Id[trid]]); + return &(_EventDefs[_EvDefTrId2Id[trid]]); } } @@ -399,8 +404,8 @@ void ParserDefinitionPaje::print_definitions() { for (; it != it_end ; ++ it){ cout << "###### " << (*it).first << endl; - // (*it).second represents the current definition - PajeDef::print(&_FieldNames, &_EventDefs[(*it).second]); + // (*it).second represents the current definition + PajeDef::print(&_FieldNames, &_EventDefs[(*it).second]); } } @@ -411,5 +416,3 @@ int ParserDefinitionPaje::definitions_number() const { const vector<PajeFieldName> *ParserDefinitionPaje::get_FieldNames() const { return &_FieldNames; } - - diff --git a/src/parser/PajeParser/ParserDefinitionPaje.hpp b/src/parser/PajeParser/ParserDefinitionPaje.hpp index 39720d593eaf1ea4a938f1a22e8331083a9f3b8c..c92ec7dcb216978c469b83e5b80de325716a0e45 100644 --- a/src/parser/PajeParser/ParserDefinitionPaje.hpp +++ b/src/parser/PajeParser/ParserDefinitionPaje.hpp @@ -6,13 +6,13 @@ ** 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, @@ -23,7 +23,7 @@ ** 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. ** @@ -37,7 +37,7 @@ ** - MARCOUEILLE Jule ** - NOISETTE Pascal ** - REDONDY Arthur -** - VUCHENER Clément +** - VUCHENER Clément ** */ /*! @@ -50,21 +50,21 @@ struct PajeDefinition; struct PajeFieldName; -/*! +/*! * \class ParserDefinitionPaje * \brief Parse the header of the trace and store the information * about event description. * * \param _EvDefStr2Id - * It is a hashtable to find quickly a match for - * each word found in definition section. It actually also - * define the keyword which are allowed in the definition + * It is a hashtable to find quickly a match for + * each word found in definition section. It actually also + * define the keyword which are allowed in the definition * section of a trace. This list is static, we initialize it * only once for all traces. The second term of each term is * the id of the event in the vector _EventDefs. * * \param _EvDefTrId2Id - * It is a hashtable to find quickly a match for + * It is a hashtable to find quickly a match for * each trace id used in the file to match an event. * This hashtable is specific to each trace. * @@ -77,8 +77,8 @@ struct PajeFieldName; * digit. * * \param _FNameStr2Id - * It is an hashtable to find quickly a match for - * the keyword naming a definition's field. This hashtable + * It is an hashtable to find quickly a match for + * the keyword naming a definition's field. This hashtable * can be complete by some new field added in the trace * file. The second term of each pair is the id of the Name in * the vector _FieldNames. @@ -115,7 +115,7 @@ private: * \brief Put the parser in definition mode */ void enter_definition(const PajeLine_t *line); - + /*! * \fn leave_definition(const PajeLine_t *line) * \param line diff --git a/src/parser/PajeParser/ParserEventPaje.cpp b/src/parser/PajeParser/ParserEventPaje.cpp index 4387a7863b418a784bec5261189f5353d0a0d9ba..175a13a96785a418671b06266ef968d472e8f953 100644 --- a/src/parser/PajeParser/ParserEventPaje.cpp +++ b/src/parser/PajeParser/ParserEventPaje.cpp @@ -6,13 +6,13 @@ ** 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, @@ -23,7 +23,7 @@ ** 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. ** @@ -37,7 +37,7 @@ ** - MARCOUEILLE Jule ** - NOISETTE Pascal ** - REDONDY Arthur -** - VUCHENER Clément +** - VUCHENER Clément ** */ #include <string> @@ -74,24 +74,23 @@ ParserEventPaje::~ParserEventPaje(){ _containers.clear(); } -void ParserEventPaje::store_event(const PajeLine *line, - Trace &trace) { - - string fvalue; - string alias; - string name; - String container_type; - 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 key; +void ParserEventPaje::store_event(const PajeLine *line, + Trace &trace) { + string fvalue; + string alias; + string name; + String type; + String start_container_type; + String end_container_type; + Date time; + String container; + String value_string; + Double value_double; + String start_container; + String end_container; + String key; + Name alias_name; + map<std::string, Value *> extra_fields; @@ -101,13 +100,13 @@ void ParserEventPaje::store_event(const PajeLine *line, int i, trid; int defsize; int idname, idtype; - + // We check if we have an event identifier if(sscanf(line->_tokens[0], "%u", &trid) != 1){ - Error::set(Error::VITE_ERR_EXPECT_ID_DEF, line->_id, Error::VITE_ERRCODE_WARNING); - return; + Error::set(Error::VITE_ERR_EXPECT_ID_DEF, line->_id, Error::VITE_ERRCODE_WARNING); + return; } - + // We check if the trid is available def = _Definitions->getDefFromTrid(trid); if ( def == NULL ) { @@ -122,9 +121,9 @@ void ParserEventPaje::store_event(const PajeLine *line, // We check if we have enough data for this event if ( defsize > (line->_nbtks - 1) ) { - Error::set(Error::VITE_ERR_LINE_TOO_SHORT_EVENT, line->_id, - Error::VITE_ERRCODE_WARNING); - return; + Error::set(Error::VITE_ERR_LINE_TOO_SHORT_EVENT, line->_id, + Error::VITE_ERRCODE_WARNING); + return; } // Warning if we have extra data @@ -132,179 +131,174 @@ void ParserEventPaje::store_event(const PajeLine *line, Error::set(Error::VITE_ERR_EXTRA_TOKEN, line->_id, Error::VITE_ERRCODE_WARNING); } - // Dispatch the tokens in the good fields + // Dispatch the tokens in the good fields for(i=0; i < defsize; i++) { - fvalue = line->_tokens[i+1]; + fvalue = line->_tokens[i+1]; idname = (*fields)[i]._idname; idtype = (*fields)[i]._idtype; - - // Store the fvalue in the correct field - switch( idname ) { - case _PajeFN_Alias : - alias = fvalue; - break; - - case _PajeFN_Name : - name = fvalue; - break; - - case _PajeFN_ContainerType : - container_type = fvalue; - break; - - case _PajeFN_SourceContainerType : - source_container_type = fvalue; - break; - - case _PajeFN_DestContainerType : - dest_container_type = fvalue; - break; - - case _PajeFN_EntityType : - entity_type = fvalue; - break; - - case _PajeFN_Time : - time = fvalue; - if(!time.is_correct()) { - Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + - fvalue + " (expecting a \"date\")", - line->_id, - Error::VITE_ERRCODE_WARNING); - return; - } - break; - - case _PajeFN_Type : - type = fvalue; - break; - - case _PajeFN_Container : - container = fvalue; - break; - - case _PajeFN_Value : - if( idtype == _FieldType_Double ) { - value_double = fvalue; - - if(!value_double.is_correct()) { - Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + fvalue + " (expecting a \"double\")", - line->_id, Error::VITE_ERRCODE_WARNING); - return; - } - } - else { - value_string = fvalue; - } - break; - - case _PajeFN_SourceContainer : - source_container = fvalue; - break; - - case _PajeFN_DestContainer : - dest_container = fvalue; - break; - - case _PajeFN_Key : - key = fvalue; - break; - - default : - Value *value = NULL; - switch( idtype ) { - case _FieldType_String : - value = new String(fvalue); - break; - - case _FieldType_Double : - value = new Double(fvalue); - break; - - case _FieldType_Hex : - value = new Hex(fvalue); - break; - - case _FieldType_Date : - value = new Date(fvalue); - break; - - case _FieldType_Int : - value = new Integer(fvalue); - break; - - case _FieldType_Color : - value = new Color(fvalue); - break; - - default: - Error::set(Error::VITE_ERR_FIELD_TYPE_UNKNOWN, line->_id, Error::VITE_ERRCODE_WARNING); - return; - } - -// if(!value->is_correct()) { // Check if the value is correct or not -// Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + fvalue + " (expecting a \"" + ftype + "\")", -// line->_id, Error::VITE_ERRCODE_WARNING); -// return; -// } - - extra_fields[(*FNames)[idname]._name] = value; - } - } - Name alias_name; + // Store the fvalue in the correct field + switch( idname ) { + case _PajeFN_Alias : + alias = fvalue; + break; + + case _PajeFN_Name : + name = fvalue; + break; + + case _PajeFN_Type : + type = fvalue; + break; + + case _PajeFN_StartContainerType : + start_container_type = fvalue; + break; + + case _PajeFN_EndContainerType : + end_container_type = fvalue; + break; + + case _PajeFN_Time : + time = fvalue; + if(!time.is_correct()) { + Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + + fvalue + " (expecting a \"date\")", + line->_id, + Error::VITE_ERRCODE_WARNING); + return; + } + break; + + case _PajeFN_Container : + container = fvalue; + break; + + case _PajeFN_Value : + if( idtype == _FieldType_Double ) { + value_double = fvalue; + + if(!value_double.is_correct()) { + Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + fvalue + " (expecting a \"double\")", + line->_id, Error::VITE_ERRCODE_WARNING); + return; + } + } + else { + value_string = fvalue; + } + break; + + case _PajeFN_StartContainer : + start_container = fvalue; + break; + + case _PajeFN_EndContainer : + end_container = fvalue; + break; + + case _PajeFN_Key : + key = fvalue; + break; + + default : + Value *value = NULL; + switch( idtype ) { + case _FieldType_String : + value = new String(fvalue); + break; + + case _FieldType_Double : + value = new Double(fvalue); + break; + + case _FieldType_Hex : + value = new Hex(fvalue); + break; + + case _FieldType_Date : + value = new Date(fvalue); + break; + + case _FieldType_Int : + value = new Integer(fvalue); + break; + + case _FieldType_Color : + value = new Color(fvalue); + break; + + default: + Error::set(Error::VITE_ERR_FIELD_TYPE_UNKNOWN, line->_id, Error::VITE_ERRCODE_WARNING); + return; + } + +// if(!value->is_correct()) { // Check if the value is correct or not +// Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + fvalue + " (expecting a \"" + ftype + "\")", +// line->_id, Error::VITE_ERRCODE_WARNING); +// return; +// } + + extra_fields[(*FNames)[idname]._name] = value; + } + } if ( (alias != "") && (name == "" ) ){ - name = alias; + name = alias; } if ( (name != "") && (alias == "") ) { - alias = name; + alias = name; } alias_name.set_alias(alias); alias_name.set_name(name); switch( def->_id ) { - case _PajeDefineContainerType : + case _PajeDefineContainerType : { - ContainerType *temp_container_type = trace.search_container_type(container_type); - if( (temp_container_type == NULL) && (container_type.to_string() != "0") ){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + container_type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - trace.define_container_type(alias_name, temp_container_type, extra_fields); - } + ContainerType *temp_container_type = trace.search_container_type(type); + if( (temp_container_type == NULL) && (type.to_string() != "0") ){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + type.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); + } + else{ + trace.define_container_type(alias_name, temp_container_type, extra_fields); + } } break; - - case _PajeCreateContainer : + + case _PajeCreateContainer : { - ContainerType *temp_container_type = trace.search_container_type(type); - Container *temp_container = trace.search_container(container); - if(temp_container_type == NULL && type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + container.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - trace.create_container(time, alias_name, temp_container_type, temp_container, extra_fields); - // We store the container in the map - _containers[alias_name.to_string()] = trace.search_container(alias_name.to_string()); - } + ContainerType *temp_container_type = trace.search_container_type(type); + Container *temp_container = trace.search_container(container); + if(temp_container_type == NULL && type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + type.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + container.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); + } + else{ + trace.create_container(time, alias_name, temp_container_type, temp_container, extra_fields); + // We store the container in the map + _containers[alias_name.to_string()] = trace.search_container(alias_name.to_string()); + } } break; - - case _PajeDestroyContainer : + + case _PajeDestroyContainer : { - Container *temp_container = trace.search_container(alias_name.to_string()); ContainerType *temp_container_type = trace.search_container_type(type); + Container *temp_container = trace.search_container(alias_name.to_string()); if(temp_container == NULL && alias_name.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + alias_name.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + alias_name.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); } else if(temp_container_type == NULL && type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + type.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); } else{ trace.destroy_container(time, temp_container, temp_container_type, extra_fields); @@ -312,11 +306,12 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajeDefineEventType : + case _PajeDefineEventType : { - ContainerType *temp_container_type = trace.search_container_type(container_type); - if(temp_container_type == NULL && container_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + container_type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + ContainerType *temp_container_type = trace.search_container_type(type); + if(temp_container_type == NULL && type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + type.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); } else{ trace.define_event_type(alias_name, temp_container_type, extra_fields); @@ -324,11 +319,12 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajeDefineStateType : + case _PajeDefineStateType : { - ContainerType *temp_container_type = trace.search_container_type(container_type); - if(temp_container_type == NULL && container_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + container_type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + ContainerType *temp_container_type = trace.search_container_type(type); + if(temp_container_type == NULL && type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + type.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); } else{ trace.define_state_type(alias_name, temp_container_type, extra_fields); @@ -336,11 +332,12 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajeDefineVariableType : + case _PajeDefineVariableType : { - ContainerType *temp_container_type = trace.search_container_type(container_type); - if(temp_container_type == NULL && container_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + container_type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + ContainerType *temp_container_type = trace.search_container_type(type); + if(temp_container_type == NULL && type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + type.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); } else{ trace.define_variable_type(alias_name, temp_container_type, extra_fields); @@ -348,31 +345,35 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajeDefineLinkType : + case _PajeDefineLinkType : { - ContainerType *temp_container_type = trace.search_container_type(container_type); - ContainerType *temp_source_container_type = trace.search_container_type(source_container_type); - ContainerType *temp_dest_container_type = trace.search_container_type(dest_container_type); - if(temp_container_type == NULL && container_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + container_type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + ContainerType *temp_container_type = trace.search_container_type(type); + ContainerType *temp_start_container_type = trace.search_container_type(start_container_type); + ContainerType *temp_end_container_type = trace.search_container_type(end_container_type); + if(temp_container_type == NULL && type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + type.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); } - else if(temp_source_container_type == NULL && source_container_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + source_container_type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + else if(temp_start_container_type == NULL && start_container_type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + start_container_type.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); } - else if(temp_dest_container_type == NULL && dest_container_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + dest_container_type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + else if(temp_end_container_type == NULL && end_container_type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + end_container_type.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); } else{ - trace.define_link_type(alias_name, temp_container_type, temp_source_container_type, temp_dest_container_type, extra_fields); + trace.define_link_type(alias_name, temp_container_type, temp_start_container_type, temp_end_container_type, extra_fields); } } break; - case _PajeDefineEntityValue : + case _PajeDefineEntityValue : { - EntityType *temp_entity_type = trace.search_entity_type(entity_type); - if(temp_entity_type == NULL && entity_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_ENTITY_TYPE + entity_type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + EntityType *temp_entity_type = trace.search_entity_type(type); + if(temp_entity_type == NULL && type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_ENTITY_TYPE + type.to_string(), line->_id, + Error::VITE_ERRCODE_ERROR); } else{ trace.define_entity_value(alias_name, temp_entity_type, extra_fields); @@ -380,7 +381,7 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajeSetState : + case _PajeSetState : { StateType *temp_state_type = trace.search_state_type(type); EntityValue *temp_entity_value = trace.search_entity_value(value_string, temp_state_type); @@ -406,12 +407,12 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajePushState : + case _PajePushState : { StateType *temp_state_type = trace.search_state_type(type); EntityValue *temp_entity_value = trace.search_entity_value(value_string, temp_state_type); - Container *temp_container = NULL; + Container *temp_container = NULL; if(_containers.find(container) != _containers.end()) { temp_container = _containers[container]; } @@ -432,10 +433,10 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajePopState : + case _PajePopState : { StateType *temp_state_type = trace.search_state_type(type); - Container *temp_container = NULL; + Container *temp_container = NULL; if(_containers.find(container) != _containers.end()) { temp_container = _containers[container]; } @@ -456,12 +457,12 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajeNewEvent : + case _PajeNewEvent : { EventType *temp_event_type = trace.search_event_type(type); EntityValue *temp_entity_value = trace.search_entity_value(value_string, temp_event_type); - Container *temp_container = NULL; + Container *temp_container = NULL; if(_containers.find(container) != _containers.end()) { temp_container = _containers[container]; } @@ -482,7 +483,7 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajeSetVariable : + case _PajeSetVariable : { VariableType *temp_variable_type = trace.search_variable_type(type); @@ -494,7 +495,7 @@ void ParserEventPaje::store_event(const PajeLine *line, temp_container = trace.search_container(container); _containers[container] = temp_container; } - + if(temp_variable_type == NULL && type.to_string() != "0"){ Error::set(Error::VITE_ERR_UNKNOWN_VARIABLE_TYPE + type.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); } @@ -507,7 +508,7 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajeAddVariable : + case _PajeAddVariable : { VariableType *temp_variable_type = trace.search_variable_type(type); Container *temp_container = NULL; @@ -531,7 +532,7 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajeSubVariable : + case _PajeSubVariable : { VariableType *temp_variable_type = trace.search_variable_type(type); Container *temp_container = NULL; @@ -555,13 +556,13 @@ void ParserEventPaje::store_event(const PajeLine *line, } break; - case _PajeStartLink : + case _PajeStartLink : { LinkType *temp_link_type = trace.search_link_type(type); EntityValue *temp_entity_value = trace.search_entity_value(value_string, temp_link_type); Container *temp_container = NULL; - Container *temp_source_container = NULL; + Container *temp_start_container = NULL; // temp_container if(_containers.find(container) != _containers.end()) { temp_container = _containers[container]; @@ -570,13 +571,13 @@ void ParserEventPaje::store_event(const PajeLine *line, temp_container = trace.search_container(container); _containers[container] = temp_container; } - // temp_source_container - if(_containers.find(source_container) != _containers.end()) { - temp_source_container = _containers[source_container]; + // temp_start_container + if(_containers.find(start_container) != _containers.end()) { + temp_start_container = _containers[start_container]; } else { - temp_source_container = trace.search_container(source_container); - _containers[source_container] = temp_source_container; + temp_start_container = trace.search_container(start_container); + _containers[start_container] = temp_start_container; } @@ -586,22 +587,22 @@ void ParserEventPaje::store_event(const PajeLine *line, else if(temp_container == NULL && container.to_string() != "0"){ Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + container.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); } - else if(temp_source_container == NULL && source_container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + source_container.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + else if(temp_start_container == NULL && start_container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + start_container.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); } else{ - trace.start_link(time, temp_link_type, temp_container, temp_source_container, temp_entity_value, key, extra_fields); + trace.start_link(time, temp_link_type, temp_container, temp_start_container, temp_entity_value, key, extra_fields); } } break; - case _PajeEndLink : + case _PajeEndLink : { LinkType *temp_link_type = trace.search_link_type(type); EntityValue *temp_entity_value = trace.search_entity_value(value_string, temp_link_type); Container *temp_container = NULL; - Container *temp_dest_container = NULL; + Container *temp_end_container = NULL; // temp_container if(_containers.find(container) != _containers.end()) { temp_container = _containers[container]; @@ -610,13 +611,13 @@ void ParserEventPaje::store_event(const PajeLine *line, temp_container = trace.search_container(container); _containers[container] = temp_container; } - // temp_dest_container - if(_containers.find(dest_container) != _containers.end()) { - temp_dest_container = _containers[dest_container]; + // temp_end_container + if(_containers.find(end_container) != _containers.end()) { + temp_end_container = _containers[end_container]; } else { - temp_dest_container = trace.search_container(dest_container); - _containers[dest_container] = temp_dest_container; + temp_end_container = trace.search_container(end_container); + _containers[end_container] = temp_end_container; } if(temp_link_type == NULL && type.to_string() != "0"){ @@ -625,11 +626,11 @@ void ParserEventPaje::store_event(const PajeLine *line, else if(temp_container == NULL && container.to_string() != "0"){ Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + container.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); } - else if(temp_dest_container == NULL && dest_container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + dest_container.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); + else if(temp_end_container == NULL && end_container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + end_container.to_string(), line->_id, Error::VITE_ERRCODE_ERROR); } else{ - trace.end_link(time, temp_link_type, temp_container, temp_dest_container, temp_entity_value, key, extra_fields); + trace.end_link(time, temp_link_type, temp_container, temp_end_container, temp_entity_value, key, extra_fields); } } break; diff --git a/src/parser/PajeParser/mt_ParserEventPaje.cpp b/src/parser/PajeParser/mt_ParserEventPaje.cpp index 367abcc9f95f1e51abb61008a04c33707cd86e45..e49bdbefba3822893dfe017bdb498fb1e1eb2a70 100644 --- a/src/parser/PajeParser/mt_ParserEventPaje.cpp +++ b/src/parser/PajeParser/mt_ParserEventPaje.cpp @@ -6,13 +6,13 @@ ** 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, @@ -23,7 +23,7 @@ ** 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. ** @@ -37,7 +37,7 @@ ** - MARCOUEILLE Jule ** - NOISETTE Pascal ** - REDONDY Arthur -** - VUCHENER Clément +** - VUCHENER Clément ** */ #include <string> @@ -84,26 +84,26 @@ mt_ParserEventPaje::~mt_ParserEventPaje(){ void mt_ParserEventPaje::setTrace(Trace* trace){_trace=trace;} -int mt_ParserEventPaje::store_event(const PajeLine *line, - Trace &trace, - Trace_builder_struct* tb_struct) { +int mt_ParserEventPaje::store_event(const PajeLine *line, + Trace &trace, + Trace_builder_struct* tb_struct) { string fvalue; string alias; string name; - + const vector<PajeFieldName> *FNames = _Definitions->get_FieldNames(); vector< Field > *fields; PajeDefinition *def; int i, trid; int defsize; int idname, idtype; - + // We check if we have an event identifier if(sscanf(line->_tokens[0], "%u", &trid) != 1){ - Error::set(Error::VITE_ERR_EXPECT_ID_DEF, line->_id, Error::VITE_ERRCODE_WARNING); - return -1; + Error::set(Error::VITE_ERR_EXPECT_ID_DEF, line->_id, Error::VITE_ERRCODE_WARNING); + return -1; } - + // We check if the trid is available def = _Definitions->getDefFromTrid(trid); if ( def == NULL ) { @@ -118,9 +118,9 @@ int mt_ParserEventPaje::store_event(const PajeLine *line, // We check if we have enough data for this event if ( defsize > (line->_nbtks - 1) ) { - Error::set(Error::VITE_ERR_LINE_TOO_SHORT_EVENT, line->_id, - Error::VITE_ERRCODE_WARNING); - return -1; + Error::set(Error::VITE_ERR_LINE_TOO_SHORT_EVENT, line->_id, + Error::VITE_ERRCODE_WARNING); + return -1; } // Warning if we have extra data @@ -128,244 +128,236 @@ int mt_ParserEventPaje::store_event(const PajeLine *line, Error::set(Error::VITE_ERR_EXTRA_TOKEN, line->_id, Error::VITE_ERRCODE_WARNING); } - // Dispatch the tokens in the good fields + // Dispatch the tokens in the good fields for(i=0; i < defsize; i++) { - fvalue = line->_tokens[i+1]; + fvalue = line->_tokens[i+1]; idname = (*fields)[i]._idname; idtype = (*fields)[i]._idtype; - - // Store the fvalue in the correct field - switch( idname ) { - case _PajeFN_Alias : - alias = fvalue; - break; - - case _PajeFN_Name : - name = fvalue; - break; - - case _PajeFN_ContainerType : - tb_struct->container_type = fvalue; - break; - - case _PajeFN_SourceContainerType : - tb_struct->source_container_type = fvalue; - break; - - case _PajeFN_DestContainerType : - tb_struct->dest_container_type = fvalue; - break; - - case _PajeFN_EntityType : - tb_struct->entity_type = fvalue; - break; - - case _PajeFN_Time : - tb_struct->time = fvalue; - if(!tb_struct->time.is_correct()) { - Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + - fvalue + " (expecting a \"date\")", - line->_id, - Error::VITE_ERRCODE_WARNING); - return -1; - } - break; - - case _PajeFN_Type : - tb_struct->type = fvalue; - break; - - case _PajeFN_Container : - tb_struct->container = fvalue; - break; - - case _PajeFN_Value : - if( idtype == _FieldType_Double ) { - tb_struct->value_double = fvalue; - - if(!tb_struct->value_double.is_correct()) { - Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + fvalue + " (expecting a \"double\")", - line->_id, Error::VITE_ERRCODE_WARNING); - return -1; - } - } - else { - tb_struct->value_string = fvalue; - } - break; - - case _PajeFN_SourceContainer : - tb_struct->source_container = fvalue; - break; - - case _PajeFN_DestContainer : - tb_struct->dest_container = fvalue; - break; - - case _PajeFN_Key : - tb_struct->key = fvalue; - break; - - default : - Value *value = NULL; - switch( idtype ) { - case _FieldType_String : - value = new String(fvalue); - break; - - case _FieldType_Double : - value = new Double(fvalue); - break; - - case _FieldType_Hex : - value = new Hex(fvalue); - break; - - case _FieldType_Date : - value = new Date(fvalue); - break; - - case _FieldType_Int : - value = new Integer(fvalue); - break; - - case _FieldType_Color : - value = new Color(fvalue); - break; - - default: - Error::set(Error::VITE_ERR_FIELD_TYPE_UNKNOWN, line->_id, Error::VITE_ERRCODE_WARNING); - return -1; - } - -// if(!value->is_correct()) { // Check if the value is correct or not -// Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + fvalue + " (expecting a \"" + ftype + "\")", -// line->_id, Error::VITE_ERRCODE_WARNING); -// return; -// } - // if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); - // tb_struct->extra_fields->insert(pair<std::string, Value *>((*FNames)[idname]._name, value)); - tb_struct->extra_fields.insert(pair<std::string, Value *>((*FNames)[idname]._name, value)); - } + + // Store the fvalue in the correct field + switch( idname ) { + case _PajeFN_Alias : + alias = fvalue; + break; + + case _PajeFN_Name : + name = fvalue; + break; + + case _PajeFN_StartContainerType : + tb_struct->start_container_type = fvalue; + break; + + case _PajeFN_EndContainerType : + tb_struct->end_container_type = fvalue; + break; + + case _PajeFN_Time : + tb_struct->time = fvalue; + if(!tb_struct->time.is_correct()) { + Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + + fvalue + " (expecting a \"date\")", + line->_id, + Error::VITE_ERRCODE_WARNING); + return -1; + } + break; + + case _PajeFN_Type : + tb_struct->type = fvalue; + break; + + case _PajeFN_Container : + tb_struct->container = fvalue; + break; + + case _PajeFN_Value : + if( idtype == _FieldType_Double ) { + tb_struct->value_double = fvalue; + + if(!tb_struct->value_double.is_correct()) { + Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + fvalue + " (expecting a \"double\")", + line->_id, Error::VITE_ERRCODE_WARNING); + return -1; + } + } + else { + tb_struct->value_string = fvalue; + } + break; + + case _PajeFN_StartContainer : + tb_struct->start_container = fvalue; + break; + + case _PajeFN_EndContainer : + tb_struct->end_container = fvalue; + break; + + case _PajeFN_Key : + tb_struct->key = fvalue; + break; + + default : + Value *value = NULL; + switch( idtype ) { + case _FieldType_String : + value = new String(fvalue); + break; + + case _FieldType_Double : + value = new Double(fvalue); + break; + + case _FieldType_Hex : + value = new Hex(fvalue); + break; + + case _FieldType_Date : + value = new Date(fvalue); + break; + + case _FieldType_Int : + value = new Integer(fvalue); + break; + + case _FieldType_Color : + value = new Color(fvalue); + break; + + default: + Error::set(Error::VITE_ERR_FIELD_TYPE_UNKNOWN, line->_id, Error::VITE_ERRCODE_WARNING); + return -1; + } + +// if(!value->is_correct()) { // Check if the value is correct or not +// Error::set(Error::VITE_ERR_INCOMPATIBLE_VALUE_IN_EVENT + fvalue + " (expecting a \"" + ftype + "\")", +// line->_id, Error::VITE_ERRCODE_WARNING); +// return; +// } + // if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); + // tb_struct->extra_fields->insert(pair<std::string, Value *>((*FNames)[idname]._name, value)); + tb_struct->extra_fields.insert(pair<std::string, Value *>((*FNames)[idname]._name, value)); + } } // Name alias_name; if ( (alias != "") && (name == "" ) ){ - name = alias; + name = alias; } if ( (name != "") && (alias == "") ) { - alias = name; + alias = name; } tb_struct->alias.set_alias(alias); tb_struct->alias.set_name(name); - - + + tb_struct->_id=line->_id; tb_struct->_trace=&trace; //tb_struct->extra_fields=extra_fields; tb_struct->_containers=&_containers; - + switch( def->_id ) { - case _PajeDefineContainerType : + case _PajeDefineContainerType : { - tb_struct->func= TraceBuilderThread::define_container_type; - } + tb_struct->func= TraceBuilderThread::define_container_type; + } break; - - case _PajeCreateContainer : + + case _PajeCreateContainer : { - tb_struct->func= TraceBuilderThread::create_container; + tb_struct->func= TraceBuilderThread::create_container; } break; - - case _PajeDestroyContainer : + + case _PajeDestroyContainer : { tb_struct->func= TraceBuilderThread::destroy_container; } break; - case _PajeDefineEventType : + case _PajeDefineEventType : { tb_struct->func= TraceBuilderThread::define_event_type; } break; - case _PajeDefineStateType : + case _PajeDefineStateType : { tb_struct->func= TraceBuilderThread::define_state_type; } break; - case _PajeDefineVariableType : + case _PajeDefineVariableType : { tb_struct->func= TraceBuilderThread::define_variable_type; } break; - case _PajeDefineLinkType : + case _PajeDefineLinkType : { tb_struct->func= TraceBuilderThread::define_link_type; } break; - case _PajeDefineEntityValue : + case _PajeDefineEntityValue : { tb_struct->func= TraceBuilderThread::define_entity_value; } break; - case _PajeSetState : + case _PajeSetState : { - tb_struct->func= TraceBuilderThread::set_state; + tb_struct->func= TraceBuilderThread::set_state; } break; - case _PajePushState : + case _PajePushState : { tb_struct->func= TraceBuilderThread::push_state; - } + } break; - case _PajePopState : + case _PajePopState : { tb_struct->func= TraceBuilderThread::pop_state; } break; - case _PajeNewEvent : + case _PajeNewEvent : { tb_struct->func= TraceBuilderThread::new_event; } break; - case _PajeSetVariable : + case _PajeSetVariable : { tb_struct->func= TraceBuilderThread::set_variable; } break; - case _PajeAddVariable : + case _PajeAddVariable : { tb_struct->func= TraceBuilderThread::add_variable; } break; - case _PajeSubVariable : + case _PajeSubVariable : { tb_struct->func= TraceBuilderThread::sub_variable; } break; - case _PajeStartLink : + case _PajeStartLink : { tb_struct->func= TraceBuilderThread::start_link; } break; - case _PajeEndLink : + case _PajeEndLink : { tb_struct->func= TraceBuilderThread::end_link; } @@ -376,5 +368,4 @@ int mt_ParserEventPaje::store_event(const PajeLine *line, return -1; } return 0; - } - + } diff --git a/src/parser/PajeParser/mt_ParserPaje.cpp b/src/parser/PajeParser/mt_ParserPaje.cpp index e78ffeef1d39df2d86381cffc4bacf258a30f854..db9a4491f88068e3ce57d0d1a549344f4c75507e 100644 --- a/src/parser/PajeParser/mt_ParserPaje.cpp +++ b/src/parser/PajeParser/mt_ParserPaje.cpp @@ -6,13 +6,13 @@ ** 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, @@ -23,7 +23,7 @@ ** 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. ** @@ -37,7 +37,7 @@ ** - MARCOUEILLE Jule ** - NOISETTE Pascal ** - REDONDY Arthur -** - VUCHENER Clément +** - VUCHENER Clément ** */ #include <iostream> @@ -85,86 +85,86 @@ LARGE_INTEGER GetFrequency() //function for getting a quite accurate timestamp (used for debug purposes and performance evaluation) unsigned long long getCurrentTime (){ #ifndef WIN32 - // Get current time in microseconds - struct timeval ts; - gettimeofday(&ts,NULL); - unsigned long long timeValue = 0; - timeValue = (1000000 * (unsigned long long)ts.tv_sec) + (unsigned long long)ts.tv_usec; - //unsigned long long timeValue = (100000000000000000); - //double t2=ts.tv_sec+(ts.tv_usec/1000000.0); - //printf("Current Time: %llu µs \n", timeValue); - return timeValue; + // Get current time in microseconds + struct timeval ts; + gettimeofday(&ts,NULL); + unsigned long long timeValue = 0; + timeValue = (1000000 * (unsigned long long)ts.tv_sec) + (unsigned long long)ts.tv_usec; + //unsigned long long timeValue = (100000000000000000); + //double t2=ts.tv_sec+(ts.tv_usec/1000000.0); + //printf("Current Time: %llu µs \n", timeValue); + return timeValue; #else - LARGE_INTEGER tick, freq; + LARGE_INTEGER tick, freq; freq = GetFrequency(); QueryPerformanceCounter(&tick); return tick.QuadPart / freq.QuadPart; #endif - + } */ using namespace std; -mt_ParserPaje::mt_ParserPaje() : _ParserDefinition(new ParserDefinitionPaje()), - _ParserEvent(new mt_ParserEventPaje(_ParserDefinition)), _file(NULL){} +mt_ParserPaje::mt_ParserPaje() : _ParserDefinition(new ParserDefinitionPaje()), + _ParserEvent(new mt_ParserEventPaje(_ParserDefinition)), _file(NULL){} -mt_ParserPaje::mt_ParserPaje(const string &filename) : Parser(filename), - _ParserDefinition(new ParserDefinitionPaje()), - _ParserEvent(new mt_ParserEventPaje(_ParserDefinition)), _file(NULL) {} +mt_ParserPaje::mt_ParserPaje(const string &filename) : Parser(filename), + _ParserDefinition(new ParserDefinitionPaje()), + _ParserEvent(new mt_ParserEventPaje(_ParserDefinition)), _file(NULL) {} mt_ParserPaje::~mt_ParserPaje() { delete _ParserDefinition; delete _ParserEvent; if (_file != NULL) - delete _file; + delete _file; } -void mt_ParserPaje::parse(Trace &trace, - bool finish_trace_after_parse) { +void mt_ParserPaje::parse(Trace &trace, + bool finish_trace_after_parse) { static const string PERCENT = "%"; - + #ifdef DBG_PARSER_PAJE int lineid = 0; #endif // Open the trace try { - _file = new mt_PajeFileManager(_file_to_parse.c_str()); + _file = new mt_PajeFileManager(_file_to_parse.c_str()); } catch (const char *) { - delete _file; - _file = NULL; + delete _file; + _file = NULL; _is_canceled = true; finish(); trace.finish(); - std::cerr << "Cannot open file " << _file_to_parse.c_str() << std::endl; + std::cerr << "Cannot open file " << _file_to_parse.c_str() << std::endl; Error::set(Error::VITE_ERR_OPEN, 0, Error::VITE_ERRCODE_WARNING); - return; - } - + return; + } + QWaitCondition ended; - - QWaitCondition trace_ended; + + QWaitCondition trace_ended; QMutex mutex; - QMutex mutex2; + QMutex mutex2; QSemaphore freeSlots(5); QSemaphore linesProduced(5); - _ParserEvent->setTrace(&trace); - - //this object will handle syntaxic verification of the events + _ParserEvent->setTrace(&trace); + + //this object will handle syntaxic verification of the events BuilderThread bt(_ParserEvent, &trace, &ended, &trace_ended, &freeSlots, &linesProduced, &mutex, &mutex2); bt.connect((const QObject*)this, SIGNAL(produced(int, PajeLine*)), SLOT(run(int, PajeLine*))); - bt.connect((const QObject*)this, + bt.connect((const QObject*)this, SIGNAL(build_finish()), SLOT(finish_build())); - QThread consumerThread; + QThread consumerThread; bt.moveToThread(&consumerThread); - - //this object will handle all trace operations + + //this object will handle all trace operations TraceBuilderThread T_bt(&trace_ended, &freeSlots, &mutex2); T_bt.connect((const QObject*)&bt, SIGNAL(build_trace(int, Trace_builder_struct*)), @@ -176,82 +176,82 @@ void mt_ParserPaje::parse(Trace &trace, QThread traceBuilderThread; T_bt.moveToThread(&traceBuilderThread); - // they both get their own thread - + // they both get their own thread + consumerThread.start(); traceBuilderThread.start(); - //we use blocks of 10000 lines + //we use blocks of 10000 lines PajeLine* line=(PajeLine*)calloc(10000,sizeof(PajeLine)); - int i=0; + int i=0; while( (!(_file->eof())) && !(_is_canceled) ) { - - + + try { - + #ifdef DBG_PARSER_PAJE - if ( (lineid+1) == _file->get_line(&line[i]) ) - { - _file->print_line(); - lineid++; - } + if ( (lineid+1) == _file->get_line(&line[i]) ) + { + _file->print_line(); + lineid++; + } #else - _file->get_line(&line[i]); -#endif + _file->get_line(&line[i]); +#endif + } + catch(char const *){ + Error::set(Error::VITE_ERR_EXPECT_ID_DEF, 0, Error::VITE_ERRCODE_ERROR); + continue; } - catch(char const *){ - Error::set(Error::VITE_ERR_EXPECT_ID_DEF, 0, Error::VITE_ERRCODE_ERROR); - continue; - } - - // If it's an empty line - if (line[i]._nbtks == 0) { - continue; - } - // The line starts by a '%' : it's a definition - else if(line[i]._tokens[0][0] == '%') { + + // If it's an empty line + if (line[i]._nbtks == 0) { + continue; + } + // The line starts by a '%' : it's a definition + else if(line[i]._tokens[0][0] == '%') { _ParserDefinition->store_definition(&line[i]); } - // It's an event - else { + // It's an event + else { i++; - if(i==10000){//we finished to build a block, send it to the BuilderThread - - linesProduced.acquire(); - emit produced(i, line); - i=0; - line=(PajeLine*)calloc(10000,sizeof(PajeLine)); - - //if a chunk of file is finished, wait for its complete treatment before releasing the chunk - // avoids reading too quickly in the file - if(_file->eoc()){ - linesProduced.acquire(5); - _file->close_old_chunk(); - linesProduced.release(5); - } - - } - + if(i==10000){//we finished to build a block, send it to the BuilderThread + + linesProduced.acquire(); + emit produced(i, line); + i=0; + line=(PajeLine*)calloc(10000,sizeof(PajeLine)); + + //if a chunk of file is finished, wait for its complete treatment before releasing the chunk + // avoids reading too quickly in the file + if(_file->eoc()){ + linesProduced.acquire(5); + _file->close_old_chunk(); + linesProduced.release(5); + } + + } + } } - + //send the last batch emit produced(i, line); line=NULL; //send the finish signal to the BuilderThread, which will do the same to the TraceBuilderThread - //both threads will then be finished and ready to destroy - //locks the mutex and automatically unlocks it when going out of scope - QMutexLocker locker(&mutex); - emit build_finish(); - ended.wait(&mutex); - locker.unlock(); + //both threads will then be finished and ready to destroy + //locks the mutex and automatically unlocks it when going out of scope + QMutexLocker locker(&mutex); + emit build_finish(); + ended.wait(&mutex); + locker.unlock(); traceBuilderThread.quit(); traceBuilderThread.wait(); - consumerThread.quit(); - consumerThread.wait(); + consumerThread.quit(); + consumerThread.wait(); if(finish_trace_after_parse) { - + trace.finish(); finish(); } @@ -261,8 +261,7 @@ void mt_ParserPaje::parse(Trace &trace, float mt_ParserPaje::get_percent_loaded() const { if (_file != NULL) - return _file->get_percent_loaded(); + return _file->get_percent_loaded(); else - return 0.; + return 0.; } - diff --git a/src/trace/TraceBuilderThread.cpp b/src/trace/TraceBuilderThread.cpp index 724422a40118a2d93f4549ebd303795dc9c5dcf6..bd26757482b4edefba3ab6644ddd5a4b20704686 100644 --- a/src/trace/TraceBuilderThread.cpp +++ b/src/trace/TraceBuilderThread.cpp @@ -1,4 +1,3 @@ - #include <iostream> #include <stdio.h> #include <string> @@ -28,467 +27,467 @@ -TraceBuilderThread::TraceBuilderThread(QWaitCondition* cond, QSemaphore * freeSlots, QMutex* mutex):_cond(cond), _freeSlots(freeSlots), _mutex(mutex){ +TraceBuilderThread::TraceBuilderThread(QWaitCondition *cond, + QSemaphore *freeSlots, + QMutex *mutex) + : _cond(cond), _freeSlots(freeSlots), _mutex(mutex) { +} + +void TraceBuilderThread::build_trace(int n_structs, Trace_builder_struct* tb_struct) { + // printf("received %p, n=%d\n", tb_struct, n_structs); + for(int i=0; i<n_structs; i++){ + tb_struct[i].func(&tb_struct[i]); + } + _freeSlots->release(); + delete[] tb_struct; +} + +void TraceBuilderThread::build_finished(){ + //locks the mutex and automatically unlocks it when going out of scope + QMutexLocker locker(_mutex); + _is_finished=true; + _cond->wakeAll(); +} + +void TraceBuilderThread::define_container_type(Trace_builder_struct* tb_struct){ + ContainerType *temp_container_type = tb_struct->_trace->search_container_type(tb_struct->type); + if( (temp_container_type == NULL) && (tb_struct->type.to_string() != "0") ){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + tb_struct->_trace->define_container_type(tb_struct->alias, temp_container_type, tb_struct->extra_fields); + } } - void TraceBuilderThread::build_trace(int n_structs, Trace_builder_struct* tb_struct){ - // printf("received %p, n=%d\n", tb_struct, n_structs); - for(int i=0; i<n_structs; i++){ - tb_struct[i].func(&tb_struct[i]); - } - _freeSlots->release(); - delete[] tb_struct; - - - - } - - void TraceBuilderThread::build_finished(){ - //locks the mutex and automatically unlocks it when going out of scope - QMutexLocker locker(_mutex); - _is_finished=true; - _cond->wakeAll(); - } - - void TraceBuilderThread::define_container_type(Trace_builder_struct* tb_struct){ - ContainerType *temp_container_type = tb_struct->_trace->search_container_type(tb_struct->container_type); - if( (temp_container_type == NULL) && (tb_struct->container_type.to_string() != "0") ){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->container_type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - tb_struct->_trace->define_container_type(tb_struct->alias, temp_container_type, tb_struct->extra_fields); - } - } - void TraceBuilderThread::create_container(Trace_builder_struct* tb_struct){ - ContainerType *temp_container_type = tb_struct->_trace->search_container_type(tb_struct->type); - Container *temp_container = NULL; - Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); - if( it != (*tb_struct->_containers).end()) { - - temp_container =( (*it).second); - } - else { - temp_container =tb_struct->_trace->search_container(tb_struct->container); - } - - if(temp_container_type == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); - Container* new_cont = tb_struct->_trace->create_container(tb_struct->time, tb_struct->alias, temp_container_type, temp_container, tb_struct->extra_fields); - // We store the container in the map - (*tb_struct->_containers)[String(tb_struct->alias.get_alias())] = new_cont;//tb_struct->_trace->search_container(tb_struct->alias.to_string()); - - - } - } - - - - - - void TraceBuilderThread::destroy_container(Trace_builder_struct* tb_struct){ - - Container *temp_container = NULL; - Container_map::const_iterator it=(*tb_struct->_containers).find( String(tb_struct->alias.get_alias())); - if( it != (*tb_struct->_containers).end()) { - - temp_container =( (*it).second); - } - else { - temp_container =tb_struct->_trace->search_container(tb_struct->alias.to_string()); - } - - //Container *temp_container = tb_struct->_trace->search_container(tb_struct->alias.to_string()); - ContainerType *temp_container_type = tb_struct->_trace->search_container_type(tb_struct->type); - if(temp_container == NULL && tb_struct->alias.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->alias.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->destroy_container(tb_struct->time, temp_container, temp_container_type, tb_struct->extra_fields); - } - - } - - - void TraceBuilderThread::define_event_type(Trace_builder_struct* tb_struct){ - ContainerType *temp_container_type = tb_struct->_trace->search_container_type( tb_struct->container_type); - if(temp_container_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->define_event_type( tb_struct->alias, temp_container_type, tb_struct->extra_fields); - } - - } - - - void TraceBuilderThread::define_state_type(Trace_builder_struct* tb_struct){ - - ContainerType *temp_container_type = tb_struct->_trace->search_container_type( tb_struct->container_type); - if(temp_container_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->define_state_type( tb_struct->alias, temp_container_type,tb_struct->extra_fields); - } - } - - - void TraceBuilderThread::define_variable_type(Trace_builder_struct* tb_struct){ - - ContainerType *temp_container_type = tb_struct->_trace->search_container_type( tb_struct->container_type); - if(temp_container_type == NULL && tb_struct->container_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->container_type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->define_variable_type( tb_struct->alias, temp_container_type,tb_struct->extra_fields); - } - - - - } - - - void TraceBuilderThread::define_link_type(Trace_builder_struct* tb_struct){ - - ContainerType *temp_container_type = tb_struct->_trace->search_container_type( tb_struct->container_type); - ContainerType *temp_source_container_type = tb_struct->_trace->search_container_type(tb_struct->source_container_type); - ContainerType *temp_dest_container_type = tb_struct->_trace->search_container_type(tb_struct->dest_container_type); - if(temp_container_type == NULL && tb_struct->container_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->container_type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_source_container_type == NULL && tb_struct->source_container_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->source_container_type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_dest_container_type == NULL && tb_struct->dest_container_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->dest_container_type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->define_link_type( tb_struct->alias, temp_container_type, temp_source_container_type, temp_dest_container_type,tb_struct->extra_fields); - } - } - - - void TraceBuilderThread::define_entity_value(Trace_builder_struct* tb_struct) { - - EntityType *temp_entity_type = tb_struct->_trace->search_entity_type(tb_struct->entity_type); - if(temp_entity_type == NULL && tb_struct->entity_type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_ENTITY_TYPE + tb_struct->entity_type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->define_entity_value( tb_struct->alias, temp_entity_type,tb_struct->extra_fields); - } - } - - - void TraceBuilderThread::set_state(Trace_builder_struct* tb_struct){ - - StateType *temp_state_type = tb_struct->_trace->search_state_type( tb_struct->type); - - EntityValue *temp_entity_value = tb_struct->_trace->search_entity_value(tb_struct->value_string, temp_state_type); - - Container *temp_container = NULL; - Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); - if( it != (*tb_struct->_containers).end()) { - temp_container =( (*it).second); - } - else { - temp_container = tb_struct->_trace->search_container( tb_struct->container); - (*tb_struct->_containers)[tb_struct->container] = temp_container; - } - - if(temp_state_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_STATE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - tb_struct->_trace->set_state( tb_struct->time, temp_state_type, temp_container, temp_entity_value,tb_struct->extra_fields); - } - - } - - - void TraceBuilderThread::push_state(Trace_builder_struct* tb_struct){ - - StateType *temp_state_type = tb_struct->_trace->search_state_type( tb_struct->type); - EntityValue *temp_entity_value = tb_struct->_trace->search_entity_value(tb_struct->value_string, temp_state_type); - - Container *temp_container = NULL; - Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); - if( it != (*tb_struct->_containers).end()) { - temp_container =( (*it).second); - } - else { - temp_container = tb_struct->_trace->search_container( tb_struct->container); - (*tb_struct->_containers)[tb_struct->container] = temp_container; - } - - if(temp_state_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_STATE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - tb_struct->_trace->push_state( tb_struct->time, temp_state_type, temp_container, temp_entity_value,tb_struct->extra_fields); - } - - } - - - void TraceBuilderThread::pop_state(Trace_builder_struct* tb_struct){ - - StateType *temp_state_type = tb_struct->_trace->search_state_type( tb_struct->type); - Container *temp_container = NULL; - Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); - if( it != (*tb_struct->_containers).end()) { - temp_container =( (*it).second); - } - else { - temp_container = tb_struct->_trace->search_container( tb_struct->container); - (*tb_struct->_containers)[tb_struct->container] = temp_container; - } - - if(temp_state_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_STATE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->pop_state( tb_struct->time, temp_state_type, temp_container,tb_struct->extra_fields); - } - - - } - - - void TraceBuilderThread::new_event(Trace_builder_struct* tb_struct){ - - EventType *temp_event_type = tb_struct->_trace->search_event_type( tb_struct->type); - EntityValue *temp_entity_value = tb_struct->_trace->search_entity_value(tb_struct->value_string, temp_event_type); - - Container *temp_container = NULL; - Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); - if( it != (*tb_struct->_containers).end()) { - temp_container =( (*it).second); - } - else { - temp_container = tb_struct->_trace->search_container( tb_struct->container); - (*tb_struct->_containers)[tb_struct->container] = temp_container; - } - - if(temp_event_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_EVENT_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - // unsigned long long before = getCurrentTime(); - tb_struct->_trace->new_event( tb_struct->time, temp_event_type, temp_container, temp_entity_value,tb_struct->extra_fields); - // unsigned long long after = getCurrentTime(); - // g_totalTime+=(after-before); - } - - } - - - void TraceBuilderThread::set_variable(Trace_builder_struct* tb_struct){ - - VariableType *temp_variable_type = tb_struct->_trace->search_variable_type( tb_struct->type); - - Container *temp_container = NULL; - Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); - if( it != (*tb_struct->_containers).end()) { - temp_container =( (*it).second); - } - else { - temp_container = tb_struct->_trace->search_container( tb_struct->container); - (*tb_struct->_containers)[tb_struct->container] = temp_container; - } - - if(temp_variable_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_VARIABLE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->set_variable( tb_struct->time, temp_variable_type, temp_container, tb_struct->value_double,tb_struct->extra_fields); - } - - } - - - void TraceBuilderThread::add_variable(Trace_builder_struct* tb_struct){ - - VariableType *temp_variable_type = tb_struct->_trace->search_variable_type( tb_struct->type); + ContainerType *temp_container_type = tb_struct->_trace->search_container_type(tb_struct->type); + Container *temp_container = NULL; + Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); + if( it != (*tb_struct->_containers).end()) { + + temp_container =( (*it).second); + } + else { + temp_container =tb_struct->_trace->search_container(tb_struct->container); + } + + if(temp_container_type == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); + Container* new_cont = tb_struct->_trace->create_container(tb_struct->time, tb_struct->alias, temp_container_type, temp_container, tb_struct->extra_fields); + // We store the container in the map + (*tb_struct->_containers)[String(tb_struct->alias.get_alias())] = new_cont;//tb_struct->_trace->search_container(tb_struct->alias.to_string()); + + + } +} + + + + + +void TraceBuilderThread::destroy_container(Trace_builder_struct* tb_struct){ + + Container *temp_container = NULL; + Container_map::const_iterator it=(*tb_struct->_containers).find( String(tb_struct->alias.get_alias())); + if( it != (*tb_struct->_containers).end()) { + + temp_container =( (*it).second); + } + else { + temp_container =tb_struct->_trace->search_container(tb_struct->alias.to_string()); + } + + //Container *temp_container = tb_struct->_trace->search_container(tb_struct->alias.to_string()); + ContainerType *temp_container_type = tb_struct->_trace->search_container_type(tb_struct->type); + if(temp_container == NULL && tb_struct->alias.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->alias.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->destroy_container(tb_struct->time, temp_container, temp_container_type, tb_struct->extra_fields); + } + +} + + +void TraceBuilderThread::define_event_type(Trace_builder_struct* tb_struct){ + ContainerType *temp_container_type = tb_struct->_trace->search_container_type( tb_struct->type); + if(temp_container_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->define_event_type( tb_struct->alias, temp_container_type, tb_struct->extra_fields); + } + +} + + +void TraceBuilderThread::define_state_type(Trace_builder_struct* tb_struct){ + + ContainerType *temp_container_type = tb_struct->_trace->search_container_type( tb_struct->type); + if(temp_container_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->define_state_type( tb_struct->alias, temp_container_type,tb_struct->extra_fields); + } +} + + +void TraceBuilderThread::define_variable_type(Trace_builder_struct* tb_struct){ + + ContainerType *temp_container_type = tb_struct->_trace->search_container_type( tb_struct->type); + if(temp_container_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->define_variable_type( tb_struct->alias, temp_container_type,tb_struct->extra_fields); + } + + + +} + + +void TraceBuilderThread::define_link_type(Trace_builder_struct* tb_struct){ + + ContainerType *temp_container_type = tb_struct->_trace->search_container_type( tb_struct->type); + ContainerType *temp_start_container_type = tb_struct->_trace->search_container_type(tb_struct->start_container_type); + ContainerType *temp_end_container_type = tb_struct->_trace->search_container_type(tb_struct->end_container_type); + if(temp_container_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_start_container_type == NULL && tb_struct->start_container_type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->start_container_type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_end_container_type == NULL && tb_struct->end_container_type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE + tb_struct->end_container_type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->define_link_type( tb_struct->alias, temp_container_type, temp_start_container_type, temp_end_container_type,tb_struct->extra_fields); + } +} + + +void TraceBuilderThread::define_entity_value(Trace_builder_struct* tb_struct) { + + EntityType *temp_entity_type = tb_struct->_trace->search_entity_type(tb_struct->type); + if(temp_entity_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_ENTITY_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(extra_fields==NULL)extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->define_entity_value( tb_struct->alias, temp_entity_type,tb_struct->extra_fields); + } +} + + +void TraceBuilderThread::set_state(Trace_builder_struct* tb_struct){ + + StateType *temp_state_type = tb_struct->_trace->search_state_type( tb_struct->type); + + EntityValue *temp_entity_value = tb_struct->_trace->search_entity_value(tb_struct->value_string, temp_state_type); + + Container *temp_container = NULL; + Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); + if( it != (*tb_struct->_containers).end()) { + temp_container =( (*it).second); + } + else { + temp_container = tb_struct->_trace->search_container( tb_struct->container); + (*tb_struct->_containers)[tb_struct->container] = temp_container; + } + + if(temp_state_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_STATE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + tb_struct->_trace->set_state( tb_struct->time, temp_state_type, temp_container, temp_entity_value,tb_struct->extra_fields); + } + +} + + +void TraceBuilderThread::push_state(Trace_builder_struct* tb_struct){ + + StateType *temp_state_type = tb_struct->_trace->search_state_type( tb_struct->type); + EntityValue *temp_entity_value = tb_struct->_trace->search_entity_value(tb_struct->value_string, temp_state_type); + + Container *temp_container = NULL; + Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); + if( it != (*tb_struct->_containers).end()) { + temp_container =( (*it).second); + } + else { + temp_container = tb_struct->_trace->search_container( tb_struct->container); + (*tb_struct->_containers)[tb_struct->container] = temp_container; + } + + if(temp_state_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_STATE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + tb_struct->_trace->push_state( tb_struct->time, temp_state_type, temp_container, temp_entity_value,tb_struct->extra_fields); + } + +} + + +void TraceBuilderThread::pop_state(Trace_builder_struct* tb_struct){ + + StateType *temp_state_type = tb_struct->_trace->search_state_type( tb_struct->type); + Container *temp_container = NULL; + Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); + if( it != (*tb_struct->_containers).end()) { + temp_container =( (*it).second); + } + else { + temp_container = tb_struct->_trace->search_container( tb_struct->container); + (*tb_struct->_containers)[tb_struct->container] = temp_container; + } + + if(temp_state_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_STATE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->pop_state( tb_struct->time, temp_state_type, temp_container,tb_struct->extra_fields); + } + + +} + + +void TraceBuilderThread::new_event(Trace_builder_struct* tb_struct){ + + EventType *temp_event_type = tb_struct->_trace->search_event_type( tb_struct->type); + EntityValue *temp_entity_value = tb_struct->_trace->search_entity_value(tb_struct->value_string, temp_event_type); + + Container *temp_container = NULL; + Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); + if( it != (*tb_struct->_containers).end()) { + temp_container =( (*it).second); + } + else { + temp_container = tb_struct->_trace->search_container( tb_struct->container); + (*tb_struct->_containers)[tb_struct->container] = temp_container; + } + + if(temp_event_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_EVENT_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + // unsigned long long before = getCurrentTime(); + tb_struct->_trace->new_event( tb_struct->time, temp_event_type, temp_container, temp_entity_value,tb_struct->extra_fields); + // unsigned long long after = getCurrentTime(); + // g_totalTime+=(after-before); + } + +} + + +void TraceBuilderThread::set_variable(Trace_builder_struct* tb_struct){ + + VariableType *temp_variable_type = tb_struct->_trace->search_variable_type( tb_struct->type); + + Container *temp_container = NULL; + Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); + if( it != (*tb_struct->_containers).end()) { + temp_container =( (*it).second); + } + else { + temp_container = tb_struct->_trace->search_container( tb_struct->container); + (*tb_struct->_containers)[tb_struct->container] = temp_container; + } + + if(temp_variable_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_VARIABLE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->set_variable( tb_struct->time, temp_variable_type, temp_container, tb_struct->value_double,tb_struct->extra_fields); + } + +} + + +void TraceBuilderThread::add_variable(Trace_builder_struct* tb_struct){ + + VariableType *temp_variable_type = tb_struct->_trace->search_variable_type( tb_struct->type); Container *temp_container = NULL; - Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); - if( it != (*tb_struct->_containers).end()) { - temp_container =( (*it).second); - } - else { - temp_container = tb_struct->_trace->search_container( tb_struct->container); - (*tb_struct->_containers)[tb_struct->container] = temp_container; - } - - if(temp_variable_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_VARIABLE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->add_variable( tb_struct->time, temp_variable_type, temp_container, tb_struct->value_double,tb_struct->extra_fields); - } - - } - - - - void TraceBuilderThread::sub_variable(Trace_builder_struct* tb_struct){ - - VariableType *temp_variable_type = tb_struct->_trace->search_variable_type( tb_struct->type); - Container *temp_container = NULL; - Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); - if( it != (*tb_struct->_containers).end()) { - temp_container =( (*it).second); - } - else { - temp_container = tb_struct->_trace->search_container( tb_struct->container); - (*tb_struct->_containers)[tb_struct->container] = temp_container; - } - - if(temp_variable_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_VARIABLE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - //if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->sub_variable( tb_struct->time, temp_variable_type, temp_container, tb_struct->value_double,tb_struct->extra_fields); - } - } - - - - - - void TraceBuilderThread::start_link(Trace_builder_struct* tb_struct){ - - LinkType *temp_link_type = tb_struct->_trace->search_link_type( tb_struct->type); - EntityValue *temp_entity_value = tb_struct->_trace->search_entity_value(tb_struct->value_string, temp_link_type); - - Container *temp_container = NULL; - Container *temp_source_container = NULL; - // temp_container - Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); - if( it != (*tb_struct->_containers).end()) { - temp_container =( (*it).second); - } - else { - temp_container = tb_struct->_trace->search_container( tb_struct->container); - (*tb_struct->_containers)[tb_struct->container] = temp_container; - } - // temp_source_container - if((*tb_struct->_containers).find(tb_struct->source_container) != (*tb_struct->_containers).end()) { - temp_source_container = (*tb_struct->_containers)[tb_struct->source_container]; - } - else { - temp_source_container = tb_struct->_trace->search_container(tb_struct->source_container); - (*tb_struct->_containers)[tb_struct->source_container] = temp_source_container; - } - - if(temp_container == NULL && tb_struct->container.to_string() == "0"){ - temp_container= tb_struct->_trace->get_root_containers()->front(); - } - - if(temp_link_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_LINK_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_source_container == NULL && tb_struct->source_container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->source_container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ - // if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->start_link( tb_struct->time, temp_link_type, temp_container, temp_source_container, temp_entity_value, tb_struct->key,tb_struct->extra_fields); - } - - - - - } - - void TraceBuilderThread::end_link(Trace_builder_struct* tb_struct){ - LinkType *temp_link_type = tb_struct->_trace->search_link_type( tb_struct->type); - EntityValue *temp_entity_value = tb_struct->_trace->search_entity_value(tb_struct->value_string, temp_link_type); - - Container *temp_container = NULL; - Container *temp_dest_container = NULL; - // temp_container - Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); - if( it != (*tb_struct->_containers).end()) { - temp_container =( (*it).second); - } - else { - temp_container = tb_struct->_trace->search_container( tb_struct->container); - (*tb_struct->_containers)[tb_struct->container] = temp_container; - } - // temp_dest_container - if((*tb_struct->_containers).find(tb_struct->dest_container) != (*tb_struct->_containers).end()) { - temp_dest_container = (*tb_struct->_containers)[tb_struct->dest_container]; - } - else { - temp_dest_container = tb_struct->_trace->search_container(tb_struct->dest_container); - (*tb_struct->_containers)[tb_struct->dest_container] = temp_dest_container; - } - - //if message father is the root container, assign it to our first root container - if(temp_container == NULL && tb_struct->container.to_string() == "0"){ - temp_container= tb_struct->_trace->get_root_containers()->front(); - } - - if(temp_link_type == NULL && tb_struct->type.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_LINK_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else if(temp_dest_container == NULL && tb_struct->dest_container.to_string() != "0"){ - Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->dest_container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); - } - else{ + Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); + if( it != (*tb_struct->_containers).end()) { + temp_container =( (*it).second); + } + else { + temp_container = tb_struct->_trace->search_container( tb_struct->container); + (*tb_struct->_containers)[tb_struct->container] = temp_container; + } + + if(temp_variable_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_VARIABLE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ //if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); - tb_struct->_trace->end_link( tb_struct->time, temp_link_type, temp_container, temp_dest_container, temp_entity_value, tb_struct->key,tb_struct->extra_fields); - } - } + tb_struct->_trace->add_variable( tb_struct->time, temp_variable_type, temp_container, tb_struct->value_double,tb_struct->extra_fields); + } + +} + -bool TraceBuilderThread::is_finished(){return _is_finished;} +void TraceBuilderThread::sub_variable(Trace_builder_struct* tb_struct){ + VariableType *temp_variable_type = tb_struct->_trace->search_variable_type( tb_struct->type); + Container *temp_container = NULL; + Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); + if( it != (*tb_struct->_containers).end()) { + temp_container =( (*it).second); + } + else { + temp_container = tb_struct->_trace->search_container( tb_struct->container); + (*tb_struct->_containers)[tb_struct->container] = temp_container; + } + + if(temp_variable_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_VARIABLE_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->sub_variable( tb_struct->time, temp_variable_type, temp_container, tb_struct->value_double,tb_struct->extra_fields); + } +} + + + + + +void TraceBuilderThread::start_link(Trace_builder_struct* tb_struct){ + + LinkType *temp_link_type = tb_struct->_trace->search_link_type( tb_struct->type); + EntityValue *temp_entity_value = tb_struct->_trace->search_entity_value(tb_struct->value_string, temp_link_type); + + Container *temp_container = NULL; + Container *temp_start_container = NULL; + // temp_container + Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); + if( it != (*tb_struct->_containers).end()) { + temp_container =( (*it).second); + } + else { + temp_container = tb_struct->_trace->search_container( tb_struct->container); + (*tb_struct->_containers)[tb_struct->container] = temp_container; + } + // temp_start_container + if((*tb_struct->_containers).find(tb_struct->start_container) != (*tb_struct->_containers).end()) { + temp_start_container = (*tb_struct->_containers)[tb_struct->start_container]; + } + else { + temp_start_container = tb_struct->_trace->search_container(tb_struct->start_container); + (*tb_struct->_containers)[tb_struct->start_container] = temp_start_container; + } + + if(temp_container == NULL && tb_struct->container.to_string() == "0"){ + temp_container= tb_struct->_trace->get_root_containers()->front(); + } + + if(temp_link_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_LINK_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_start_container == NULL && tb_struct->start_container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->start_container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + // if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->start_link( tb_struct->time, temp_link_type, temp_container, temp_start_container, temp_entity_value, tb_struct->key,tb_struct->extra_fields); + } + + + + +} + +void TraceBuilderThread::end_link(Trace_builder_struct* tb_struct){ + LinkType *temp_link_type = tb_struct->_trace->search_link_type( tb_struct->type); + EntityValue *temp_entity_value = tb_struct->_trace->search_entity_value(tb_struct->value_string, temp_link_type); + + Container *temp_container = NULL; + Container *temp_end_container = NULL; + // temp_container + Container_map::const_iterator it=(*tb_struct->_containers).find( tb_struct->container); + if( it != (*tb_struct->_containers).end()) { + temp_container =( (*it).second); + } + else { + temp_container = tb_struct->_trace->search_container( tb_struct->container); + (*tb_struct->_containers)[tb_struct->container] = temp_container; + } + // temp_end_container + if((*tb_struct->_containers).find(tb_struct->end_container) != (*tb_struct->_containers).end()) { + temp_end_container = (*tb_struct->_containers)[tb_struct->end_container]; + } + else { + temp_end_container = tb_struct->_trace->search_container(tb_struct->end_container); + (*tb_struct->_containers)[tb_struct->end_container] = temp_end_container; + } + + //if message father is the root container, assign it to our first root container + if(temp_container == NULL && tb_struct->container.to_string() == "0"){ + temp_container= tb_struct->_trace->get_root_containers()->front(); + } + + if(temp_link_type == NULL && tb_struct->type.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_LINK_TYPE + tb_struct->type.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_container == NULL && tb_struct->container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else if(temp_end_container == NULL && tb_struct->end_container.to_string() != "0"){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER + tb_struct->end_container.to_string(), tb_struct->_id, Error::VITE_ERRCODE_ERROR); + } + else{ + //if(tb_struct->extra_fields==NULL)tb_struct->extra_fields=new map<std::string, Value *>(); + tb_struct->_trace->end_link( tb_struct->time, temp_link_type, temp_container, temp_end_container, temp_entity_value, tb_struct->key,tb_struct->extra_fields); + } +} + +bool TraceBuilderThread::is_finished(){ + return _is_finished; +} diff --git a/src/trace/TraceBuilderThread.hpp b/src/trace/TraceBuilderThread.hpp index 654c892738be9d3dd9719ff4acfe24f957115e08..81f08f7814ee2bf9cd97d9a37a0acf5bd0caded7 100644 --- a/src/trace/TraceBuilderThread.hpp +++ b/src/trace/TraceBuilderThread.hpp @@ -41,16 +41,14 @@ typedef struct Trace_builder_struct{ void (*func)(Trace_builder_struct*); Date time; Name alias; - String container_type; - String source_container_type; - String dest_container_type; - String entity_type; String type; + String start_container_type; + String end_container_type; String container; String value_string; Double value_double; - String source_container; - String dest_container; + String start_container; + String end_container; String key; std::map<std::string, Value *> extra_fields; //std::map<std::string, Value *> *extra_fields;