Panda3D
panda
src
putil
globalPointerRegistry.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 globalPointerRegistry.I
10
* @author drose
11
* @date 2000-02-03
12
*/
13
14
/**
15
* Returns the pointer associated with the indicated TypeHandle, if any. If
16
* no pointer has yet been associated, returns NULL.
17
*/
18
INLINE
void
*
GlobalPointerRegistry::
19
get_pointer
(
TypeHandle
type) {
20
return
get_global_ptr()->ns_get_pointer(type);
21
}
22
23
/**
24
* Associates the given pointer with the indicated TypeHandle. It is an error
25
* to call this with a NULL pointer, or to call this function more than once
26
* with a given TypeHandle (without first calling clear_pointer).
27
*/
28
INLINE
void
GlobalPointerRegistry::
29
store_pointer
(
TypeHandle
type,
void
*ptr) {
30
get_global_ptr()->ns_store_pointer(type, ptr);
31
}
32
33
/**
34
* Removes the association of the given pointer with the indicated TypeHandle.
35
* Subsequent calls to get_pointer() with this TypeHandle will return NULL,
36
* until another call to store_pointer() is made.
37
*/
38
INLINE
void
GlobalPointerRegistry::
39
clear_pointer
(
TypeHandle
type) {
40
get_global_ptr()->ns_clear_pointer(type);
41
}
42
43
44
/**
45
* Returns a pointer to the single GlobalPointerRegistry object. If the
46
* object does not yet exist, creates it. This indirection is used instead of
47
* making all the data members of GlobalPointerRegistry static, so that we
48
* don't have to worry about order dependency during static init time.
49
*/
50
INLINE
GlobalPointerRegistry
*GlobalPointerRegistry::
51
get_global_ptr() {
52
if
(_global_ptr ==
nullptr
) {
53
_global_ptr =
new
GlobalPointerRegistry
;
54
}
55
return
_global_ptr;
56
}
GlobalPointerRegistry::store_pointer
static void store_pointer(TypeHandle type, void *ptr)
Associates the given pointer with the indicated TypeHandle.
Definition:
globalPointerRegistry.I:29
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition:
typeHandle.h:81
GlobalPointerRegistry::get_pointer
static void * get_pointer(TypeHandle type)
Returns the pointer associated with the indicated TypeHandle, if any.
Definition:
globalPointerRegistry.I:19
GlobalPointerRegistry
This class maintains a one-to-one mapping from TypeHandle to a void * pointer.
Definition:
globalPointerRegistry.h:50
GlobalPointerRegistry::clear_pointer
static void clear_pointer(TypeHandle type)
Removes the association of the given pointer with the indicated TypeHandle.
Definition:
globalPointerRegistry.I:39
Generated on Sun Dec 27 2020 13:23:16 for Panda3D by
1.8.20