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. 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... | |
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. More... | |
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. 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 ©) |
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... | |
![]() | |
TypedObject (const TypedObject ©) | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_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... | |
void | operator= (const TypedObject ©) |
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. More... | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
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 = (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 37 of file typedWritable.h.
|
virtual |
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type.
Reimplemented in TypedWritableReferenceCount.
Definition at line 149 of file typedWritable.cxx.
References encode_to_bam_stream().
Referenced by BamReader::change_pointer(), finalize(), BamReader::register_change_this(), BamReader::register_pta(), and BamReader::resolve().
|
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, FINAL, TextureStage, PartBundle, GeomVertexArrayData, RenderEffects, TextureAttrib, FINAL, TextureImage, Character, Palettizer, LightAttrib, ClipPlaneAttrib, PortalNode, TransformBlendTable, MovieVideoCursor, TexGenAttrib, PartGroup, TexturePlacement, PaletteImage, PaletteGroup, ParamTextureImage, TextureReference, TexProjectorEffect, SliderTable, TexMatrixAttrib, EggFile, MovingPartBase, CollisionNode, TransformTable, TextureProperties, CharacterJoint, OccluderNode, AnimChannelMatrixDynamic, LensNode, ImageFile, PaletteGroups, CFDoCullCommand, AnimGroup, OccluderEffect, PartBundleNode, AnimChannelScalarDynamic, PalettePage, CharacterJointEffect, JointVertexTransform, MaterialAttrib, FogAttrib, DataNodeTransmit, RecorderFrame, SourceTextureImage, AnimBundleNode, ParamTextureSampler, ParamNodePath, and CharacterVertexSlider.
Definition at line 97 of file typedWritable.cxx.
References require_fully_complete().
Referenced by CharacterVertexSlider::complete_pointers(), ParamNodePath::complete_pointers(), ParamTextureSampler::complete_pointers(), AnimBundleNode::complete_pointers(), DataNodeTransmit::complete_pointers(), RecorderFrame::complete_pointers(), FogAttrib::complete_pointers(), MaterialAttrib::complete_pointers(), JointVertexTransform::complete_pointers(), CharacterJointEffect::complete_pointers(), PalettePage::complete_pointers(), PartBundleNode::complete_pointers(), OccluderEffect::complete_pointers(), CFDoCullCommand::complete_pointers(), PaletteGroups::complete_pointers(), ImageFile::complete_pointers(), LensNode::complete_pointers(), OccluderNode::complete_pointers(), TextureProperties::complete_pointers(), TransformTable::complete_pointers(), CollisionNode::complete_pointers(), EggFile::complete_pointers(), TexMatrixAttrib::complete_pointers(), SliderTable::complete_pointers(), TexProjectorEffect::complete_pointers(), ParamTextureImage::complete_pointers(), TextureReference::complete_pointers(), PaletteGroup::complete_pointers(), TexturePlacement::complete_pointers(), PartGroup::complete_pointers(), TexGenAttrib::complete_pointers(), MovieVideoCursor::complete_pointers(), TransformBlendTable::complete_pointers(), ClipPlaneAttrib::complete_pointers(), LightAttrib::complete_pointers(), Palettizer::complete_pointers(), TextureAttrib::complete_pointers(), RenderEffects::complete_pointers(), GeomVertexArrayData::complete_pointers(), TextureStage::complete_pointers(), RenderState::complete_pointers(), GeomVertexData::complete_pointers(), PiecewiseCurve::rebuild_curveseg(), update_bam_nested(), and BamCacheIndex::write_datagram().
|
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 238 of file typedWritable.cxx.
References AtomicAdjustDummyImpl::get_ptr(), BamReader::init(), DatagramInputFile::open(), DatagramInputFile::read_header(), BamReader::read_object(), ReferenceCount::ref(), BamReader::resolve(), BamReader::set_source(), and ReferenceCount::unref().
Referenced by TypedWritableReferenceCount::as_reference_count(), encode_to_bam_stream(), and PandaNode::is_ambient_light().
|
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.
Referenced by as_reference_count(), and get_bam_modified().
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 168 of file typedWritable.cxx.
References decode_raw_from_bam_stream(), BamWriter::init(), DatagramOutputFile::open(), BamWriter::set_target(), DatagramOutputFile::write_header(), and BamWriter::write_object().
|
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 127 of file typedWritable.cxx.
References finalize().
Referenced by ParamNodePath::complete_pointers(), ParamTextureSampler::complete_pointers(), DataNodeTransmit::complete_pointers(), RecorderFrame::complete_pointers(), PalettePage::complete_pointers(), CFDoCullCommand::complete_pointers(), ImageFile::complete_pointers(), TransformTable::complete_pointers(), EggFile::complete_pointers(), SliderTable::complete_pointers(), TextureReference::complete_pointers(), ParamTextureImage::complete_pointers(), TexturePlacement::complete_pointers(), MovieVideoCursor::complete_pointers(), TransformBlendTable::complete_pointers(), TexturePosition::fillin(), ButtonEventList::fillin(), PaletteGroups::fillin(), TextureProperties::fillin(), RenderEffect::finalize(), PaletteGroup::finalize(), Palettizer::finalize(), RenderEffects::finalize(), GeomVertexArrayData::finalize(), RenderAttrib::finalize(), GeomPrimitive::finalize(), RenderState::finalize(), GeomVertexData::finalize(), Geom::finalize(), require_fully_complete(), RecorderHeader::write_datagram(), MovieVideo::write_datagram(), RecorderTable::write_datagram(), BamCacheIndex::write_datagram(), VertexSlider::write_datagram(), VertexTransform::write_datagram(), BamCacheRecord::write_datagram(), ParamValue< Type >::write_datagram(), Lens::write_datagram(), and PandaNode::write_recorder().
|
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, Geom, GeomVertexData, RenderState, GeomPrimitive, RenderAttrib, PartBundle, GeomVertexArrayData, GeomNode, FfmpegVideoCursor, RenderEffects, FINAL, Palettizer, FINAL, LightAttrib, PaletteGroup, and RenderEffect.
Definition at line 139 of file typedWritable.cxx.
References as_reference_count().
Referenced by fillin(), and BamReader::finalize_now().
|
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.
References encode_to_bam_stream().
Referenced by BamWriter::consider_update(), mark_bam_modified(), BamWriter::write_handle(), and BamWriter::write_pointer().
|
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.
References get_bam_modified().
Referenced by PandaNode::add_stashed(), PandaNode::adjust_draw_mask(), PandaNode::apply_attribs_to_vertices(), PandaNode::clear_attrib(), PandaNode::clear_bounds(), PandaNode::clear_effect(), PandaNode::clear_tag(), PandaNode::copy_all_properties(), PandaNode::copy_tags(), PandaNode::is_ambient_light(), PandaNode::make_copy(), PandaNode::r_prepare_scene(), 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_effect(), PandaNode::set_effects(), PandaNode::set_into_collide_mask(), PandaNode::set_prev_transform(), PandaNode::set_state(), PandaNode::set_tag(), PandaNode::set_transform(), ParamValue< Type >::set_value(), PandaNode::stash_child(), and PandaNode::unstash_child().
|
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 112 of file typedWritable.cxx.
References fillin().
Referenced by complete_pointers().
|
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 71 of file typedWritable.cxx.
References complete_pointers().
Referenced by write_datagram().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented in Texture, PandaNode, Shader, FINAL, Lens, Geom, GeomVertexData, RenderState, GeomPrimitive, SpeedTreeNode, FINAL, TextureStage, RopeNode, RenderAttrib, PartBundle, GeomVertexArrayData, GeomNode, LODNode, FfmpegVideoCursor, RenderEffects, TextureAttrib, FINAL, StencilAttrib, TextureImage, Character, CollisionSolid, Palettizer, FINAL, LightAttrib, CollisionBox, CollisionPolygon, ClipPlaneAttrib, PortalNode, TransformBlendTable, MovieVideoCursor, ParamValue< Type >, TexGenAttrib, PolylightNode, PartGroup, CollisionTube, DataNode, TexturePlacement, Camera, PaletteImage, ColorBlendAttrib, PaletteGroup, ParamTextureImage, PlaneNode, TextureReference, TexProjectorEffect, BamCacheRecord, SliderTable, TexMatrixAttrib, EggFile, SheetNode, Material, RenderEffect, Spotlight, MovingPartBase, CollisionFloorMesh, CompassEffect, Fog, CollisionSphere, AuxBitplaneAttrib, DepthOffsetAttrib, CollisionNode, TransformTable, RenderModeAttrib, TextureProperties, ComputeNode, CharacterJoint, ScissorEffect, VertexTransform, BillboardEffect, CollisionPlane, VertexSlider, LightRampAttrib, OccluderNode, DirectionalLight, PointLight, CollisionParabola, ColorScaleAttrib, TransparencyAttrib, MouseRecorder, AnimChannelMatrixDynamic, AnimChannelMatrixXfmTable, AnimPreloadTable, CollisionSegment, AntialiasAttrib, LensNode, ScissorAttrib, ImageFile, PaletteGroups, ModelNode, RescaleNormalAttrib, CFDoCullCommand, CollisionRay, ColorAttrib, AnimGroup, CallbackNode, CullFaceAttrib, OccluderEffect, PartBundleNode, AnimChannelScalarDynamic, CollisionInvSphere, AudioVolumeAttrib, PalettePage, CharacterJointEffect, UserVertexTransform, LightLensNode, PNMFileType, FadeLODNode, SwitchNode, WritableConfigurable, JointVertexTransform, ColorWriteAttrib, ModelRoot, ShadeModelAttrib, BamCacheIndex, RecorderTable, UserVertexSlider, DepthWriteAttrib, AlphaTestAttrib, MaterialAttrib, UvScrollNode, CullBinAttrib, AnimChannelScalarTable, ButtonEventList, FogAttrib, DepthTestAttrib, DataNodeTransmit, MovieVideo, RecorderFrame, AnimBundle, SourceTextureImage, AnimChannelBase, SequenceNode, AnimBundleNode, TexturePosition, AnimChannelMatrixFixed, MovingPart< SwitchType >, GeomPatches, AmbientLight, MovingPart< ACScalarSwitchType >, MovingPart< ACMatrixSwitchType >, CollisionLine, ShowBoundsEffect, ParamTextureSampler, DestTextureImage, ParamNodePath, LightNode, CharacterVertexSlider, RecorderHeader, FfmpegVideo, and DecalEffect.
Definition at line 60 of file typedWritable.cxx.
References update_bam_nested().
Referenced by RecorderHeader::write_datagram(), ParamNodePath::write_datagram(), ParamTextureSampler::write_datagram(), TexturePosition::write_datagram(), DataNodeTransmit::write_datagram(), MovieVideo::write_datagram(), RecorderFrame::write_datagram(), ButtonEventList::write_datagram(), RecorderTable::write_datagram(), BamCacheIndex::write_datagram(), PalettePage::write_datagram(), CFDoCullCommand::write_datagram(), PaletteGroups::write_datagram(), ImageFile::write_datagram(), VertexSlider::write_datagram(), VertexTransform::write_datagram(), TextureProperties::write_datagram(), TransformTable::write_datagram(), RenderEffect::write_datagram(), EggFile::write_datagram(), SliderTable::write_datagram(), BamCacheRecord::write_datagram(), ParamTextureImage::write_datagram(), TextureReference::write_datagram(), PaletteGroup::write_datagram(), TexturePlacement::write_datagram(), ParamValue< Type >::write_datagram(), MovieVideoCursor::write_datagram(), TransformBlendTable::write_datagram(), Palettizer::write_datagram(), RenderEffects::write_datagram(), GeomVertexArrayData::write_datagram(), RenderAttrib::write_datagram(), GeomPrimitive::write_datagram(), RenderState::write_datagram(), GeomVertexData::write_datagram(), Geom::write_datagram(), Lens::write_datagram(), and PandaNode::write_datagram().