MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getCommonParent

Method getCommonParent

Engine/source/console/consoleObject.cpp:297–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297AbstractClassRep *AbstractClassRep::getCommonParent( const AbstractClassRep *otherClass ) const
298{
299 // CodeReview: This may be a noob way of doing it. There may be some kind of
300 // super-spiffy algorithm to do what the code below does, but this appeared
301 // to make sense to me, and it is pretty easy to see what it is doing [6/23/2007 Pat]
302
303 static VectorPtr<AbstractClassRep *> thisClassHeirarchy;
304 thisClassHeirarchy.clear();
305
306 AbstractClassRep *walk = const_cast<AbstractClassRep *>( this );
307
308 while( walk != NULL )
309 {
310 thisClassHeirarchy.push_front( walk );
311 walk = walk->getParentClass();
312 }
313
314 static VectorPtr<AbstractClassRep *> compClassHeirarchy;
315 compClassHeirarchy.clear();
316 walk = const_cast<AbstractClassRep *>( otherClass );
317 while( walk != NULL )
318 {
319 compClassHeirarchy.push_front( walk );
320 walk = walk->getParentClass();
321 }
322
323 // Make sure we only iterate over the list the number of times we can
324 S32 maxIterations = getMin( compClassHeirarchy.size(), thisClassHeirarchy.size() );
325
326 U32 i = 0;
327 for( ; i < maxIterations; i++ )
328 {
329 if( compClassHeirarchy[i] != thisClassHeirarchy[i] )
330 break;
331 }
332
333 return compClassHeirarchy[i];
334}
335
336//------------------------------------------------------------------------------
337//-------------------------------------- ConsoleObject

Callers 1

getUniqueEntryListsMethod · 0.80

Calls 4

getParentClassMethod · 0.80
clearMethod · 0.45
push_frontMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected