00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ANIMPRELOADTABLE_H
00016 #define ANIMPRELOADTABLE_H
00017
00018 #include "pandabase.h"
00019 #include "typedWritableReferenceCount.h"
00020 #include "ordered_vector.h"
00021 #include "copyOnWriteObject.h"
00022
00023 class BamWriter;
00024 class BamReader;
00025 class Datagram;
00026 class DatagramIterator;
00027 class FactoryParams;
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class EXPCL_PANDA_CHAN AnimPreloadTable : public CopyOnWriteObject {
00040 public:
00041 class AnimRecord {
00042 public:
00043 INLINE AnimRecord();
00044 INLINE bool operator < (const AnimRecord &other) const;
00045
00046 string _basename;
00047 PN_stdfloat _base_frame_rate;
00048 int _num_frames;
00049 };
00050
00051 protected:
00052 virtual PT(CopyOnWriteObject) make_cow_copy();
00053
00054 PUBLISHED:
00055 AnimPreloadTable();
00056 virtual ~AnimPreloadTable();
00057
00058 int get_num_anims() const;
00059 int find_anim(const string &basename) const;
00060
00061 INLINE string get_basename(int n) const;
00062 INLINE PN_stdfloat get_base_frame_rate(int n) const;
00063 INLINE int get_num_frames(int n) const;
00064
00065 void clear_anims();
00066 void remove_anim(int n);
00067 void add_anim(const string &basename, PN_stdfloat base_frame_rate, int num_frames);
00068 void add_anims_from(const AnimPreloadTable *other);
00069
00070 virtual void output(ostream &out) const;
00071 virtual void write(ostream &out, int indent_level) const;
00072
00073 private:
00074 INLINE void consider_sort() const;
00075
00076 public:
00077 static void register_with_read_factory();
00078 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00079 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00080
00081 protected:
00082 void fillin(DatagramIterator &scan, BamReader *manager);
00083
00084 private:
00085 typedef ov_set<AnimRecord> Anims;
00086 Anims _anims;
00087 bool _needs_sort;
00088
00089 public:
00090 virtual TypeHandle get_type() const {
00091 return get_class_type();
00092 }
00093 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00094
00095 static TypeHandle get_class_type() {
00096 return _type_handle;
00097 }
00098 static void init_type() {
00099 CopyOnWriteObject::init_type();
00100 register_type(_type_handle, "AnimPreloadTable",
00101 CopyOnWriteObject::get_class_type());
00102 }
00103
00104 private:
00105 static TypeHandle _type_handle;
00106 };
00107
00108 inline ostream &operator << (ostream &out, const AnimPreloadTable &anim) {
00109 anim.output(out);
00110 return out;
00111 }
00112
00113 #include "animPreloadTable.I"
00114
00115 #endif
00116
00117