00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef BAMCACHEINDEX_H
00016 #define BAMCACHEINDEX_H
00017
00018 #include "pandabase.h"
00019 #include "bamCacheRecord.h"
00020 #include "pointerTo.h"
00021 #include "filename.h"
00022 #include "typedWritable.h"
00023 #include "linkedListNode.h"
00024 #include "pmap.h"
00025 #include "pvector.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 class EXPCL_PANDA_PUTIL BamCacheIndex : public TypedWritable, public LinkedListNode {
00038 private:
00039 INLINE BamCacheIndex();
00040 ~BamCacheIndex();
00041
00042 public:
00043 void write(ostream &out, int indent_level = 0) const;
00044
00045 private:
00046 void process_new_records();
00047 void release_records();
00048 PT(BamCacheRecord) evict_old_file();
00049
00050 bool add_record(BamCacheRecord *record);
00051 bool remove_record(const Filename &source_pathname);
00052
00053 private:
00054 typedef pmap<Filename, PT(BamCacheRecord) > Records;
00055
00056 Records _records;
00057 off_t _cache_size;
00058
00059
00060
00061 typedef pvector< PT(BamCacheRecord) > RecordVector;
00062 RecordVector _record_vector;
00063
00064 public:
00065 static void register_with_read_factory();
00066 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00067
00068 protected:
00069 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00070 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
00071 void fillin(DatagramIterator &scan, BamReader *manager);
00072
00073 public:
00074 static TypeHandle get_class_type() {
00075 return _type_handle;
00076 }
00077 static void init_type() {
00078 TypedWritable::init_type();
00079 register_type(_type_handle, "BamCacheIndex",
00080 TypedWritable::get_class_type());
00081 }
00082 virtual TypeHandle get_type() const {
00083 return get_class_type();
00084 }
00085 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00086
00087 private:
00088 static TypeHandle _type_handle;
00089
00090 friend class BamCache;
00091 };
00092
00093 #include "bamCacheIndex.I"
00094
00095 #endif