Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Tools/Debugging/DebugDrawings2.cpp

Go to the documentation of this file.

    00001 /**
    00002 * @file Tools/Debugging/Debugging.cpp
    00003 *
    00004 * Functions for Debugging
    00005 *
    00006 * @author Michael Spranger
    00007 */
    00008
    00009 #include "DebugDrawings2.h"
    00010 #include "Tools/Process.h"
    00011
    00012 #ifdef NEWDEBUGGING
    00013
    00014 GT_GLOBAL DrawingManager* drawingManagerPtr;
    00015
    00016 void DrawingManager::addDrawingId(const char* name, const char* typeName, const char* description)
    00017 {
    00018   if(drawingNameIdTable.find(name) == drawingNameIdTable.end())
    00019   {
    00020     if(freeStrings)
    00021     {
    00022       char* temp = new char[strlen(name) + 1];
    00023       strcpy(temp, name);
    00024       name = temp;
    00025     }
    00026     drawingNameIdTable[name].id=(char)idCounter++;
    00027
    00028     if( drawingNameTypeTable.find(typeName) == drawingNameTypeTable.end())
    00029     {
    00030       if(freeStrings)
    00031       {
    00032         char* temp = new char[strlen(typeName) + 1];
    00033         strcpy(temp, typeName);
    00034         typeName = temp;
    00035       }
    00036       drawingNameTypeTable[typeName]=(char)typeCounter++;
    00037     }
    00038     drawingNameIdTable[name].type = drawingNameTypeTable[typeName];
    00039     if(freeStrings)
    00040     {
    00041       char* temp = new char[strlen(description) + 1];
    00042       strcpy(temp, description);
    00043       description = temp;
    00044     }
    00045     drawingNameIdTable[name].description = description;
    00046   }
    00047 }
    00048
    00049 void DrawingManager::reset()
    00050 {
    00051   if(freeStrings)
    00052   {
    00053     for(DrawingNameTypeTable::const_iterator i = drawingNameTypeTable.begin();
    00054         i != drawingNameTypeTable.end(); ++i)
    00055       delete i->first;
    00056     for(DrawingNameIdTable::const_iterator i = drawingNameIdTable.begin();
    00057         i != drawingNameIdTable.end(); ++i)
    00058     {
    00059       delete i->first;
    00060       delete i->second.description;
    00061     }
    00062     freeStrings = false;
    00063   }
    00064   drawingNameTypeTable.clear();
    00065   drawingNameIdTable.clear();
    00066 }
    00067
    00068 void initDrawingManager(DrawingManager* drawingManager)
    00069 {
    00070   drawingManagerPtr = drawingManager;
    00071 }
    00072
    00073 DrawingManager& getDrawingManager()
    00074 {
    00075   return *drawingManagerPtr;
    00076 }
    00077
    00078 In& operator>>(In& stream, DrawingManager& drawingManager)
    00079 {
    00080   drawingManager.reset();
    00081   drawingManager.freeStrings = true;
    00082
    00083   stream >> drawingManager.idCounter;
    00084   for(int i = 0; i < drawingManager.idCounter; ++i)
    00085   {
    00086     char name[100];
    00087     int id;
    00088     stream >> id >> name;
    00089     char* n = new char[strlen(name) + 1];
    00090     strcpy(n, name);
    00091     drawingManager.drawingNameTypeTable[n] = (char) id;
    00092   }
    00093
    00094   stream >> drawingManager.idCounter;
    00095   for(int i = 0; i < drawingManager.idCounter; ++i)
    00096   {
    00097     DrawingManager::DrawingNameIdTableEntry entry;
    00098     char name[100],
    00099          description[200];
    00100     int id,
    00101         type;
    00102     stream >> id >> type >> name >> description;
    00103     entry.id = (char) id;
    00104     entry.type = (char) type;
    00105     char* d = new char[strlen(description) + 1];
    00106     strcpy(d, description);
    00107     entry.description = d;
    00108     char* n = new char[strlen(name) + 1];
    00109     strcpy(n, name);
    00110     drawingManager.drawingNameIdTable[n] = entry;
    00111   }
    00112
    00113   return stream;
    00114 }
    00115
    00116 Out& operator<<(Out& stream, const DrawingManager& drawingManager)
    00117 {
    00118   stream << drawingManager.drawingNameTypeTable.size();
    00119
    00120   for (DrawingManager::DrawingNameTypeTable::const_iterator iter = drawingManager.drawingNameTypeTable.begin();
    00121        iter != drawingManager.drawingNameTypeTable.end(); ++iter)
    00122   {
    00123     stream << (int) iter->second;
    00124     stream << iter->first;
    00125   }
    00126
    00127   stream << drawingManager.drawingNameIdTable.size();
    00128   for (DrawingManager::DrawingNameIdTable::const_iterator iter = drawingManager.drawingNameIdTable.begin();
    00129        iter != drawingManager.drawingNameIdTable.end(); ++iter)
    00130   {
    00131     stream << (int) iter->second.id;
    00132     stream << (int) iter->second.type;
    00133     stream << iter->first;
    00134     stream << iter->second.description;
    00135   }
    00136
    00137   return stream;
    00138 }
    00139
    00140 #endif