00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef MODELPOOL_H
00016 #define MODELPOOL_H
00017
00018 #include "pandabase.h"
00019
00020 #include "filename.h"
00021 #include "modelRoot.h"
00022 #include "pointerTo.h"
00023 #include "lightMutex.h"
00024 #include "pmap.h"
00025 #include "loaderOptions.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 class EXPCL_PANDA_PGRAPH ModelPool {
00049 PUBLISHED:
00050 INLINE static bool has_model(const Filename &filename);
00051 INLINE static bool verify_model(const Filename &filename);
00052 BLOCKING INLINE static ModelRoot *load_model(const Filename &filename,
00053 const LoaderOptions &options = LoaderOptions());
00054
00055 INLINE static void add_model(const Filename &filename, ModelRoot *model);
00056 INLINE static void release_model(const Filename &filename);
00057
00058 INLINE static void add_model(ModelRoot *model);
00059 INLINE static void release_model(ModelRoot *model);
00060
00061 INLINE static void release_all_models();
00062
00063 INLINE static int garbage_collect();
00064
00065 INLINE static void list_contents(ostream &out);
00066 INLINE static void list_contents();
00067 static void write(ostream &out);
00068
00069 private:
00070 INLINE ModelPool();
00071
00072 bool ns_has_model(const Filename &filename);
00073 ModelRoot *ns_load_model(const Filename &filename,
00074 const LoaderOptions &options);
00075 void ns_add_model(const Filename &filename, ModelRoot *model);
00076 void ns_release_model(const Filename &filename);
00077
00078 void ns_add_model(ModelRoot *model);
00079 void ns_release_model(ModelRoot *model);
00080
00081 void ns_release_all_models();
00082 int ns_garbage_collect();
00083 void ns_list_contents(ostream &out) const;
00084
00085 static ModelPool *get_ptr();
00086
00087 static ModelPool *_global_ptr;
00088
00089 LightMutex _lock;
00090 typedef pmap<Filename, PT(ModelRoot) > Models;
00091 Models _models;
00092 };
00093
00094 #include "modelPool.I"
00095
00096 #endif
00097
00098