/////////////////////////////////////////////////////////////////////////////////////////// MapQuantumDatabase -- Our objective is to map all the information that the database is currently storing. It may be necessary to do some hacking about with the database object in order to expose all the information necessary to accomplish this. Addition: 2/15/99: We want to print out statistics on the cu
| 237 | // file, so let's do it here ( since we're traversing it to map the addresses, anyway ). |
| 238 | ////////////////////////////////////////////////////////////////////////////////////////////// |
| 239 | void cDbDebug::MapQuantumDatabase(cDebugHierDb& db) |
| 240 | { |
| 241 | //mirroring the implementation in blockrecordfile.h: |
| 242 | typedef std::vector<cBlockRecordArray> BlockArray; |
| 243 | |
| 244 | //Using the two added methods to gain access to the low-level implementation of the |
| 245 | //quantum database. |
| 246 | BlockArray* pBlkArray = db.myGetBlockArray(); |
| 247 | |
| 248 | // Print some statistics on the blockfile if we're in debug mode: |
| 249 | #ifdef _BLOCKFILE_DEBUG |
| 250 | db.myGetBlockFile()->TraceContents(); |
| 251 | #endif |
| 252 | // Prints as much information about the current state of the block file as can be |
| 253 | // assessed. |
| 254 | |
| 255 | // time to iterate over the database: |
| 256 | std::vector<cBlockRecordArray>::iterator i; |
| 257 | int count = 0; |
| 258 | |
| 259 | for (i = (*pBlkArray).begin(); i != (*pBlkArray).end(); ++i, ++count) |
| 260 | { |
| 261 | util_InitBlockArray(*i); |
| 262 | //This is necessary to make sure that each block is initialized as we iterate |
| 263 | //over the block array. |
| 264 | // |
| 265 | // Print out statistics on this block, if we're in debug mode: |
| 266 | #ifdef _BLOCKFILE_DEBUG |
| 267 | i->TraceContents(); |
| 268 | #endif |
| 269 | |
| 270 | |
| 271 | //Search through all the indexes and determine which of them references valid |
| 272 | //information. Store these <int, int> pairs ( the first int being the value of |
| 273 | //count.... |
| 274 | for (int j = 0; j <= i->GetNumItems(); ++j) |
| 275 | { |
| 276 | if (i->IsItemValid(j)) |
| 277 | { |
| 278 | // |
| 279 | // We found a valid node in the database, so store it in the map. |
| 280 | // |
| 281 | mpData->mDbMap.insert(cDbDebug_i::hierDbMap::value_type(std::pair<int, int>(count, j), 0)); |
| 282 | } |
| 283 | // if not, just don't store it. The index is no longer valid. |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| 289 | // TraverseHierarchy -- |
no test coverage detected