00001 // Filename: modelPool.I 00002 // Created by: drose (12Mar02) 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: ModelPool::has_model 00022 // Access: Public, Static 00023 // Description: Returns true if the model has ever been loaded, 00024 // false otherwise. 00025 //////////////////////////////////////////////////////////////////// 00026 INLINE bool ModelPool:: 00027 has_model(const string &filename) { 00028 return get_ptr()->ns_has_model(filename); 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: ModelPool::verify_model 00033 // Access: Public, Static 00034 // Description: Loads the given filename up as a model, if it has 00035 // not already been loaded, and returns true to indicate 00036 // success, or false to indicate failure. If this 00037 // returns true, it is guaranteed that a subsequent call 00038 // to load_model() with the same model name will 00039 // return a valid Node pointer. 00040 //////////////////////////////////////////////////////////////////// 00041 INLINE bool ModelPool:: 00042 verify_model(const string &filename) { 00043 return load_model(filename) != (PandaNode *)NULL; 00044 } 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Function: ModelPool::load_model 00048 // Access: Public, Static 00049 // Description: Loads the given filename up as a model, if it has 00050 // not already been loaded, and returns the new model. 00051 // If a model with the same filename was previously 00052 // loaded, returns that one instead. If the model 00053 // file cannot be found, returns NULL. 00054 //////////////////////////////////////////////////////////////////// 00055 INLINE PandaNode *ModelPool:: 00056 load_model(const string &filename) { 00057 return get_ptr()->ns_load_model(filename); 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: ModelPool::add_model 00062 // Access: Public, Static 00063 // Description: Adds the indicated already-loaded model to the 00064 // pool. The model will always replace any 00065 // previously-loaded model in the pool that had the 00066 // same filename. 00067 //////////////////////////////////////////////////////////////////// 00068 INLINE void ModelPool:: 00069 add_model(const string &filename, PandaNode *model) { 00070 get_ptr()->ns_add_model(filename, model); 00071 } 00072 00073 //////////////////////////////////////////////////////////////////// 00074 // Function: ModelPool::release_model 00075 // Access: Public, Static 00076 // Description: Removes the indicated model from the pool, 00077 // indicating it will never be loaded again; the model 00078 // may then be freed. If this function is never called, 00079 // a reference count will be maintained on every model 00080 // every loaded, and models will never be freed. 00081 //////////////////////////////////////////////////////////////////// 00082 INLINE void ModelPool:: 00083 release_model(const string &filename) { 00084 get_ptr()->ns_release_model(filename); 00085 } 00086 00087 //////////////////////////////////////////////////////////////////// 00088 // Function: ModelPool::release_all_models 00089 // Access: Public, Static 00090 // Description: Releases all models in the pool and restores the 00091 // pool to the empty state. 00092 //////////////////////////////////////////////////////////////////// 00093 INLINE void ModelPool:: 00094 release_all_models() { 00095 get_ptr()->ns_release_all_models(); 00096 } 00097 00098 //////////////////////////////////////////////////////////////////// 00099 // Function: ModelPool::garbage_collect 00100 // Access: Public, Static 00101 // Description: Releases only those models in the pool that have a 00102 // reference count of exactly 1; i.e. only those 00103 // models that are not being used outside of the pool. 00104 // Returns the number of models released. 00105 //////////////////////////////////////////////////////////////////// 00106 INLINE int ModelPool:: 00107 garbage_collect() { 00108 return get_ptr()->ns_garbage_collect(); 00109 } 00110 00111 //////////////////////////////////////////////////////////////////// 00112 // Function: ModelPool::list_contents 00113 // Access: Public, Static 00114 // Description: Lists the contents of the model pool to the 00115 // indicated output stream. 00116 //////////////////////////////////////////////////////////////////// 00117 INLINE void ModelPool:: 00118 list_contents(ostream &out) { 00119 get_ptr()->ns_list_contents(out); 00120 } 00121 00122 //////////////////////////////////////////////////////////////////// 00123 // Function: ModelPool::Constructor 00124 // Access: Private 00125 // Description: The constructor is not intended to be called 00126 // directly; there's only supposed to be one ModelPool 00127 // in the universe and it constructs itself. 00128 //////////////////////////////////////////////////////////////////// 00129 INLINE ModelPool:: 00130 ModelPool() { 00131 }