Panda3D
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends
BamCacheRecord Class Reference

An instance of this class is written to the front of a Bam or Txo file to make the file a cached instance of some other loadable resource. More...

#include "bamCacheRecord.h"

Inheritance diagram for BamCacheRecord:
TypedWritableReferenceCount LinkedListNode TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

List of all members.

Classes

class  DependentFile
class  SortByAccessTime

Public Member Functions

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.
void clear_data ()
 Removes the in-memory data object associated with this record, if any.
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, false otherwise.
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 within this record.
virtual TypeHandle force_init_type ()
const Filenameget_cache_filename () const
 Returns the name of the cache file as hashed from the source_pathname.
TypedWritableget_data () const
 Returns a pointer to the data stored in the record, or NULL if there is no data.
const Filenameget_dependent_pathname (int n) const
 Returns the full pathname of the nth source files that contributes to the cache.
int get_num_dependent_files () const
 Returns the number of source files that contribute to the cache.
time_t get_recorded_time () const
 Returns the time at which this particular record was recorded or updated.
const Filenameget_source_pathname () const
 Returns the full pathname to the source file that originally generated this cache request.
virtual TypeHandle get_type () const
bool has_data () const
 Returns true if this cache record has an in-memory data object associated--that is, the object stored in the cache.
bool operator== (const BamCacheRecord &other) const
 Returns true if the record matches the other record in those attributes which get written to disk.
void output (ostream &out) const
 PT (BamCacheRecord) make_copy() const
void set_data (TypedWritable *ptr, ReferenceCount *ref_ptr)
 Stores a new data object on the record.
void set_data (TypedWritable *ptr, int dummy)
 This variant on set_data() is provided just to allow Python code to pass a 0 as the second parameter.
void write (ostream &out, int indent_level=0) const
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type BamCacheRecord.

Protected Member Functions

void fillin (DatagramIterator &scan, BamReader *manager)
 This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new BamCacheRecord.

Static Protected Member Functions

static TypedWritablemake_from_bam (const FactoryParams &params)
 This function is called by the BamReader's factory when a new object of type BamCacheRecord is encountered in the Bam file.

Friends

class BamCache
class BamCacheIndex
class BamCacheRecord::SortByAccessTime

Detailed Description

An instance of this class is written to the front of a Bam or Txo file to make the file a cached instance of some other loadable resource.

This record contains information needed to test the validity of the cache.

Definition at line 38 of file bamCacheRecord.h.


Member Function Documentation

void BamCacheRecord::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.

This should be called once for the primary source file, and again for each secondary source file, if any.

Definition at line 161 of file bamCacheRecord.cxx.

References BamCache::get_global_ptr().

Referenced by Texture::do_read(), Texture::do_read_one(), Texture::do_reload_ram_image(), and EggGroupNode::r_load_externals().

void BamCacheRecord::clear_data ( ) [inline]

Removes the in-memory data object associated with this record, if any.

This does not affect the on-disk representation of the record.

Definition at line 126 of file bamCacheRecord.I.

Referenced by extract_data(), and set_data().

Empties the list of files that contribute to the data in this record.

Definition at line 147 of file bamCacheRecord.cxx.

Returns true if all of the dependent files are still the same as when the cache was recorded, false otherwise.

Definition at line 91 of file bamCacheRecord.cxx.

References BamCache::get_global_ptr(), and get_source_pathname().

bool BamCacheRecord::extract_data ( TypedWritable *&  ptr,
ReferenceCount *&  ref_ptr 
) [inline]

Fills ptr and ref_ptr with the two different-typed pointers to the same object, the data stored within this record.

This transfers ownership of the data pointer; the caller will be responsible for managing the reference counts on this object subsequently.

Returns true if the record contained any data (and the pointers have been filled), false if it didn't (and the pointers are NULL).

Definition at line 161 of file bamCacheRecord.I.

References clear_data().

void BamCacheRecord::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new BamCacheRecord.

Reimplemented from TypedWritable.

Definition at line 309 of file bamCacheRecord.cxx.

References DatagramIterator::get_string(), DatagramIterator::get_uint16(), DatagramIterator::get_uint32(), and DatagramIterator::get_uint64().

const Filename & BamCacheRecord::get_cache_filename ( ) const [inline]

Returns the name of the cache file as hashed from the source_pathname.

This will be relative to the root of the cache directory, and it will not include any suffixes that may be appended to resolve hash conflicts.

Definition at line 68 of file bamCacheRecord.I.

Returns a pointer to the data stored in the record, or NULL if there is no data.

The pointer is not removed from the record.

Definition at line 143 of file bamCacheRecord.I.

Referenced by Texture::do_reload_ram_image(), and BamCache::store().

const Filename & BamCacheRecord::get_dependent_pathname ( int  n) const [inline]

Returns the full pathname of the nth source files that contributes to the cache.

Definition at line 101 of file bamCacheRecord.I.

Returns the number of source files that contribute to the cache.

Definition at line 90 of file bamCacheRecord.I.

time_t BamCacheRecord::get_recorded_time ( ) const [inline]

Returns the time at which this particular record was recorded or updated.

Definition at line 79 of file bamCacheRecord.I.

const Filename & BamCacheRecord::get_source_pathname ( ) const [inline]

Returns the full pathname to the source file that originally generated this cache request.

In some cases, for instance in the case of a of a multipage texture like "cube_#.png", this may not not a true filename on disk.

Definition at line 54 of file bamCacheRecord.I.

Referenced by BamCacheIndex::complete_pointers(), and dependents_unchanged().

bool BamCacheRecord::has_data ( ) const [inline]

Returns true if this cache record has an in-memory data object associated--that is, the object stored in the cache.

Definition at line 114 of file bamCacheRecord.I.

Referenced by Texture::do_reload_ram_image(), and BamCache::store().

TypedWritable * BamCacheRecord::make_from_bam ( const FactoryParams params) [static, protected]

This function is called by the BamReader's factory when a new object of type BamCacheRecord is encountered in the Bam file.

It should create the BamCacheRecord and extract its information from the file.

Definition at line 290 of file bamCacheRecord.cxx.

Referenced by register_with_read_factory().

bool BamCacheRecord::operator== ( const BamCacheRecord other) const [inline]

Returns true if the record matches the other record in those attributes which get written to disk.

Does not compare the data pointer.

Definition at line 37 of file bamCacheRecord.I.

Tells the BamReader how to create objects of type BamCacheRecord.

Definition at line 253 of file bamCacheRecord.cxx.

References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().

void BamCacheRecord::set_data ( TypedWritable ptr,
ReferenceCount ref_ptr 
) [inline]

Stores a new data object on the record.

You should pass the same pointer twice, to both parameters; this allows the C++ typecasting to automatically convert the pointer into both a TypedWritable and a ReferenceCount pointer, so that the BamCacheRecord object can reliably manage the reference counts.

You may pass 0 or NULL as the second parameter. If you do this, the BamCacheRecord will not manage the object's reference count; it will be up to you to ensure the object is not deleted during the lifetime of the BamCacheRecord object.

Definition at line 185 of file bamCacheRecord.I.

References clear_data(), and ReferenceCount::ref().

Referenced by DXTextureContext8::create_texture(), DXTextureContext9::create_texture(), Texture::do_reload_ram_image(), and set_data().

void BamCacheRecord::set_data ( TypedWritable ptr,
int  dummy 
) [inline]

This variant on set_data() is provided just to allow Python code to pass a 0 as the second parameter.

Definition at line 203 of file bamCacheRecord.I.

References set_data().

void BamCacheRecord::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from TypedWritable.

Definition at line 264 of file bamCacheRecord.cxx.

References Datagram::add_string(), Datagram::add_uint16(), Datagram::add_uint32(), and Datagram::add_uint64().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations