Panda3D
|
Base class for objects that can be written to and read from Bam files. More...
#include "typedWritable.h"
Public Member Functions | |
TypedWritable (const TypedWritable ©) | |
virtual ReferenceCount * | as_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(). | |
string | encode_to_bam_stream () const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string. | |
bool | encode_to_bam_stream (string &data, BamWriter *writer=NULL) 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 ©) |
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. | |
Static Public Member Functions | |
static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, const string &data, BamReader *reader=NULL) |
Reads the string created by a previous call to encode_to_bam_stream(), and extracts the single object on that string. | |
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 = (TypedWritable*)0L |
Friends | |
class | BamWriter |
Base class for objects that can be written to and read from Bam files.
See also TypedObject for detailed instructions.
Definition at line 38 of file typedWritable.h.
ReferenceCount * TypedWritable::as_reference_count | ( | ) | [virtual] |
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type.
Reimplemented in PandaNode, and TypedWritableReferenceCount.
Definition at line 155 of file typedWritable.cxx.
Referenced by BamReader::change_pointer(), BamReader::register_change_this(), and BamReader::resolve().
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, RenderEffects, TextureImage, TextureAttrib, Character, GeomVertexArrayFormat, Palettizer, LightAttrib, TexGenAttrib, ClipPlaneAttrib, PortalNode, TransformBlendTable, MovieVideoCursor, PartGroup, TexturePlacement, PaletteImage, PaletteGroup, TextureReference, SliderTable, TexMatrixAttrib, TexProjectorEffect, EggFile, MovingPartBase, PiecewiseCurve, CollisionNode, TransformTable, TextureProperties, CharacterJoint, OccluderNode, AnimChannelMatrixDynamic, LensNode, ImageFile, PaletteGroups, CFDoCullCommand, AnimGroup, PartBundleNode, OccluderEffect, PalettePage, AnimChannelScalarDynamic, CharacterJointEffect, BamCacheIndex, JointVertexTransform, MaterialAttrib, FogAttrib, DataNodeTransmit, RecorderFrame, SourceTextureImage, AnimBundleNode, and CharacterVertexSlider.
Definition at line 103 of file typedWritable.cxx.
bool TypedWritable::decode_raw_from_bam_stream | ( | TypedWritable *& | ptr, |
ReferenceCount *& | ref_ptr, | ||
const string & | data, | ||
BamReader * | reader = NULL |
||
) | [static] |
Reads the string created by a previous call to encode_to_bam_stream(), and extracts the single object on that string.
Returns true on success, false on 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 353 of file typedWritable.cxx.
References BamReader::init(), DatagramInputFile::open(), DatagramInputFile::read_header(), BamReader::read_object(), ReferenceCount::ref(), BamReader::resolve(), BamReader::set_source(), and ReferenceCount::unref().
string 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 string string.
Returns empty string 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 86 of file typedWritable.I.
bool TypedWritable::encode_to_bam_stream | ( | string & | data, |
BamWriter * | writer = NULL |
||
) | 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 283 of file typedWritable.cxx.
References BamWriter::init(), DatagramOutputFile::open(), BamWriter::set_target(), DatagramOutputFile::write_header(), and BamWriter::write_object().
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 PandaNode, TransformState, Lens, GeomVertexData, Geom, RenderState, GeomPrimitive, SpeedTreeNode, GeomVertexFormat, TextureStage, RopeNode, RenderAttrib, PartBundle, GeomVertexArrayData, LODNode, GeomNode, RenderEffects, StencilAttrib, EventStoreValue< Type >, TextureImage, GeomVertexArrayFormat, TextureAttrib, Character, HermiteCurve, Palettizer, CollisionSolid, LightAttrib, ParametricCurve, CollisionBox, CollisionPolygon, TexGenAttrib, ClipPlaneAttrib, PortalNode, TransformBlendTable, MovieVideoCursor, PolylightNode, PartGroup, TexturePlacement, CollisionTube, DataNode, PaletteImage, CubicCurveseg, NurbsCurve, PaletteGroup, ColorBlendAttrib, TextureReference, Camera, PlaneNode, SliderTable, TexMatrixAttrib, TexProjectorEffect, BamCacheRecord, EggFile, SheetNode, Material, RenderEffect, Spotlight, MovingPartBase, CompassEffect, Fog, CollisionSphere, AuxBitplaneAttrib, TextureProperties, CollisionNode, TransformTable, CharacterJoint, CollisionFloorMesh, PiecewiseCurve, BillboardEffect, RenderModeAttrib, CollisionPlane, VertexTransform, ScissorEffect, DepthOffsetAttrib, OccluderNode, VertexSlider, LightRampAttrib, DirectionalLight, PointLight, CollisionParabola, ColorScaleAttrib, TransparencyAttrib, MouseRecorder, PaletteGroups, AnimChannelMatrixXfmTable, LensNode, ImageFile, AnimPreloadTable, CollisionSegment, AntialiasAttrib, CFDoCullCommand, AnimChannelMatrixDynamic, AnimGroup, CollisionRay, ModelNode, RescaleNormalAttrib, ColorAttrib, OccluderEffect, ScissorAttrib, CallbackNode, PartBundleNode, CullFaceAttrib, PalettePage, CharacterJointEffect, CollisionInvSphere, AudioVolumeAttrib, AnimChannelScalarDynamic, UserVertexTransform, JointVertexTransform, FadeLODNode, SwitchNode, BamCacheIndex, ColorWriteAttrib, ShadeModelAttrib, LightLensNode, UserVertexSlider, DepthWriteAttrib, MaterialAttrib, AlphaTestAttrib, AnimChannelScalarTable, ButtonEventList, CullBinAttrib, FogAttrib, ModelRoot, UvScrollNode, DataNodeTransmit, DepthTestAttrib, RecorderFrame, RecorderTable, SourceTextureImage, AnimBundle, MovieVideo, AnimBundleNode, TexturePosition, AnimChannelBase, AnimChannelMatrixFixed, SequenceNode, MovingPart< SwitchType >, AmbientLight, MovingPart< ACScalarSwitchType >, MovingPart< ACMatrixSwitchType >, CollisionLine, ShowBoundsEffect, DestTextureImage, CharacterVertexSlider, LightNode, RecorderHeader, and DecalEffect.
Definition at line 133 of file typedWritable.cxx.
Referenced by EventStoreValue< Type >::fillin().
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, RenderAttrib, PartBundle, GeomVertexArrayData, GeomNode, RenderEffects, GeomVertexArrayFormat, Palettizer, LightAttrib, InternalName, PaletteGroup, and RenderEffect.
Definition at line 145 of file typedWritable.cxx.
Referenced by BamReader::finalize_now().
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 66 of file typedWritable.I.
Referenced by BamWriter::consider_update(), and BamWriter::write_pointer().
static void TypedWritable::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from TypedObject.
Reimplemented in Palettizer, TexturePlacement, PaletteImage, TextureReference, TextureProperties, PaletteGroups, ImageFile, PNMFileType, BamCacheIndex, WritableConfigurable, DataNodeTransmit, RecorderFrame, RecorderTable, SourceTextureImage, TexturePosition, DestTextureImage, and RecorderHeader.
Definition at line 94 of file typedWritable.h.
References TypedObject::init_type(), TypeRegistry::ptr(), and TypeRegistry::record_alternate_name().
Referenced by RecorderHeader::init_type(), RecorderTable::init_type(), RecorderFrame::init_type(), DataNodeTransmit::init_type(), WritableConfigurable::init_type(), BamCacheIndex::init_type(), and PNMFileType::init_type().
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 54 of file typedWritable.I.
Referenced by PandaNode::add_child(), PandaNode::add_stashed(), PandaNode::adjust_draw_mask(), PandaNode::apply_attribs_to_vertices(), PandaNode::clear_attrib(), PandaNode::clear_effect(), PandaNode::clear_tag(), PandaNode::copy_all_properties(), PandaNode::copy_tags(), PandaNode::disable_cull_callback(), PandaNode::force_bounds_stale(), 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_bounds_type(), PandaNode::set_cull_callback(), PandaNode::set_effect(), PandaNode::set_effects(), PandaNode::set_final(), PandaNode::set_internal_bounds(), PandaNode::set_into_collide_mask(), PandaNode::set_prev_transform(), PandaNode::set_state(), PandaNode::set_tag(), PandaNode::set_transform(), PandaNode::stash_child(), and PandaNode::unstash_child().
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, RenderEffects, ClipPlaneAttrib, and OccluderEffect.
Definition at line 118 of file typedWritable.cxx.
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, and CFDoCullCommand.
Definition at line 77 of file typedWritable.cxx.
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, TransformState, Lens, Geom, GeomVertexData, RenderState, GeomPrimitive, SpeedTreeNode, GeomVertexFormat, TextureStage, RopeNode, RenderAttrib, PartBundle, GeomVertexArrayData, LODNode, GeomNode, StencilAttrib, EventStoreValue< Type >, RenderEffects, TextureImage, HermiteCurve, TextureAttrib, GeomVertexArrayFormat, Character, CollisionSolid, ParametricCurve, Palettizer, LightAttrib, CollisionBox, CollisionPolygon, TexGenAttrib, ClipPlaneAttrib, PortalNode, TransformBlendTable, MovieVideoCursor, PolylightNode, PartGroup, CollisionTube, CubicCurveseg, DataNode, InternalName, NurbsCurve, TexturePlacement, PaletteImage, ColorBlendAttrib, PaletteGroup, Camera, PlaneNode, TextureReference, SliderTable, TexMatrixAttrib, TexProjectorEffect, BamCacheRecord, EggFile, SheetNode, Material, RenderEffect, CollisionFloorMesh, Spotlight, MovingPartBase, CompassEffect, Fog, CollisionSphere, AuxBitplaneAttrib, PiecewiseCurve, CollisionNode, TransformTable, TextureProperties, CharacterJoint, VertexTransform, BillboardEffect, RenderModeAttrib, ScissorEffect, CollisionPlane, VertexSlider, DepthOffsetAttrib, LightRampAttrib, OccluderNode, DirectionalLight, PointLight, CollisionParabola, ColorScaleAttrib, TransparencyAttrib, AnimChannelMatrixDynamic, AnimChannelMatrixXfmTable, MouseRecorder, AnimPreloadTable, CollisionSegment, AntialiasAttrib, LensNode, ImageFile, PaletteGroups, CollisionRay, ModelNode, RescaleNormalAttrib, CFDoCullCommand, ColorAttrib, ScissorAttrib, AnimGroup, CallbackNode, CullFaceAttrib, OccluderEffect, PartBundleNode, AnimChannelScalarDynamic, CollisionInvSphere, AudioVolumeAttrib, PalettePage, CharacterJointEffect, UserVertexTransform, PNMFileType, FadeLODNode, SwitchNode, WritableConfigurable, JointVertexTransform, ColorWriteAttrib, ShadeModelAttrib, LightLensNode, BamCacheIndex, UserVertexSlider, DepthWriteAttrib, AlphaTestAttrib, MaterialAttrib, CullBinAttrib, AnimChannelScalarTable, ModelRoot, ButtonEventList, FogAttrib, UvScrollNode, MovieVideo, DepthTestAttrib, RecorderTable, DataNodeTransmit, RecorderFrame, AnimBundle, SourceTextureImage, AnimChannelBase, AnimChannelMatrixFixed, SequenceNode, AnimBundleNode, TexturePosition, MovingPart< SwitchType >, AmbientLight, MovingPart< ACScalarSwitchType >, MovingPart< ACMatrixSwitchType >, CollisionLine, ShowBoundsEffect, DestTextureImage, LightNode, CharacterVertexSlider, RecorderHeader, and DecalEffect.
Definition at line 66 of file typedWritable.cxx.
Referenced by EventStoreValue< Type >::write_datagram(), and GeomPrimitive::write_datagram().