00001 #include "GTXabsl2ProfilerLog.h" 00002 00003 /** 00004 * LogEntry Stuff 00005 */ 00006 int GTXabsl2LogEntry::differsInParameters(GTXabsl2LogEntry& entry) 00007 { 00008 if(this->activeOptions.size() != entry.activeOptions.size()) 00009 return 0; 00010 for(unsigned int i = 0; i < this->activeOptions.size(); ++i) 00011 if(this->activeOptions[i].optionNumber != entry.activeOptions[i].optionNumber) 00012 return 0; 00013 else if(this->activeOptions[i].stateNumber != entry.activeOptions[i].stateNumber) 00014 return 0; 00015 return 1; 00016 } 00017 In& operator>>(In& in, GTXabsl2LogEntry& logEntry) 00018 { 00019 logEntry.activeOptions.clear(); 00020 logEntry.inputSymbolValues.clear(); 00021 00022 // frame 00023 in >> logEntry.frameNumber; 00024 00025 00026 // inputSymbols 00027 int nrOfSymbols; 00028 double inputSymbolValue; 00029 in >> nrOfSymbols; 00030 std::vector<double> inputSymbolValues; 00031 for(;nrOfSymbols > 0; --nrOfSymbols) 00032 { 00033 in >> inputSymbolValue; 00034 logEntry.inputSymbolValues.push_back(inputSymbolValue); 00035 } 00036 00037 // option-graph 00038 int nrofoptions; 00039 in >> nrofoptions; 00040 std::vector<GTXabsl2ActiveOption> activeOptions; 00041 for(;nrofoptions > 0; --nrofoptions){ 00042 int optionnumber; 00043 int statenumber; 00044 in >> optionnumber; 00045 in >> statenumber; 00046 00047 int nrofparams; 00048 in >> nrofparams; 00049 std::vector<double> params; 00050 for(;nrofparams > 0; -- nrofparams){ 00051 double param; 00052 in >> param; 00053 params.push_back(param); 00054 } 00055 00056 logEntry.activeOptions.push_back(GTXabsl2ActiveOption(optionnumber, statenumber, params)); 00057 } 00058 00059 return in; 00060 } 00061 00062 Out& operator<<(Out& out, const GTXabsl2LogEntry& logEntry) 00063 { 00064 00065 out << logEntry.frameNumber; 00066 out << logEntry.inputSymbolValues.size(); 00067 for(unsigned int m = 0; m < logEntry.inputSymbolValues.size(); ++m) 00068 { 00069 out << logEntry.inputSymbolValues[m]; 00070 } 00071 out << logEntry.activeOptions.size(); 00072 for(unsigned int k = 0; k <logEntry.activeOptions.size(); ++k) 00073 { 00074 out << logEntry.activeOptions[k].optionNumber; 00075 out << logEntry.activeOptions[k].stateNumber; 00076 out << logEntry.activeOptions[k].parameters.size(); 00077 for(unsigned l = 0; l < logEntry.activeOptions[k].parameters.size(); ++l){ 00078 out << logEntry.activeOptions[k].parameters[l]; 00079 } 00080 } 00081 00082 return out; 00083 00084 } 00085 00086 /** 00087 * GTXabsl2Log 00088 */ 00089 void GTXabsl2Log::init(Xabsl2Engine& pEngine) 00090 { 00091 nameTable.init(pEngine); 00092 00093 int i; 00094 for(i = 0; i < pEngine.numberOfDecimalInputSymbols();++i) 00095 inputSymbolNames.push_back(pEngine.getDecimalInputSymbol(i)->n); 00096 for(i = 0; i < pEngine.numberOfBooleanInputSymbols();++i) 00097 inputSymbolNames.push_back(pEngine.getBooleanInputSymbol(i)->n); 00098 for(i = 0; i < pEngine.numberOfEnumeratedInputSymbols();++i) 00099 inputSymbolNames.push_back(pEngine.getEnumeratedInputSymbol(i)->n); 00100 } 00101 00102 In& operator>>(In& in, GTXabsl2Log& log) 00103 { 00104 log.clear(); 00105 if(in.eof()) 00106 return in; 00107 00108 // inputSymbols 00109 int inputSymbolTableSize = 0; 00110 char inputSymbolName[300]; 00111 in >> inputSymbolTableSize; 00112 for(;inputSymbolTableSize > 0; --inputSymbolTableSize) 00113 { 00114 in >> inputSymbolName; 00115 log.inputSymbolNames.push_back(inputSymbolName); 00116 00117 } 00118 00119 // nametable 00120 in >> log.nameTable; 00121 00122 // logs 00123 while(!in.eof()){ 00124 GTXabsl2LogEntry entry; 00125 in >> entry; 00126 log.push_back(entry); 00127 } 00128 // check if log has non ascending frame numbers 00129 for(int i = 0; i < (int) log.size(); ++i){ 00130 if(i > 0 && log[i-1].frameNumber > log[i].frameNumber) 00131 { 00132 log.clearAll(); 00133 return in; 00134 } 00135 } 00136 return in; 00137 } 00138 00139 Out& operator<<(Out& out, const GTXabsl2Log& log) 00140 { 00141 unsigned int i; 00142 00143 // inputsymbols 00144 out << log.inputSymbolNames.size(); 00145 for(i = 0;i < log.inputSymbolNames.size(); ++i) 00146 { 00147 out << log.inputSymbolNames[i].c_str(); 00148 } 00149 00150 //nameTable 00151 out << log.nameTable; 00152 00153 // logentries 00154 for(i = 0; i < log.size();++i){ 00155 out << log[i]; 00156 00157 } 00158 return out; 00159 } 00160 00161 00162 void GTXabsl2Log::clearAll() 00163 { 00164 clear(); 00165 nameTable.clear(); 00166 inputSymbolNames.clear(); 00167 } 00168 00169 /** 00170 * specific functions for log-access 00171 */ 00172 int GTXabsl2Log::getIndexOfFrameNumber(unsigned int frameNumber) 00173 { 00174 for(unsigned int i = 0; i < this->size(); ++i) 00175 { 00176 if((*this)[i].frameNumber == unsigned(frameNumber)) 00177 return int(i); 00178 } 00179 return -1; 00180 } 00181 00182 int GTXabsl2Log::getActiveOptionNumberAtFrameNumber(unsigned int frameNumber, int optionMaxDepth) 00183 { 00184 for(unsigned int i = 0; i < this->size(); ++i) 00185 { 00186 if((*this)[i].frameNumber == unsigned(frameNumber)) 00187 { 00188 for(unsigned int j = 0; j < ((*this)[i]).activeOptions.size();++j) 00189 { 00190 if(nameTable[(((*this)[i]).activeOptions[j].optionNumber)].maxDepth == optionMaxDepth) 00191 return ((*this)[i]).activeOptions[j].optionNumber; 00192 else if(nameTable[(((*this)[i]).activeOptions[j].optionNumber)].maxDepth > optionMaxDepth) 00193 return -1; 00194 } 00195 00196 } 00197 } 00198 return -1; 00199 } 00200 00201 GTXabsl2ActiveOption GTXabsl2Log::getOption(int index, int optionMaxDepth) 00202 { 00203 for(unsigned int j = 0; j < ((*this)[index]).activeOptions.size();++j) 00204 { 00205 if(nameTable[(((*this)[index]).activeOptions[j].optionNumber)].maxDepth == optionMaxDepth) 00206 return (*this)[index].activeOptions[j]; 00207 else if(nameTable[(((*this)[index]).activeOptions[j].optionNumber)].maxDepth > optionMaxDepth) 00208 return GTXabsl2ActiveOption(); 00209 } 00210 00211 return GTXabsl2ActiveOption(); 00212 } 00213
1.3.6