Panda3D
 All Classes Functions Variables Enumerations
globalPointerRegistry.I
00001 // Filename: globalPointerRegistry.I
00002 // Created by:  drose (03Feb00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: GlobalPointerRegistry::get_pointer
00018 //       Access: Public, Static
00019 //  Description: Returns the pointer associated with the indicated
00020 //               TypeHandle, if any.  If no pointer has yet been
00021 //               associated, returns NULL.
00022 ////////////////////////////////////////////////////////////////////
00023 INLINE void *GlobalPointerRegistry::
00024 get_pointer(TypeHandle type) {
00025   return get_global_ptr()->ns_get_pointer(type);
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: GlobalPointerRegistry::store_pointer
00030 //       Access: Public, Static
00031 //  Description: Associates the given pointer with the indicated
00032 //               TypeHandle.  It is an error to call this with a NULL
00033 //               pointer, or to call this function more than once with
00034 //               a given TypeHandle (without first calling
00035 //               clear_pointer).
00036 ////////////////////////////////////////////////////////////////////
00037 INLINE void GlobalPointerRegistry::
00038 store_pointer(TypeHandle type, void *ptr) {
00039   get_global_ptr()->ns_store_pointer(type, ptr);
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: GlobalPointerRegistry::clear_pointer
00044 //       Access: Public, Static
00045 //  Description: Removes the association of the given pointer with the
00046 //               indicated TypeHandle.  Subsequent calls to
00047 //               get_pointer() with this TypeHandle will return NULL,
00048 //               until another call to store_pointer() is made.
00049 ////////////////////////////////////////////////////////////////////
00050 INLINE void GlobalPointerRegistry::
00051 clear_pointer(TypeHandle type) {
00052   get_global_ptr()->ns_clear_pointer(type);
00053 }
00054 
00055 
00056 ////////////////////////////////////////////////////////////////////
00057 //     Function: GlobalPointerRegistry::get_global_pointer
00058 //       Access: Private, Static
00059 //  Description: Returns a pointer to the single GlobalPointerRegistry
00060 //               object.  If the object does not yet exist, creates
00061 //               it.  This indirection is used instead of making all
00062 //               the data members of GlobalPointerRegistry static, so
00063 //               that we don't have to worry about order dependency
00064 //               during static init time.
00065 ////////////////////////////////////////////////////////////////////
00066 INLINE GlobalPointerRegistry *GlobalPointerRegistry::
00067 get_global_ptr() {
00068   if (_global_ptr == (GlobalPointerRegistry *)NULL) {
00069     _global_ptr = new GlobalPointerRegistry;
00070   }
00071   return _global_ptr;
00072 }
 All Classes Functions Variables Enumerations