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

panda/src/putil/globalPointerRegistry.I

Go to the documentation of this file.
00001 // Filename: globalPointerRegistry.I
00002 // Created by:  drose (03Feb00)
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 ////////////////////////////////////////////////////////////////////
00021 //     Function: GlobalPointerRegistry::get_pointer
00022 //       Access: Public, Static
00023 //  Description: Returns the pointer associated with the indicated
00024 //               TypeHandle, if any.  If no pointer has yet been
00025 //               associated, returns NULL.
00026 ////////////////////////////////////////////////////////////////////
00027 INLINE void *GlobalPointerRegistry::
00028 get_pointer(TypeHandle type) {
00029   return get_global_ptr()->ns_get_pointer(type);
00030 }
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //     Function: GlobalPointerRegistry::store_pointer
00034 //       Access: Public, Static
00035 //  Description: Associates the given pointer with the indicated
00036 //               TypeHandle.  It is an error to call this with a NULL
00037 //               pointer, or to call this function more than once with
00038 //               a given TypeHandle (without first calling
00039 //               clear_pointer).
00040 ////////////////////////////////////////////////////////////////////
00041 INLINE void GlobalPointerRegistry::
00042 store_pointer(TypeHandle type, void *ptr) {
00043   get_global_ptr()->ns_store_pointer(type, ptr);
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: GlobalPointerRegistry::clear_pointer
00048 //       Access: Public, Static
00049 //  Description: Removes the association of the given pointer with the
00050 //               indicated TypeHandle.  Subsequent calls to
00051 //               get_pointer() with this TypeHandle will return NULL,
00052 //               until another call to store_pointer() is made.
00053 ////////////////////////////////////////////////////////////////////
00054 INLINE void GlobalPointerRegistry::
00055 clear_pointer(TypeHandle type) {
00056   get_global_ptr()->ns_clear_pointer(type);
00057 }
00058 
00059 
00060 ////////////////////////////////////////////////////////////////////
00061 //     Function: GlobalPointerRegistry::get_global_pointer
00062 //       Access: Private, Static
00063 //  Description: Returns a pointer to the single GlobalPointerRegistry
00064 //               object.  If the object does not yet exist, creates
00065 //               it.  This indirection is used instead of making all
00066 //               the data members of GlobalPointerRegistry static, so
00067 //               that we don't have to worry about order dependency
00068 //               during static init time.
00069 ////////////////////////////////////////////////////////////////////
00070 INLINE GlobalPointerRegistry *GlobalPointerRegistry::
00071 get_global_ptr() {
00072   if (_global_ptr == (GlobalPointerRegistry *)NULL) {
00073     _global_ptr = new GlobalPointerRegistry;
00074   }
00075   return _global_ptr;
00076 }

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