# panda3d.core.BamCacheRecord¶

from panda3d.core import BamCacheRecord

class BamCacheRecord

Bases: TypedWritableReferenceCount, LinkedListNode

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.

Inheritance diagram

addDependentFile(pathname: Filename) → None

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.

addDependentFile(file: VirtualFile) → None

property cache_filename

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.

Return type

Filename

clearData() → None

Removes the in-memory data object associated with this record, if any. This does not affect the on-disk representation of the record.

clearDependentFiles() → None

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

property data
Getter

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.

Setter

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.

This variant on setData() is provided to easily pass objects deriving from TypedWritable.

This variant on setData() is provided to easily pass objects deriving from TypedWritableReferenceCount.

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

Return type

TypedWritable

dependentsUnchanged() → bool

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

getCacheFilename() → Filename

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.

Return type

Filename

static getClassType() → TypeHandle
Return type

TypeHandle

getData() → TypedWritable

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.

Return type

TypedWritable

getDependentPathname(n: int) → Filename

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

Return type

Filename

getNumDependentFiles() → int

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

getRecordedTime() → time_t

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

Return type

time_t

getSourcePathname() → Filename

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.

Return type

Filename

getSourceTimestamp() → time_t

Returns the file timestamp of the original source file that generated this cache record, if available. In some cases the original file timestamp is not available, and this will return 0.

Return type

time_t

hasData() → bool

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

makeCopy() → BamCacheRecord

Returns a duplicate of the BamCacheRecord. The duplicate will not have a data pointer set, even though one may have been assigned to the original via setData().

Return type

BamCacheRecord

output(out: ostream) → None
property recorded_time

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

Return type

time_t

setData(ptr: TypedWritable) → None

This variant on setData() is provided to easily pass objects deriving from TypedWritable.

setData(ptr: TypedWritable, ref_ptr: ReferenceCount) → None

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.

setData(ptr: TypedWritable, dummy: int) → None

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

setData(ptr: TypedWritableReferenceCount) → None

This variant on setData() is provided to easily pass objects deriving from TypedWritableReferenceCount.

property source_pathname

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.

Return type

Filename

property source_timestamp

Returns the file timestamp of the original source file that generated this cache record, if available. In some cases the original file timestamp is not available, and this will return 0.

Return type

time_t

write(out: ostream, indent_level: int) → None