14#ifndef BAMCACHERECORD_H
15#define BAMCACHERECORD_H
35class EXPCL_PANDA_PUTIL BamCacheRecord :
public TypedWritableReferenceCount,
36 public LinkedListNode {
39 BamCacheRecord(
const Filename &source_pathname,
41 BamCacheRecord(
const BamCacheRecord ©);
44 virtual ~BamCacheRecord();
46 INLINE PT(BamCacheRecord) make_copy()
const;
48 INLINE
bool operator == (
const BamCacheRecord &other)
const;
50 INLINE
const Filename &get_source_pathname()
const;
51 INLINE
const Filename &get_cache_filename()
const;
52 INLINE time_t get_source_timestamp()
const;
53 INLINE time_t get_recorded_time()
const;
55 MAKE_PROPERTY(source_pathname, get_source_pathname);
56 MAKE_PROPERTY(cache_filename, get_cache_filename);
57 MAKE_PROPERTY(source_timestamp, get_source_timestamp);
58 MAKE_PROPERTY(recorded_time, get_recorded_time);
60 INLINE
int get_num_dependent_files()
const;
61 INLINE
const Filename &get_dependent_pathname(
int n)
const;
68 INLINE
bool has_data()
const;
69 INLINE
void clear_data();
70 INLINE TypedWritable *
get_data()
const;
71 INLINE
bool extract_data(TypedWritable *&ptr, ReferenceCount *&ref_ptr);
72 INLINE
void set_data(TypedWritable *ptr, ReferenceCount *ref_ptr);
73 INLINE
void set_data(TypedWritable *ptr);
74 INLINE
void set_data(TypedWritableReferenceCount *ptr);
75 INLINE
void set_data(TypedWritable *ptr,
int dummy);
79 void output(std::ostream &out)
const;
80 void write(std::ostream &out,
int indent_level = 0)
const;
84 class SortByAccessTime {
86 INLINE
bool operator () (
const BamCacheRecord *a,
const BamCacheRecord *b)
const;
89 static std::string format_timestamp(time_t timestamp);
93 time_t _recorded_time;
94 std::streamsize _record_size;
95 time_t _source_timestamp;
101 std::streamsize _size;
104 typedef pvector<DependentFile> DependentFiles;
105 DependentFiles _files;
109 Filename _cache_pathname;
111 ReferenceCount *_ref_ptr;
116 time_t _record_access_time;
119 static void register_with_read_factory();
123 static TypedWritable *make_from_bam(
const FactoryParams ¶ms);
124 void fillin(DatagramIterator &scan, BamReader *manager);
127 static TypeHandle get_class_type() {
130 static void init_type() {
131 TypedWritableReferenceCount::init_type();
133 TypedWritableReferenceCount::get_class_type());
135 virtual TypeHandle get_type()
const {
136 return get_class_type();
138 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
141 static TypeHandle _type_handle;
143 friend class BamCache;
144 friend class BamCacheIndex;
145 friend class BamCacheRecord::SortByAccessTime;
148INLINE std::ostream &operator << (std::ostream &out,
const BamCacheRecord &record) {
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
void add_dependent_file(const Filename &pathname)
Adds the indicated file to the list of files that will be loaded to generate the data in this record.
get_data
Returns a pointer to the data stored in the record, or NULL if there is no data.
bool extract_data(TypedWritable *&ptr, ReferenceCount *&ref_ptr)
Fills ptr and ref_ptr with the two different-typed pointers to the same object, the data stored withi...
set_data
Stores a new data object on the record.
void clear_dependent_files()
Empties the list of files that contribute to the data in this record.
bool dependents_unchanged() const
Returns true if all of the dependent files are still the same as when the cache was recorded,...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
The name of a file, such as a texture file or an Egg file.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
The abstract base class for a file or directory within the VirtualFileSystem.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.