Panda3D
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes

BamReader Class Reference

This is the fundamental interface for extracting binary objects from a Bam file, as generated by a BamWriter. More...

#include "bamReader.h"

Inheritance diagram for BamReader:
BamEnums

List of all members.

Classes

class  AuxData
class  CreatedObj
class  PointerReference

Public Types

typedef TypedWritable *(* ChangeThisFunc )(TypedWritable *object, BamReader *manager)
typedef PT()
TypedWritableReferenceCount(* 
ChangeThisRefFunc )(TypedWritableReferenceCount *object, BamReader *manager)
typedef Factory< TypedWritableWritableFactory

Public Member Functions

 BamReader (DatagramGenerator *source=NULL)
bool change_pointer (const TypedWritable *orig_pointer, const TypedWritable *new_pointer)
 Indicates that an object recently read from the bam stream should be replaced with a new object.
void finalize_now (TypedWritable *whom)
 Forces the finalization of a particular object.
AuxDataget_aux_data (TypedWritable *obj, const string &name) const
 Returns the pointer previously associated with the bam reader by a previous call to set_aux_data(), or NULL if data with the indicated key has not been set.
BamReaderAuxDataget_aux_tag (const string &tag) const
 Returns the value previously set via set_aux_tag().
int get_current_major_ver () const
 Returns the major version number of Bam files supported by the current code base.
int get_current_minor_ver () const
 Returns the minor version number of Bam files supported by the current code base.
const FileReferenceget_file ()
 Returns the FileReference that provides the source for these datagrams, if any, or NULL if the datagrams do not originate from a file on disk.
BamEndian get_file_endian () const
 Returns the endian preference indicated by the Bam file currently being read.
int get_file_major_ver () const
 Returns the major version number of the Bam file currently being read.
int get_file_minor_ver () const
 Returns the minor version number of the Bam file currently being read.
streampos get_file_pos ()
 Returns the current file position within the data stream, if any, or 0 if the file position is not meaningful or cannot be determined.
bool get_file_stdfloat_double () const
 Returns true if the file stores all "standard" floats as 64-bit doubles, or false if they are 32-bit floats.
const Filenameget_filename () const
 If a BAM is a file, then the BamReader should contain the name of the file.
int get_int_tag (const string &tag) const
 Returns the value previously set via set_int_tag().
const LoaderOptionsget_loader_options () const
 Returns the LoaderOptions passed to the loader when the model was requested, if any.
void * get_pta (DatagramIterator &scan)
 This function works in conjection with register_pta(), below, to read a PointerToArray (PTA) from the Bam file, and unify references to the same PTA.
DatagramGeneratorget_source ()
 Returns the current source of the BamReader as set by set_source() or the constructor.
VirtualFileget_vfile ()
 Returns the VirtualFile that provides the source for these datagrams, if any, or NULL if the datagrams do not originate from a VirtualFile.
bool init ()
 Initializes the BamReader prior to reading any objects from its source.
bool is_eof () const
 Returns true if the reader has reached end-of-file, false otherwise.
void read_cdata (DatagramIterator &scan, PipelineCyclerBase &cycler, void *extra_data)
 This flavor of read_cdata allows passing an additional parameter to cdata->fillin().
void read_cdata (DatagramIterator &scan, PipelineCyclerBase &cycler)
 Reads in the indicated CycleData object.
void read_file_data (SubfileInfo &info)
 Reads a block of auxiliary file data from the Bam file.
TypeHandle read_handle (DatagramIterator &scan)
 Reads a TypeHandle out of the Datagram.
bool read_object (TypedWritable *&ptr, ReferenceCount *&ref_ptr)
 Reads a single object from the Bam file.
TypedWritableread_object ()
 Reads a single object from the Bam file.
void read_pointer (DatagramIterator &scan)
 The interface for reading a pointer to another object from a Bam file.
void read_pointers (DatagramIterator &scan, int count)
 A convenience function to read a contiguous list of pointers.
void register_change_this (ChangeThisFunc func, TypedWritable *whom)
 Called by an object reading itself from the bam file to indicate that the object pointer that will be returned is temporary, and will eventually need to be replaced with another pointer.
void register_change_this (ChangeThisRefFunc func, TypedWritableReferenceCount *whom)
 Called by an object reading itself from the bam file to indicate that the object pointer that will be returned is temporary, and will eventually need to be replaced with another pointer.
void register_finalize (TypedWritable *whom)
 Should be called by an object reading itself from the Bam file to indicate that this particular object would like to receive the finalize() callback when all the objects and pointers in the Bam file are completely read.
void register_pta (void *ptr)
 The second part of read_pta(), this should be called with the pointer to the array that was read in after read_pta() returned NULL.
bool resolve ()
 This may be called at any time during processing of the Bam file to resolve all the known pointers so far.
void set_aux_data (TypedWritable *obj, const string &name, AuxData *data)
 Associates an arbitrary block of data with the indicated object (or NULL), and the indicated name.
void set_aux_tag (const string &tag, BamReaderAuxData *value)
 Allows the creating object to store a temporary data value on the BamReader.
void set_int_tag (const string &tag, int value)
 Allows the creating object to store a temporary data value on the BamReader.
void set_loader_options (const LoaderOptions &options)
 Specifies the LoaderOptions for this BamReader.
void set_source (DatagramGenerator *source)
 Changes the source of future datagrams for this BamReader.
void skip_pointer (DatagramIterator &scan)
 Reads and discards a pointer value from the Bam file.

Static Public Member Functions

static WritableFactoryget_factory ()
 Returns the global WritableFactory for generating TypedWritable objects.

Static Public Attributes

static BamReader *const Null = (BamReader*)0L
static WritableFactory *const NullFactory = (WritableFactory*)0L

Detailed Description

This is the fundamental interface for extracting binary objects from a Bam file, as generated by a BamWriter.

A Bam file can be thought of as a linear collection of objects. Each object is an instance of a class that inherits, directly or indirectly, from TypedWritable. The objects may include pointers to other objects within the Bam file; the BamReader automatically manages these (with help from code within each class) and restores the pointers correctly.

This is the abstract interface and does not specifically deal with disk files, but rather with a DatagramGenerator of some kind, which is simply a linear source of Datagrams. It is probably from a disk file, but it might conceivably be streamed directly from a network or some such nonsense.

Bam files are most often used to store scene graphs or subgraphs, and by convention they are given filenames ending in the extension ".bam" when they are used for this purpose. However, a Bam file may store any arbitrary list of TypedWritable objects; in this more general usage, they are given filenames ending in ".boo" to differentiate them from the more common scene graph files.

See also BamFile, which defines a higher-level interface to read and write Bam files on disk.

Definition at line 122 of file bamReader.h.


Member Function Documentation

bool BamReader::change_pointer ( const TypedWritable orig_pointer,
const TypedWritable new_pointer 
)

Indicates that an object recently read from the bam stream should be replaced with a new object.

Any future occurrences of the original object in the stream will henceforth return the new object instead.

The return value is true if the replacement was successfully made, or false if the object was not read from the stream (or if change_pointer had already been called on it).

Definition at line 497 of file bamReader.cxx.

References TypedWritable::as_reference_count().

Referenced by GeomVertexData::finalize(), and GeomVertexArrayData::finalize().

void BamReader::finalize_now ( TypedWritable whom)

Forces the finalization of a particular object.

This may be called by any of the objects during finalization, to guarantee finalization ordering where it is important.

Definition at line 980 of file bamReader.cxx.

References TypedWritable::finalize().

Referenced by GeomNode::finalize().

BamReader::AuxData * BamReader::get_aux_data ( TypedWritable obj,
const string &  name 
) const

Returns the pointer previously associated with the bam reader by a previous call to set_aux_data(), or NULL if data with the indicated key has not been set.

Definition at line 200 of file bamReader.cxx.

Referenced by LightAttrib::complete_pointers(), LightAttrib::finalize(), and GeomVertexArrayData::finalize().

BamReaderAuxData * BamReader::get_aux_tag ( const string &  tag) const

Returns the value previously set via set_aux_tag().

It is an error if no value has been set.

Definition at line 853 of file bamReader.cxx.

int BamReader::get_current_major_ver ( ) const [inline]

Returns the major version number of Bam files supported by the current code base.

This must match get_file_major_ver() in order to successfully read a file.

Definition at line 145 of file bamReader.I.

int BamReader::get_current_minor_ver ( ) const [inline]

Returns the minor version number of Bam files supported by the current code base.

This must match or exceed get_file_minor_ver() in order to successfully read a file.

Definition at line 158 of file bamReader.I.

WritableFactory * BamReader::get_factory ( ) [inline, static]

Returns the global WritableFactory for generating TypedWritable objects.

Definition at line 213 of file bamReader.I.

Referenced by TextureReference::register_with_read_factory(), TextureProperties::register_with_read_factory(), TexturePosition::register_with_read_factory(), TexturePlacement::register_with_read_factory(), TextureImage::register_with_read_factory(), SourceTextureImage::register_with_read_factory(), Palettizer::register_with_read_factory(), PalettePage::register_with_read_factory(), PaletteImage::register_with_read_factory(), PaletteGroups::register_with_read_factory(), PaletteGroup::register_with_read_factory(), EggFile::register_with_read_factory(), DestTextureImage::register_with_read_factory(), SpeedTreeNode::register_with_read_factory(), RecorderTable::register_with_read_factory(), RecorderHeader::register_with_read_factory(), RecorderFrame::register_with_read_factory(), MouseRecorder::register_with_read_factory(), BamCacheRecord::register_with_read_factory(), BamCacheIndex::register_with_read_factory(), UvScrollNode::register_with_read_factory(), SwitchNode::register_with_read_factory(), Spotlight::register_with_read_factory(), SequenceNode::register_with_read_factory(), PointLight::register_with_read_factory(), LODNode::register_with_read_factory(), FadeLODNode::register_with_read_factory(), DirectionalLight::register_with_read_factory(), CallbackNode::register_with_read_factory(), AmbientLight::register_with_read_factory(), TransparencyAttrib::register_with_read_factory(), TransformState::register_with_read_factory(), TextureAttrib::register_with_read_factory(), TexProjectorEffect::register_with_read_factory(), TexMatrixAttrib::register_with_read_factory(), TexGenAttrib::register_with_read_factory(), StencilAttrib::register_with_read_factory(), ShowBoundsEffect::register_with_read_factory(), ShadeModelAttrib::register_with_read_factory(), ScissorEffect::register_with_read_factory(), ScissorAttrib::register_with_read_factory(), RescaleNormalAttrib::register_with_read_factory(), RenderState::register_with_read_factory(), RenderModeAttrib::register_with_read_factory(), RenderEffects::register_with_read_factory(), PortalNode::register_with_read_factory(), PolylightNode::register_with_read_factory(), PlaneNode::register_with_read_factory(), PandaNode::register_with_read_factory(), OccluderNode::register_with_read_factory(), OccluderEffect::register_with_read_factory(), ModelRoot::register_with_read_factory(), ModelNode::register_with_read_factory(), MaterialAttrib::register_with_read_factory(), LightRampAttrib::register_with_read_factory(), LightAttrib::register_with_read_factory(), LensNode::register_with_read_factory(), GeomNode::register_with_read_factory(), FogAttrib::register_with_read_factory(), Fog::register_with_read_factory(), DepthWriteAttrib::register_with_read_factory(), DepthTestAttrib::register_with_read_factory(), DepthOffsetAttrib::register_with_read_factory(), DecalEffect::register_with_read_factory(), CullFaceAttrib::register_with_read_factory(), CullBinAttrib::register_with_read_factory(), CompassEffect::register_with_read_factory(), ColorWriteAttrib::register_with_read_factory(), ColorScaleAttrib::register_with_read_factory(), ColorBlendAttrib::register_with_read_factory(), ColorAttrib::register_with_read_factory(), ClipPlaneAttrib::register_with_read_factory(), Camera::register_with_read_factory(), BillboardEffect::register_with_read_factory(), AuxBitplaneAttrib::register_with_read_factory(), AudioVolumeAttrib::register_with_read_factory(), AntialiasAttrib::register_with_read_factory(), AlphaTestAttrib::register_with_read_factory(), SheetNode::register_with_read_factory(), RopeNode::register_with_read_factory(), NurbsCurve::register_with_read_factory(), HermiteCurve::register_with_read_factory(), CubicCurveseg::register_with_read_factory(), UserVertexTransform::register_with_read_factory(), UserVertexSlider::register_with_read_factory(), TransformTable::register_with_read_factory(), TransformBlendTable::register_with_read_factory(), TextureStage::register_with_read_factory(), Texture::register_with_read_factory(), SliderTable::register_with_read_factory(), PerspectiveLens::register_with_read_factory(), OrthographicLens::register_with_read_factory(), MatrixLens::register_with_read_factory(), Material::register_with_read_factory(), InternalName::register_with_read_factory(), GeomVertexFormat::register_with_read_factory(), GeomVertexData::register_with_read_factory(), GeomVertexArrayFormat::register_with_read_factory(), GeomVertexArrayData::register_with_read_factory(), GeomTristrips::register_with_read_factory(), GeomTrifans::register_with_read_factory(), GeomTriangles::register_with_read_factory(), GeomPoints::register_with_read_factory(), GeomLinestrips::register_with_read_factory(), GeomLines::register_with_read_factory(), Geom::register_with_read_factory(), EventStoreValue< Type >::register_with_read_factory(), ButtonEventList::register_with_read_factory(), DataNodeTransmit::register_with_read_factory(), CollisionTube::register_with_read_factory(), CollisionSphere::register_with_read_factory(), CollisionSegment::register_with_read_factory(), CollisionRay::register_with_read_factory(), CollisionPolygon::register_with_read_factory(), CollisionPlane::register_with_read_factory(), CollisionParabola::register_with_read_factory(), CollisionNode::register_with_read_factory(), CollisionLine::register_with_read_factory(), CollisionInvSphere::register_with_read_factory(), CollisionFloorMesh::register_with_read_factory(), CollisionBox::register_with_read_factory(), JointVertexTransform::register_with_read_factory(), CharacterVertexSlider::register_with_read_factory(), CharacterSlider::register_with_read_factory(), CharacterJointEffect::register_with_read_factory(), CharacterJointBundle::register_with_read_factory(), CharacterJoint::register_with_read_factory(), Character::register_with_read_factory(), PartGroup::register_with_read_factory(), PartBundle::register_with_read_factory(), MovingPartScalar::register_with_read_factory(), MovingPartMatrix::register_with_read_factory(), AnimPreloadTable::register_with_read_factory(), AnimGroup::register_with_read_factory(), AnimChannelScalarTable::register_with_read_factory(), AnimChannelScalarDynamic::register_with_read_factory(), AnimChannelMatrixXfmTable::register_with_read_factory(), AnimChannelMatrixFixed::register_with_read_factory(), AnimChannelMatrixDynamic::register_with_read_factory(), AnimBundleNode::register_with_read_factory(), AnimBundle::register_with_read_factory(), and CFDoCullCommand::register_with_read_factory().

const FileReference * BamReader::get_file ( ) [inline]

Returns the FileReference that provides the source for these datagrams, if any, or NULL if the datagrams do not originate from a file on disk.

Definition at line 170 of file bamReader.I.

References DatagramGenerator::get_file().

BamReader::BamEndian BamReader::get_file_endian ( ) const [inline]

Returns the endian preference indicated by the Bam file currently being read.

This does not imply that every number is stored using the indicated convention, but individual objects may choose to respect this flag when recording data.

Definition at line 119 of file bamReader.I.

Referenced by BamFile::get_file_endian().

int BamReader::get_file_major_ver ( ) const [inline]

Returns the major version number of the Bam file currently being read.

Definition at line 94 of file bamReader.I.

Referenced by BamFile::get_file_major_ver().

int BamReader::get_file_minor_ver ( ) const [inline]
streampos BamReader::get_file_pos ( ) [inline]

Returns the current file position within the data stream, if any, or 0 if the file position is not meaningful or cannot be determined.

For BamReaders that return a meaningful file position, this will be pointing to the first byte following the datagram returned after a call to get_datagram().

Definition at line 201 of file bamReader.I.

References DatagramGenerator::get_file_pos().

bool BamReader::get_file_stdfloat_double ( ) const [inline]

Returns true if the file stores all "standard" floats as 64-bit doubles, or false if they are 32-bit floats.

This is determined by the compilation flags of the version of Panda that generated this file.

Definition at line 132 of file bamReader.I.

Referenced by BamFile::get_file_stdfloat_double().

const Filename & BamReader::get_filename ( ) const [inline]

If a BAM is a file, then the BamReader should contain the name of the file.

This enables the reader to interpret pathnames in the BAM as relative to the directory containing the BAM.

Definition at line 45 of file bamReader.I.

References DatagramGenerator::get_filename().

Referenced by Texture::make_this_from_bam(), and read_handle().

int BamReader::get_int_tag ( const string &  tag) const

Returns the value previously set via set_int_tag().

It is an error if no value has been set.

Definition at line 804 of file bamReader.cxx.

const LoaderOptions & BamReader::get_loader_options ( ) const [inline]

Returns the LoaderOptions passed to the loader when the model was requested, if any.

Definition at line 60 of file bamReader.I.

Referenced by Texture::make_this_from_bam().

void * BamReader::get_pta ( DatagramIterator scan)

This function works in conjection with register_pta(), below, to read a PointerToArray (PTA) from the Bam file, and unify references to the same PTA.

The first time get_pta() encounters a particular PTA, it will return NULL. This is the indication that the caller should then read in the data associated with the PTA, and subsequently call register_pta() with the address of the filled-in array.

The next time (and all subsequent times) that get_pta() encounters this same PTA, it will return the pointer that was passed with register_pta().

Also see the READ_PTA() macro, which consolidates all the work that must be done to read a PTA.

Definition at line 1019 of file bamReader.cxx.

DatagramGenerator * BamReader::get_source ( ) [inline]

Returns the current source of the BamReader as set by set_source() or the constructor.

Definition at line 32 of file bamReader.I.

VirtualFile * BamReader::get_vfile ( ) [inline]

Returns the VirtualFile that provides the source for these datagrams, if any, or NULL if the datagrams do not originate from a VirtualFile.

Definition at line 183 of file bamReader.I.

References DatagramGenerator::get_vfile().

bool BamReader::init ( )

Initializes the BamReader prior to reading any objects from its source.

This includes reading the Bam header.

This returns true if the BamReader successfully initialized, false otherwise.

Definition at line 94 of file bamReader.cxx.

References DatagramIterator::get_bool(), DatagramIterator::get_uint16(), and DatagramIterator::get_uint8().

Referenced by RecorderController::begin_playback(), CFChannel::CFChannel(), TypedWritable::decode_raw_from_bam_stream(), and set_source().

bool BamReader::is_eof ( ) const [inline]

Returns true if the reader has reached end-of-file, false otherwise.

This call is only valid after a call to read_object().

Definition at line 82 of file bamReader.I.

Referenced by BamFile::is_eof(), and RecorderController::play_frame().

void BamReader::read_cdata ( DatagramIterator scan,
PipelineCyclerBase cycler,
void *  extra_data 
)

This flavor of read_cdata allows passing an additional parameter to cdata->fillin().

Definition at line 763 of file bamReader.cxx.

References CycleData::fillin(), Thread::get_current_thread(), PipelineCyclerTrivialImpl::release_write(), and PipelineCyclerTrivialImpl::write().

void BamReader::read_cdata ( DatagramIterator scan,
PipelineCyclerBase cycler 
)
void BamReader::read_file_data ( SubfileInfo info)

Reads a block of auxiliary file data from the Bam file.

This can be a block of arbitrary size, and it is assumed it may be quite large. Rather than reading the entire block into memory, a file reference is returned to locate the block on disk. The data must have been written by a matching call to write_file_data().

Definition at line 725 of file bamReader.cxx.

Referenced by MovieVideo::fillin().

TypeHandle BamReader::read_handle ( DatagramIterator scan)
TypedWritable * BamReader::read_object ( )

Reads a single object from the Bam file.

If the object type is known, a new object of the appropriate type is created and returned; otherwise, NULL is returned. NULL is also returned when the end of the file is reached. is_eof() may be called to differentiate between these two cases.

This may be called repeatedly to extract out all the objects in the Bam file, but typically (especially for scene graph files, indicated with the .bam extension), only one object is retrieved directly from the Bam file: the root of the scene graph. The remaining objects will all be retrieved recursively by the first object.

Note that the object returned may not yet be complete. In particular, some of its pointers may not be filled in; you must call resolve() to fill in all the available pointers before you can safely use any objects returned by read_object().

This flavor of read_object() requires the caller to know what type of object it has received in order to properly manage the reference counts.

Definition at line 243 of file bamReader.cxx.

Referenced by RecorderController::begin_playback(), NodePath::decode_from_bam_stream(), TypedWritable::decode_raw_from_bam_stream(), and BamFile::read_object().

bool BamReader::read_object ( TypedWritable *&  ptr,
ReferenceCount *&  ref_ptr 
)

Reads a single object from the Bam file.

This flavor of read_object() returns both a TypedWritable and a ReferenceCount pointer to the same object, so the reference count may be tracked reliably, without having to know precisely what type of object we have. It returns true on success, or false on failure.

Definition at line 267 of file bamReader.cxx.

void BamReader::read_pointer ( DatagramIterator scan)

The interface for reading a pointer to another object from a Bam file.

Objects reading themselves from a Bam file should call this when they expect to read a pointer to some other object. This function reads whatever is stored in the bam file to represent the pointer, and advances the datagram iterator accordingly.

Rather than returning a pointer immediately, this function reads the internal pointer information from the datagram and queues up the request. The pointer itself may not be available until later (it may be a pointer to an object that appears later in the Bam file). Later, when all pointers are available, the complete_pointers() callback function will be called with an array of actual pointers, one for each time read_pointer() was called. It is then the calling object's responsibility to store these pointers in the object properly.

Definition at line 652 of file bamReader.cxx.

References Thread::consider_yield(), and get_file_minor_ver().

Referenced by TextureReference::fillin(), TextureProperties::fillin(), TexturePlacement::fillin(), SourceTextureImage::fillin(), Palettizer::fillin(), PalettePage::fillin(), PaletteImage::fillin(), EggFile::fillin(), RecorderFrame::fillin(), BamCacheIndex::fillin(), TextureAttrib::fillin(), TexMatrixAttrib::fillin(), TexGenAttrib::fillin(), RenderState::fillin(), RenderEffects::fillin(), OccluderEffect::fillin(), MaterialAttrib::fillin(), LensNode::fillin(), FogAttrib::fillin(), ClipPlaneAttrib::fillin(), PiecewiseCurve::fillin(), MovieVideoCursor::fillin(), TransformTable::fillin(), TransformBlend::fillin(), TextureStage::fillin(), SliderTable::fillin(), GeomVertexFormat::fillin(), GeomVertexColumn::fillin(), GeomVertexArrayData::fillin(), DataNodeTransmit::fillin(), CollisionNode::fillin(), JointVertexTransform::fillin(), CharacterVertexSlider::fillin(), CharacterJointEffect::fillin(), CharacterJoint::fillin(), Character::fillin(), PartGroup::fillin(), PartBundleNode::fillin(), PartBundle::fillin(), MovingPartBase::fillin(), AnimGroup::fillin(), AnimChannelScalarDynamic::fillin(), AnimChannelMatrixDynamic::fillin(), AnimBundleNode::fillin(), CFDoCullCommand::fillin(), and read_pointers().

void BamReader::read_pointers ( DatagramIterator scan,
int  count 
)

A convenience function to read a contiguous list of pointers.

This is equivalent to calling read_pointer() count times.

Definition at line 694 of file bamReader.cxx.

References read_pointer().

Referenced by TexturePlacement::fillin(), TextureImage::fillin(), Palettizer::fillin(), PalettePage::fillin(), PaletteImage::fillin(), PaletteGroups::fillin(), PaletteGroup::fillin(), EggFile::fillin(), and LightAttrib::fillin().

void BamReader::register_change_this ( ChangeThisRefFunc  func,
TypedWritableReferenceCount object 
)

Called by an object reading itself from the bam file to indicate that the object pointer that will be returned is temporary, and will eventually need to be replaced with another pointer.

The supplied function pointer will later be called on the object, immediately after complete_pointers() is called; it should return the new and final pointer.

We use a static function pointer instead of a virtual function (as in finalize()), to allow the function to destruct the old pointer if necessary. (It is invalid to destruct the this pointer within a virtual function.)

Definition at line 950 of file bamReader.cxx.

void BamReader::register_change_this ( ChangeThisFunc  func,
TypedWritable object 
)

Called by an object reading itself from the bam file to indicate that the object pointer that will be returned is temporary, and will eventually need to be replaced with another pointer.

The supplied function pointer will later be called on the object, immediately after complete_pointers() is called; it should return the new and final pointer.

We use a static function pointer instead of a virtual function (as in finalize()), to allow the function to destruct the old pointer if necessary. (It is invalid to destruct the this pointer within a virtual function.)

Definition at line 911 of file bamReader.cxx.

References TypedWritable::as_reference_count().

Referenced by RenderAttrib::fillin(), TransformState::make_from_bam(), RenderState::make_from_bam(), and RenderEffects::make_from_bam().

void BamReader::register_finalize ( TypedWritable whom)

Should be called by an object reading itself from the Bam file to indicate that this particular object would like to receive the finalize() callback when all the objects and pointers in the Bam file are completely read.

This provides a hook for objects that need to do any additional finalization work after all of their related pointers are guaranteed to be filled in.

Definition at line 880 of file bamReader.cxx.

Referenced by RenderState::change_this(), RenderEffects::change_this(), RenderEffect::change_this(), RenderAttrib::change_this(), GeomPrimitive::fillin(), CharacterJointBundle::make_CharacterJointBundle(), LightAttrib::make_from_bam(), GeomNode::make_from_bam(), InternalName::make_from_bam(), GeomVertexData::make_from_bam(), GeomVertexArrayFormat::make_from_bam(), GeomVertexArrayData::make_from_bam(), Geom::make_from_bam(), PartBundle::make_from_bam(), PaletteGroup::make_PaletteGroup(), Palettizer::make_Palettizer(), InternalName::make_texcoord_from_bam(), and Texture::make_this_from_bam().

void BamReader::register_pta ( void *  ptr)

The second part of read_pta(), this should be called with the pointer to the array that was read in after read_pta() returned NULL.

This associates the pointer with the ID that was previously read, so that future calls to read_pta() will return the same pointer.

Also see the READ_PTA() macro, which consolidates all the work that must be done to read a PTA.

Definition at line 1057 of file bamReader.cxx.

bool BamReader::resolve ( )

This may be called at any time during processing of the Bam file to resolve all the known pointers so far.

It is usually called at the end of the processing, after all objects have been read, which is generally the best time to call it.

This must be called at least once after reading a particular object via get_object() in order to validate that object.

The return value is true if all objects have been resolved, or false if some objects are still outstanding (in which case you will need to call resolve() again later).

Definition at line 353 of file bamReader.cxx.

References TypedWritable::as_reference_count().

Referenced by RecorderController::begin_playback(), NodePath::decode_from_bam_stream(), TypedWritable::decode_raw_from_bam_stream(), and BamFile::resolve().

void BamReader::set_aux_data ( TypedWritable obj,
const string &  name,
BamReader::AuxData data 
)

Associates an arbitrary block of data with the indicated object (or NULL), and the indicated name.

This is intended to provide a place for temporary storage for objects reading themselves from the bam file. To use it, inherit from BamReader::AuxData and store whatever data you like there. Then associate your AuxData with the object as it is being read with set_aux_data(). You may later set the aux data to NULL to remove it; or it will automatically be removed (and deleted) after finalize() is called for the object in question.

If the TypedWritable pointer is NULL, the the aux data is stored globally for the BamReader in general. This pointer is available to any bam objects, and will not be automatically removed until the BamReader itself destructs.

In either case, the name is just an arbitrary user-defined key. If there is already a data pointer stored for the obj/name pair, that data pointer will be replaced (and deleted).

Definition at line 176 of file bamReader.cxx.

Referenced by LightAttrib::fillin(), and GeomNode::finalize().

void BamReader::set_aux_tag ( const string &  tag,
BamReaderAuxData value 
)

Allows the creating object to store a temporary data value on the BamReader.

This method may be called during an object's fillin() method; it will associate a newly-allocated BamReaderAuxData construct with an arbitrary string key (which is in turn associated with the calling object only). Later, in the complete_pointers() method, the same object may query this data again via get_aux_tag().

The BamReader will maintain the reference count on the BamReaderAuxData, and destruct it when it is cleaned up.

The tag string need not be unique between different objects, but it should be unique between an object and its CData object(s).

Definition at line 838 of file bamReader.cxx.

void BamReader::set_int_tag ( const string &  tag,
int  value 
)

Allows the creating object to store a temporary data value on the BamReader.

This method may be called during an object's fillin() method; it will associate an integer value with an arbitrary string key (which is in turn associated with the calling object only). Later, in the complete_pointers() method, the same object may query this data again via get_int_tag().

The tag string need not be unique between different objects, but it should be unique between an object and its CData object(s).

Definition at line 789 of file bamReader.cxx.

void BamReader::set_loader_options ( const LoaderOptions options) [inline]

Specifies the LoaderOptions for this BamReader.

Definition at line 70 of file bamReader.I.

void BamReader::set_source ( DatagramGenerator source)

Changes the source of future datagrams for this BamReader.

This also implicitly calls init() if it has not already been called.

Definition at line 75 of file bamReader.cxx.

References init().

Referenced by NodePath::decode_from_bam_stream(), and TypedWritable::decode_raw_from_bam_stream().

void BamReader::skip_pointer ( DatagramIterator scan)

Reads and discards a pointer value from the Bam file.

This pointer will not be counted among the pointers read for a given object, and will not be in the list of pointers passed to complete_pointers().

Definition at line 709 of file bamReader.cxx.


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