00001 #ifndef _SCOPED_LOG_READER_H
00002 #define _SCOPED_LOG_READER_H
00003
00004 #include "BinaryLogObject.h"
00005
00006 namespace ScopedLogReader_namespace {
00007
00008 class ScopedLogReader : public mace::BinaryLogObject, public mace::PrintPrintable {
00009 public:
00010 static const std::string type;
00011 bool begin;
00012 bool matched;
00013
00014 ScopedLogReader(bool b = true, bool d = true) : begin(b), matched(d)
00015 { }
00016
00017 public:
00018 void serialize(std::string& __str) const {
00019 __str += (char)(begin ? (matched ? '1' : '2') : (matched ? '0' : '3') );
00020 }
00021
00022 int deserialize(std::istream& is) throw(mace::SerializationException) {
00023 char c;
00024
00025
00026 c = is.get();
00027 if (c == '1') {
00028 begin = true;
00029 matched = true;
00030 }
00031 else if (c == '0') {
00032 begin = false;
00033 matched = true;
00034 }
00035 else if (c == '2') {
00036 begin = true;
00037 matched = false;
00038 }
00039 else if (c == '3') {
00040 begin = false;
00041 matched = false;
00042 }
00043 else {
00044 std::cerr << "Invalid ScopedLog token " << (int)c << " found" << std::endl;
00045 throw mace::SerializationException("Invalid ScopedLog token found");
00046 }
00047 return 1;
00048 }
00049
00050 void print(std::ostream& __out) const {
00051 if (begin) {
00052 if (matched) {
00053 __out << "STARTING";
00054 } else {
00055 __out << "CALLED";
00056 }
00057 }
00058 else {
00059 if (matched) {
00060 __out << "ENDING";
00061 } else {
00062 __out << "COMPLETED";
00063 }
00064 }
00065 }
00066
00067 const std::string& getLogType() const {
00068 return type;
00069 }
00070
00071 const std::string& getLogDescription() const {
00072 static const std::string desc = "ScopedLog";
00073 return desc;
00074 }
00075
00076 LogClass getLogClass() const {
00077 return STRUCTURE;
00078 }
00079 };
00080
00081 void init();
00082 }
00083
00084 #endif // _SCOPED_LOG_READER_H