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