Panda3D
Loading...
Searching...
No Matches
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 PNMFileType PaletteGroup PaletteGroups PalettePage Palettizer 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.
 
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().
 
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.
 
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.
 
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.
 
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.
 
virtual TypeHandle force_init_type ()
 
UpdateSeq get_bam_modified () const
 Returns the current bam_modified counter.
 
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.
 
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.
 
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.
 
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer.
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer.
 
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.
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly.
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type.
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from MemoryBase
void operator delete (void *, void *)
 
void operator delete (void *ptr)
 
void operator delete[] (void *, void *)
 
void operator delete[] (void *ptr)
 
void * operator new (size_t size)
 
void * operator new (size_t size, void *ptr)
 
void * operator new[] (size_t size)
 
void * operator new[] (size_t size, void *ptr)
 

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.
 
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.
 

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.

Constructor & Destructor Documentation

◆ TypedWritable() [1/2]

TypedWritable::TypedWritable ( )
inline

Definition at line 17 of file typedWritable.I.

◆ TypedWritable() [2/2]

TypedWritable::TypedWritable ( const TypedWritable & copy)
inline

Definition at line 24 of file typedWritable.I.

◆ ~TypedWritable()

TypedWritable::~TypedWritable ( )
virtual

Definition at line 27 of file typedWritable.cxx.

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 120 of file typedWritable.cxx.

Referenced by BamReader::change_pointer(), BamReader::register_change_this(), and BamReader::resolve().

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

Definition at line 80 of file typedWritable.cxx.

Referenced by AnimBundleNode::complete_pointers(), PartBundleNode::complete_pointers(), PartGroup::complete_pointers(), EggFile::complete_pointers(), ImageFile::complete_pointers(), PaletteGroup::complete_pointers(), PaletteGroups::complete_pointers(), PalettePage::complete_pointers(), Palettizer::complete_pointers(), TexturePlacement::complete_pointers(), TextureProperties::complete_pointers(), TextureReference::complete_pointers(), BulletBodyNode::complete_pointers(), BulletMinkowskiSumShape::complete_pointers(), BulletTriangleMeshShape::complete_pointers(), CharacterJointEffect::complete_pointers(), CharacterVertexSlider::complete_pointers(), JointVertexTransform::complete_pointers(), CollisionNode::complete_pointers(), DataNodeTransmit::complete_pointers(), GeomVertexArrayData::complete_pointers(), GeomVertexArrayFormat::complete_pointers(), GeomVertexData::complete_pointers(), GeomVertexFormat::complete_pointers(), ParamTextureSampler::complete_pointers(), ParamTextureImage::complete_pointers(), SliderTable::complete_pointers(), TextureStage::complete_pointers(), TransformBlendTable::complete_pointers(), TransformTable::complete_pointers(), MovieVideoCursor::complete_pointers(), BillboardEffect::complete_pointers(), ClipPlaneAttrib::complete_pointers(), CompassEffect::complete_pointers(), FogAttrib::complete_pointers(), LensNode::complete_pointers(), LightAttrib::complete_pointers(), MaterialAttrib::complete_pointers(), OccluderEffect::complete_pointers(), OccluderNode::complete_pointers(), ParamNodePath::complete_pointers(), PortalNode::complete_pointers(), RenderEffects::complete_pointers(), RenderState::complete_pointers(), TexGenAttrib::complete_pointers(), TexMatrixAttrib::complete_pointers(), TexProjectorEffect::complete_pointers(), TextureAttrib::complete_pointers(), and RecorderFrame::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 189 of file typedWritable.cxx.

References BamReader::init(), DatagramBuffer::read_header(), BamReader::read_object(), ReferenceCount::ref(), BamReader::resolve(), BamReader::set_source, and ReferenceCount::unref().

Referenced by PT().

◆ 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 66 of file typedWritable.I.

References encode_to_bam_stream().

Referenced by encode_to_bam_stream().

◆ 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 135 of file typedWritable.cxx.

References BamWriter::init(), BamWriter::set_target, DatagramBuffer::swap_data(), DatagramBuffer::write_header(), and BamWriter::write_object().

◆ 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 AnimChannelMatrixDynamic, AnimChannelScalarDynamic, ButtonEventList, PaletteGroups, TexturePosition, and TextureProperties.

Definition at line 102 of file typedWritable.cxx.

Referenced by ButtonEventList::fillin(), PaletteGroups::fillin(), TexturePosition::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 PartBundle, FfmpegVideoCursor, Geom, GeomPrimitive, GeomVertexArrayData, GeomVertexArrayFormat, GeomVertexData, InternalName, Texture, ClipPlaneAttrib, GeomNode, LightAttrib, RenderAttrib, RenderEffect, RenderEffects, RenderState, PaletteGroup, and Palettizer.

Definition at line 112 of file typedWritable.cxx.

Referenced by BamReader::finalize_now().

◆ force_init_type()

virtual TypeHandle TypedWritable::force_init_type ( )
inlinevirtual

Implements TypedObject.

Definition at line 101 of file typedWritable.h.

◆ 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 51 of file typedWritable.I.

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

◆ get_class_type()

static TypeHandle TypedWritable::get_class_type ( )
inlinestatic

Definition at line 89 of file typedWritable.h.

◆ get_type()

virtual TypeHandle TypedWritable::get_type ( ) const
inlinevirtual

Implements TypedObject.

Definition at line 98 of file typedWritable.h.

◆ init_type()

static void TypedWritable::init_type ( )
inlinestatic

Definition at line 92 of file typedWritable.h.

◆ 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 42 of file typedWritable.I.

Referenced by PandaNode::add_stashed(), PandaNode::adjust_draw_mask(), PandaNode::apply_attribs_to_vertices(), PandaNode::clear_attrib(), PandaNode::clear_effect(), PandaNode::copy_all_properties(), PandaNode::copy_tags(), PandaNode::remove_all_children(), PandaNode::remove_child(), PandaNode::remove_stashed(), PandaNode::reset_all_prev_transform(), PandaNode::reset_prev_transform(), PandaNode::set_attrib(), PandaNode::set_bounds(), PandaNode::set_effect(), PandaNode::set_prev_transform(), PandaNode::stash_child(), and PandaNode::unstash_child().

◆ operator=()

void TypedWritable::operator= ( const TypedWritable & copy)
inline

Definition at line 31 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 BulletBodyNode, BulletMinkowskiSumShape, GeomVertexData, OccluderEffect, and RenderEffects.

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

Definition at line 53 of file typedWritable.cxx.

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

Friends And Related Symbol Documentation

◆ BamWriter

friend class BamWriter
friend

Definition at line 109 of file typedWritable.h.

Member Data Documentation

◆ Null

TypedWritable *const TypedWritable::Null = nullptr
static

Definition at line 37 of file typedWritable.h.


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