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

Method getCommonParent

Engine/source/console/consoleObject.cpp:292–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

getUniqueEntryListsMethod · 0.80

Calls 4

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

Tested by

no test coverage detected