Panda3D
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
TypedWritable Class Reference

Base class for objects that can be written to and read from Bam files. More...

#include "typedWritable.h"

Inheritance diagram for TypedWritable:
TypedObject MemoryBase BamCacheIndex DataNodeTransmit EggFile ImageFile PaletteGroup PaletteGroups PalettePage Palettizer PNMFileType RecorderFrame RecorderHeader RecorderTable TexturePlacement TexturePosition TextureProperties TextureReference TypedWritableReferenceCount WritableConfigurable

Public Member Functions

 TypedWritable (const TypedWritable &copy)
 
virtual ReferenceCountas_reference_count ()
 Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More...
 
virtual int complete_pointers (TypedWritable **p_list, BamReader *manager)
 Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). More...
 
vector_uchar encode_to_bam_stream () const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More...
 
bool encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More...
 
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 of the relevant data from the BamFile for the new object. More...
 
virtual void finalize (BamReader *manager)
 Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed. More...
 
virtual TypeHandle force_init_type ()
 
UpdateSeq get_bam_modified () const
 Returns the current bam_modified counter. More...
 
virtual TypeHandle get_type () const
 
void mark_bam_modified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More...
 
void operator= (const TypedWritable &copy)
 
virtual bool require_fully_complete () const
 Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. More...
 
virtual void update_bam_nested (BamWriter *manager)
 Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. More...
 
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file. More...
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
TypedObjectoperator= (const TypedObject &copy)=default
 

Static Public Member Functions

static bool decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr)
 Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes. More...
 
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 

Static Public Attributes

static TypedWritable *const Null = nullptr
 

Friends

class BamWriter
 

Additional Inherited Members

- Public Attributes inherited from TypedObject
 get_type
 

Detailed Description

Base class for objects that can be written to and read from Bam files.

See also TypedObject for detailed instructions.

Definition at line 35 of file typedWritable.h.

Member Function Documentation

◆ as_reference_count()

ReferenceCount * TypedWritable::as_reference_count ( )
virtual

Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type.

Reimplemented in TypedWritableReferenceCount.

Definition at line 121 of file typedWritable.cxx.

◆ complete_pointers()

int TypedWritable::complete_pointers ( TypedWritable **  p_list,
BamReader manager 
)
virtual

Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().

Returns the number of pointers processed.

This is the callback function that is made by the BamReader at some later point, after all of the required pointers have been filled in. It is necessary because there might be forward references in a bam file; when we call read_pointer() in fillin(), the object may not have been read from the file yet, so we do not have a pointer available at that time. Thus, instead of returning a pointer, read_pointer() simply reserves a later callback. This function provides that callback. The calling object is responsible for keeping track of the number of times it called read_pointer() and extracting the same number of pointers out of the supplied vector, and storing them appropriately within the object.

Reimplemented in GeomVertexData, RenderState, GeomVertexFormat, TextureStage, PartBundle, GeomVertexArrayData, TextureAttrib, BulletBodyNode, RenderEffects, GeomVertexArrayFormat, TextureImage, Character, LightAttrib, Palettizer, ClipPlaneAttrib, PortalNode, TransformBlendTable, Camera, MovieVideoCursor, PartGroup, TexGenAttrib, ParamTextureImage, TexturePlacement, PaletteImage, PaletteGroup, TextureReference, SliderTable, TexMatrixAttrib, EggFile, TexProjectorEffect, CollisionNode, MovingPartBase, TransformTable, CompassEffect, CharacterJoint, TextureProperties, BillboardEffect, OccluderNode, AnimChannelMatrixDynamic, LensNode, ImageFile, PaletteGroups, AnimGroup, PartBundleNode, AnimChannelScalarDynamic, OccluderEffect, CharacterJointEffect, PalettePage, BulletMinkowskiSumShape, BulletTriangleMeshShape, MaterialAttrib, FogAttrib, JointVertexTransform, DataNodeTransmit, RecorderFrame, SourceTextureImage, AnimBundleNode, ParamTextureSampler, CharacterVertexSlider, and ParamNodePath.

Definition at line 81 of file typedWritable.cxx.

Referenced by TextureProperties::complete_pointers(), TexturePlacement::complete_pointers(), and Palettizer::complete_pointers().

◆ decode_raw_from_bam_stream()

bool TypedWritable::decode_raw_from_bam_stream ( TypedWritable *&  ptr,
ReferenceCount *&  ref_ptr,
vector_uchar  data,
BamReader reader = nullptr 
)
static

Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes.

Returns true on success, false on error.

This variant sets the TypedWritable and ReferenceCount pointers separately; both are pointers to the same object. The reference count is not incremented; it is the caller's responsibility to manage the reference count.

Note that this method cannot be used to retrieve objects that do not inherit from ReferenceCount, because these objects cannot persist beyond the lifetime of the BamReader that reads them. To retrieve these objects from a bam stream, you must construct a BamReader directly.

If you happen to know that the particular object in question inherits from TypedWritableReferenceCount or PandaNode, consider calling the variant of decode_from_bam_stream() defined for those methods, which presents a simpler interface.

Definition at line 190 of file typedWritable.cxx.

◆ encode_to_bam_stream() [1/2]

vector_uchar TypedWritable::encode_to_bam_stream ( ) const
inline

Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object.

Returns an empty bytes object on failure.

This is a convenience method particularly useful for cases when you are only serializing a single object. If you have many objects to process, it is more efficient to use the same BamWriter to serialize all of them together.

Definition at line 67 of file typedWritable.I.

◆ encode_to_bam_stream() [2/2]

bool TypedWritable::encode_to_bam_stream ( vector_uchar &  data,
BamWriter writer = nullptr 
) const

Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string.

Returns true on success, false on failure.

This is a convenience method particularly useful for cases when you are only serializing a single object. If you have many objects to process, it is more efficient to use the same BamWriter to serialize all of them together.

Definition at line 136 of file typedWritable.cxx.

◆ fillin()

void TypedWritable::fillin ( DatagramIterator scan,
BamReader manager 
)
virtual

This internal function is intended to be called by each class's make_from_bam() method to read in all of the relevant data from the BamFile for the new object.

It is also called directly by the BamReader to re-read the data for an object that has been placed on the stream for an update.

Reimplemented in TextureProperties, PaletteGroups, AnimChannelMatrixDynamic, AnimChannelScalarDynamic, ButtonEventList, and TexturePosition.

Definition at line 103 of file typedWritable.cxx.

Referenced by TexturePosition::fillin(), ButtonEventList::fillin(), PaletteGroups::fillin(), and TextureProperties::fillin().

◆ finalize()

void TypedWritable::finalize ( BamReader manager)
virtual

Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.

Reimplemented in Texture, GeomVertexData, Geom, RenderState, GeomPrimitive, PartBundle, GeomVertexArrayData, RenderAttrib, GeomNode, FfmpegVideoCursor, RenderEffects, GeomVertexArrayFormat, LightAttrib, Palettizer, InternalName, ClipPlaneAttrib, PaletteGroup, and RenderEffect.

Definition at line 113 of file typedWritable.cxx.

Referenced by BamReader::finalize_now().

◆ get_bam_modified()

UpdateSeq TypedWritable::get_bam_modified ( ) const
inline

Returns the current bam_modified counter.

This counter is normally incremented automatically whenever the object is modified.

Definition at line 52 of file typedWritable.I.

Referenced by BamWriter::consider_update(), and BamWriter::write_pointer().

◆ mark_bam_modified()

void TypedWritable::mark_bam_modified ( )
inline

Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams.

This should normally not need to be called by user code; it should be called internally when the object has been changed in a way that legitimately requires its retransmission to any connected clients.

Definition at line 43 of file typedWritable.I.

◆ require_fully_complete()

bool TypedWritable::require_fully_complete ( ) const
virtual

Some objects require all of their nested pointers to have been completed before the objects themselves can be completed.

If this is the case, override this method to return true, and be careful with circular references (which would make the object unreadable from a bam file).

Reimplemented in GeomVertexData, BulletBodyNode, RenderEffects, OccluderEffect, and BulletMinkowskiSumShape.

Definition at line 92 of file typedWritable.cxx.

◆ update_bam_nested()

void TypedWritable::update_bam_nested ( BamWriter manager)
virtual

Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates.

Reimplemented in PandaNode.

Definition at line 62 of file typedWritable.cxx.

◆ write_datagram()

void TypedWritable::write_datagram ( BamWriter manager,
Datagram dg 
)
virtual

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

Reimplemented in Texture, PandaNode, Shader, TransformState, Lens, Geom, GeomVertexData, RenderState, GeomPrimitive, SpeedTreeNode, GeomVertexFormat, TextureStage, RopeNode, PartBundle, GeomVertexArrayData, RenderAttrib, LODNode, GeomNode, FfmpegVideoCursor, TextureAttrib, BulletBodyNode, RenderEffects, Material, GeomVertexArrayFormat, StencilAttrib, TextureImage, CollisionBox, Character, CollisionSolid, BulletRigidBodyNode, LightAttrib, CollisionPolygon, Palettizer, InternalName, ColorBlendAttrib, ClipPlaneAttrib, PortalNode, CollisionCapsule, TransformBlendTable, Camera, MovieVideoCursor, BulletDebugNode, ParamValue< Type >, PolylightNode, PartGroup, TexGenAttrib, BamCacheRecord, ParamTextureImage, TexturePlacement, PaletteImage, PaletteGroup, TextureReference, PlaneNode, DataNode, SliderTable, TexMatrixAttrib, Spotlight, EggFile, TexProjectorEffect, CollisionFloorMesh, CollisionNode, SheetNode, CollisionSphere, Fog, RenderModeAttrib, MovingPartBase, TransformTable, RenderEffect, DepthOffsetAttrib, ComputeNode, LightLensNode, AuxBitplaneAttrib, CompassEffect, PointLight, CollisionPlane, CharacterJoint, TextureProperties, BulletTriangleMesh, BillboardEffect, VertexTransform, OccluderNode, ScissorEffect, DirectionalLight, VertexSlider, LogicOpAttrib, CollisionParabola, LightRampAttrib, AntialiasAttrib, ColorScaleAttrib, RescaleNormalAttrib, AnimChannelMatrixXfmTable, CollisionSegment, AnimChannelMatrixDynamic, ScissorAttrib, TransparencyAttrib, MouseRecorder, ColorAttrib, CullFaceAttrib, ShaderBuffer, LensNode, ImageFile, AnimPreloadTable, CallbackNode, RectangleLight, PaletteGroups, AnimGroup, CollisionRay, MatrixLens, ModelNode, PartBundleNode, AudioVolumeAttrib, AnimChannelScalarDynamic, FadeLODNode, OccluderEffect, PNMFileType, CharacterJointEffect, CollisionInvSphere, SphereLight, SwitchNode, PalettePage, UserVertexTransform, ColorWriteAttrib, DepthWriteAttrib, ModelRoot, ShadeModelAttrib, UvScrollNode, BulletMinkowskiSumShape, BulletTriangleMeshShape, AlphaTestAttrib, CullBinAttrib, MaterialAttrib, BamCacheIndex, RecorderTable, UserVertexSlider, FogAttrib, BulletCapsuleShape, AnimChannelScalarTable, DepthTestAttrib, BulletPlaneShape, AnimBundle, WritableConfigurable, BulletBoxShape, ButtonEventList, BulletCylinderShape, BulletHeightfieldShape, BulletMultiSphereShape, MovieVideo, JointVertexTransform, DataNodeTransmit, RecorderFrame, SourceTextureImage, BulletConeShape, BulletSphereShape, AnimBundleNode, BulletConvexPointCloudShape, SequenceNode, AnimChannelBase, AnimChannelMatrixFixed, TexturePosition, BulletConvexHullShape, ParamTextureSampler, MovingPart< SwitchType >, GeomPatches, AmbientLight, MovingPart< ACScalarSwitchType >, MovingPart< ACMatrixSwitchType >, CollisionLine, ShowBoundsEffect, LightNode, DestTextureImage, CharacterVertexSlider, RecorderHeader, ParamNodePath, FfmpegVideo, and DecalEffect.

Definition at line 54 of file typedWritable.cxx.

Referenced by ParamNodePath::write_datagram(), RecorderHeader::write_datagram(), ParamTextureSampler::write_datagram(), BulletConvexHullShape::write_datagram(), TexturePosition::write_datagram(), BulletConvexPointCloudShape::write_datagram(), BulletConeShape::write_datagram(), BulletSphereShape::write_datagram(), RecorderFrame::write_datagram(), DataNodeTransmit::write_datagram(), BulletMultiSphereShape::write_datagram(), BulletCylinderShape::write_datagram(), BulletHeightfieldShape::write_datagram(), MovieVideo::write_datagram(), BulletBoxShape::write_datagram(), ButtonEventList::write_datagram(), BulletPlaneShape::write_datagram(), BulletCapsuleShape::write_datagram(), BamCacheIndex::write_datagram(), RecorderTable::write_datagram(), BulletMinkowskiSumShape::write_datagram(), BulletTriangleMeshShape::write_datagram(), PalettePage::write_datagram(), PaletteGroups::write_datagram(), ImageFile::write_datagram(), VertexSlider::write_datagram(), VertexTransform::write_datagram(), TextureProperties::write_datagram(), RenderEffect::write_datagram(), TransformTable::write_datagram(), EggFile::write_datagram(), SliderTable::write_datagram(), PaletteGroup::write_datagram(), TextureReference::write_datagram(), TexturePlacement::write_datagram(), ParamTextureImage::write_datagram(), BamCacheRecord::write_datagram(), ParamValue< Type >::write_datagram(), MovieVideoCursor::write_datagram(), TransformBlendTable::write_datagram(), Palettizer::write_datagram(), GeomVertexArrayFormat::write_datagram(), RenderEffects::write_datagram(), GeomVertexArrayData::write_datagram(), RenderAttrib::write_datagram(), GeomVertexFormat::write_datagram(), GeomPrimitive::write_datagram(), RenderState::write_datagram(), GeomVertexData::write_datagram(), Geom::write_datagram(), Lens::write_datagram(), and PandaNode::write_datagram().


The documentation for this class was generated from the following files: