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

# Tools/Debugging/Trace.cpp

Go to the documentation of this file.

    00001 /**
    00002 * @file Tools/Debugging/Trace.cpp
    00003 *
    00004 * A class representing a trace.
    00005 *
    00006 * @author Thomas Röfer
    00007 */
    00008
    00009 #include <string.h>
    00010 #include "Trace.h"
    00011
    00012 static Trace* trace = 0;
    00013
    00014 Trace::Line::Line(const char* f, int l)
    00015 : line(l)
    00016 {
    00017   strcpy(file, f);
    00018 }
    00019
    00020 void Trace::setCurrentLine(const char* file, int line)
    00021 {
    00022   buffer.add(Line(file, line));
    00023 }
    00024
    00025 In& operator>>(In& stream, Trace& trace)
    00026 {
    00027   trace.buffer.init();
    00028   int size;
    00029   stream >> size;
    00030   for(int i = 0; i < size; ++i)
    00031   {
    00032     Trace::Line line;
    00033     stream >> line.file >> line.line;
    00034     trace.buffer.add(line);
    00035   }
    00036   return stream;
    00037 }
    00038
    00039 Out& operator<<(Out& stream, const Trace& trace)
    00040 {
    00041   stream << trace.buffer.getNumberOfEntries() << endl;
    00042   for(int i = trace.buffer.getNumberOfEntries() - 1; i >= 0; --i)
    00043     stream << trace.buffer[i].file << trace.buffer[i].line << endl;
    00044   return stream;
    00045 }
    00046
    00047 Trace& getTrace()
    00048 {
    00049   return *trace;
    00050 }
    00051
    00052 void setTrace(Trace& t)
    00053 {
    00054   trace = &t;
    00055 }