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

panda/src/pgraph/modelPool.h

Go to the documentation of this file.
00001 // Filename: modelPool.h
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 #ifndef MODELPOOL_H
00020 #define MODELPOOL_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "filename.h"
00025 #include "pandaNode.h"
00026 #include "pointerTo.h"
00027 
00028 #include "pmap.h"
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : ModelPool
00032 // Description : This is the preferred interface for loading models.
00033 //               It unifies all references to the same filename, so
00034 //               that multiple attempts to load the same model will
00035 //               return the same pointer.  Note that the default
00036 //               behavior is thus to make instances: use with caution.
00037 //               Use the copy_subgraph() method on Node (or use
00038 //               NodePath::copy_to) to make modifiable copies of the
00039 //               node.
00040 //
00041 //               Unlike TexturePool, this class does not automatically
00042 //               resolve the model filenames before loading, so a
00043 //               relative path and an absolute path to the same model
00044 //               will appear to be different filenames.
00045 //
00046 //               This does not presently support asynchronous loading,
00047 //               although it wouldn't be *too* difficult to add.
00048 ////////////////////////////////////////////////////////////////////
00049 class EXPCL_PANDA ModelPool {
00050 PUBLISHED:
00051   INLINE static bool has_model(const string &filename);
00052   INLINE static bool verify_model(const string &filename);
00053   INLINE static PandaNode *load_model(const string &filename);
00054 
00055   INLINE static void add_model(const string &filename, PandaNode *model);
00056   INLINE static void release_model(const string &filename);
00057   INLINE static void release_all_models();
00058 
00059   INLINE static int garbage_collect();
00060 
00061   INLINE static void list_contents(ostream &out);
00062 
00063 private:
00064   INLINE ModelPool();
00065 
00066   bool ns_has_model(const string &filename);
00067   PandaNode *ns_load_model(const string &filename);
00068   void ns_add_model(const string &filename, PandaNode *model);
00069   void ns_release_model(const string &filename);
00070   void ns_release_all_models();
00071   int ns_garbage_collect();
00072   void ns_list_contents(ostream &out);
00073 
00074   static ModelPool *get_ptr();
00075 
00076   static ModelPool *_global_ptr;
00077   typedef pmap<string,  PT(PandaNode) > Models;
00078   Models _models;
00079 };
00080 
00081 #include "modelPool.I"
00082 
00083 #endif
00084 
00085 

Generated on Fri May 2 00:41:53 2003 for Panda by doxygen1.3