MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / TraverseHierarchy

Method TraverseHierarchy

src/tw/dbdebug.cpp:295–372  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////////////////////// TraverseHierarchy -- A recursive function for traversing a hierarchical database, accounting for all the data structures that make up the object. Looks at data addresses as well as structures that are necessary to maintain the hierarchy ( namely cHierArrayInfo records ). //////////////////////////////////

Source from the content-addressed store, hash-verified

293// necessary to maintain the hierarchy ( namely cHierArrayInfo records ).
294////////////////////////////////////////////////////////////////////////////////////////////////
295void cDbDebug::TraverseHierarchy(cDebugHierDbIter pIter)
296{
297 if (!pIter.CanDescend())
298 return; //Done with this call.
299
300 pIter.Descend();
301 //
302 //Descend once from the root, into the first child set. Also, descend once for each recursive call.
303 //
304
305 for (pIter.SeekBegin(); !pIter.Done(); pIter.Next())
306 {
307 //Try to match the parent's address in the database.
308 if (!pIter.Done())
309 {
310 if (pIter.myGetEntryArrayIt() == pIter.myGetEntryArray().begin())
311 //We're dealing with a cHierArrayInfo object, so treat it differently.
312 {
313 //
314 // Let's map the parent address, and the array address, so we account for all the data structures
315 // that make up this particular node.
316 //
317 MapHierDbNodes(mpData->mDbMap,
318 std::pair<int, int>(pIter.myGetArrayInfo().mParent.mBlockNum,
319 pIter.myGetArrayInfo().mParent.mIndex),
320 pIter);
321 // and the array...
322 MapHierDbNodes(
323 mpData->mDbMap,
324 std::pair<int, int>(pIter.myGetArrayInfo().mArray.mBlockNum, pIter.myGetArrayInfo().mArray.mIndex),
325 pIter);
326 }
327 else
328 //This is a regular cHierEntry, so look at the Data and Child (if it exists ).
329 {
330
331 cDebugHierDbIter::EntryArray::iterator lEntryArrayIt = pIter.myGetEntryArrayIt();
332
333 MapHierDbNodes(mpData->mDbMap,
334 std::pair<int, int>(lEntryArrayIt->mData.mBlockNum, lEntryArrayIt->mData.mIndex),
335 pIter);
336
337 --lEntryArrayIt;
338 // Get the address of this node by examining the previous next pointer in the entry list.
339 //
340
341 //
342 // Map the next peer entry in the list. TODO: This may very well be overkill... if so, lose this call to MapHierDbNodes.
343 //
344 MapHierDbNodes(mpData->mDbMap,
345 std::pair<int, int>(lEntryArrayIt->mNext.mBlockNum, lEntryArrayIt->mNext.mIndex),
346 pIter);
347 //
348 // We also want to map the address of the child array, if non-null.
349 //
350 if (lEntryArrayIt->mChild.mBlockNum != -1)
351 MapHierDbNodes(mpData->mDbMap,
352 std::pair<int, int>(lEntryArrayIt->mChild.mBlockNum, lEntryArrayIt->mChild.mIndex),

Callers 1

ExecuteMethod · 0.80

Calls 6

beginMethod · 0.80
CanDescendMethod · 0.45
DescendMethod · 0.45
SeekBeginMethod · 0.45
DoneMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected