Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/express/typeRegistry.I

Go to the documentation of this file.
00001 // Filename: typeRegistry.I
00002 // Created by:  drose (06Aug01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 #ifdef NDEBUG
00021 // This function is only inline if NDEBUG is defined.  Otherwise, it
00022 // is non-inline and its definition appears in typeRegistry.cxx.
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: TypeRegistry::look_up
00026 //       Access: Private
00027 //  Description: Returns the TypeRegistryNode associated with the
00028 //               indicated TypeHandle.
00029 ////////////////////////////////////////////////////////////////////
00030 INLINE TypeRegistryNode *TypeRegistry::
00031 look_up(TypeHandle handle, TypedObject *) const {
00032   return _handle_registry[handle._index];
00033 }
00034 #endif  // NDEBUG
00035 
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: TypeRegistry::freshen_derivations
00039 //       Access: Private
00040 //  Description: Rebuilds the derivation data structures after some
00041 //               derivation relationship has been modified, so that
00042 //               class relationships can quickly be determined.
00043 ////////////////////////////////////////////////////////////////////
00044 INLINE void TypeRegistry::
00045 freshen_derivations() {
00046   if (!_derivations_fresh) {
00047     rebuild_derivations();
00048     _derivations_fresh = true;
00049   }
00050 }
00051 
00052 ////////////////////////////////////////////////////////////////////
00053 //     Function: TypeRegistry::is_derived_from
00054 //       Access: Public
00055 //  Description: Returns true if the first type is derived from the
00056 //               second type, false otherwise.
00057 //
00058 //               The "child_object" pointer is an optional pointer to
00059 //               the TypedObject class that owns the child TypeHandle.
00060 //               It is only used in case the TypeHandle is
00061 //               inadvertently undefined.
00062 //
00063 //               This function definition follows the definitions for
00064 //               look_up() and freshen_derivations() just to maximize
00065 //               the chance the the compiler will be able to inline
00066 //               the above functions.  Yeah, a compiler shouldn't
00067 //               care, but there's a big different between "shouldn't"
00068 //               and "doesn't".
00069 ////////////////////////////////////////////////////////////////////
00070 INLINE bool TypeRegistry::
00071 is_derived_from(TypeHandle child, TypeHandle base,
00072                 TypedObject *child_object) {
00073   const TypeRegistryNode *child_node = look_up(child, child_object);
00074   const TypeRegistryNode *base_node = look_up(base, (TypedObject *)NULL);
00075   nassertr(child_node != (TypeRegistryNode *)NULL &&
00076            base_node != (TypeRegistryNode *)NULL, false);
00077   freshen_derivations();
00078   return TypeRegistryNode::is_derived_from(child_node, base_node);
00079 }

Generated on Fri May 2 00:38:44 2003 for Panda by doxygen1.3