Panda3D
typeRegistry.I
1 // Filename: typeRegistry.I
2 // Created by: drose (06Aug01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: TypeRegistry::freshen_derivations
18 // Access: Private
19 // Description: Rebuilds the derivation data structures after some
20 // derivation relationship has been modified, so that
21 // class relationships can quickly be determined.
22 ////////////////////////////////////////////////////////////////////
23 INLINE void TypeRegistry::
24 freshen_derivations() {
25  if (!_derivations_fresh) {
26  rebuild_derivations();
27  _derivations_fresh = true;
28  }
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: TypeRegistry::init_lock
33 // Access: Private, Static
34 // Description: Ensures the lock pointer has been allocated.
35 ////////////////////////////////////////////////////////////////////
36 INLINE void TypeRegistry::
37 init_lock() {
38  if (_lock == (MutexImpl *)NULL) {
39  _lock = new MutexImpl;
40  }
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: TypeRegistry::look_up
45 // Access: Private
46 // Description: Returns the TypeRegistryNode associated with the
47 // indicated TypeHandle. If there is no associated
48 // TypeRegistryNode, reports an error condition and
49 // returns NULL.
50 //
51 // The associated TypedObject pointer is the pointer to
52 // the object that owns the handle, if available. It is
53 // only used in an error condition, if for some reason
54 // the handle was uninitialized.
55 //
56 // Assumes the lock is already held.
57 ////////////////////////////////////////////////////////////////////
58 INLINE TypeRegistryNode *TypeRegistry::
59 look_up(TypeHandle handle, TypedObject *object) const {
60 #ifndef NDEBUG
61  if (handle._index >= (int)_handle_registry.size() ||
62  handle._index <= 0) {
63  // Invalid or uninitialized type handle.
64  return look_up_invalid(handle, object);
65  }
66 #endif
67  return _handle_registry[(size_t)handle._index];
68 }
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:98
This is a single entry in the TypeRegistry.
A fake mutex implementation for single-threaded applications that don&#39;t need any synchronization cont...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85