00001 // Filename: materialPool.I 00002 // Created by: drose (30Apr01) 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: MaterialPool::get_material 00022 // Access: Public, Static 00023 // Description: Returns a const Material pointer that represents the 00024 // same material described by temp, except that it is a 00025 // shared pointer. 00026 // 00027 // Each call to get_material() passing an equivalent 00028 // Material pointer will return the same shared pointer. 00029 // 00030 // This shared pointer must not be further modified. 00031 // Doing so will (a) cause global changes to other 00032 // objects that may share this material, and (b) damage 00033 // the sorted container that stores these things, so 00034 // that future pointers may not be properly shared. 00035 // 00036 // Also, the return value may be a different pointer 00037 // than that passed in, or it may be the same pointer. 00038 // In either case, the passed in pointer has now been 00039 // sacrificed to the greater good and should not be used 00040 // again (like any other PointerTo, it will be freed 00041 // when the last reference count is removed). 00042 //////////////////////////////////////////////////////////////////// 00043 INLINE const Material *MaterialPool:: 00044 get_material(const CPT(Material) &temp) { 00045 return get_ptr()->ns_get_material(temp); 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: MaterialPool::garbage_collect 00050 // Access: Public, Static 00051 // Description: Releases only those materials in the pool that have a 00052 // reference count of exactly 1; i.e. only those 00053 // materials that are not being used outside of the pool. 00054 // Returns the number of materials released. 00055 //////////////////////////////////////////////////////////////////// 00056 INLINE int MaterialPool:: 00057 garbage_collect() { 00058 return get_ptr()->ns_garbage_collect(); 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: MaterialPool::list_contents 00063 // Access: Public, Static 00064 // Description: Lists the contents of the material pool to the 00065 // indicated output stream. 00066 //////////////////////////////////////////////////////////////////// 00067 INLINE void MaterialPool:: 00068 list_contents(ostream &out) { 00069 get_ptr()->ns_list_contents(out); 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: MaterialPool::Constructor 00074 // Access: Private 00075 // Description: The constructor is not intended to be called 00076 // directly; there's only supposed to be one MaterialPool 00077 // in the universe and it constructs itself. 00078 //////////////////////////////////////////////////////////////////// 00079 INLINE MaterialPool:: 00080 MaterialPool() { 00081 }