Panda3D
|
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by a BamReader. More...
Public Member Functions | |
__init__ (DatagramSink target) | |
flush () | |
Ensures that all data written thus far is manifested on the output stream. More... | |
BamEnums::BamEndian | getFileEndian () |
Returns the endian preference indicated by the Bam file currently being written. 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. More... | |
const Filename | getFilename () |
If a BAM is a file, then the BamWriter should contain the name of the file. This enables the writer to convert pathnames in the BAM to relative to the directory containing the BAM. More... | |
bool | getFileStdfloatDouble () |
Returns true if the file will store all "standard" floats as 64-bit doubles, or false if they are 32-bit floats. This isn't runtime settable; it's based on the compilation flags of the version of Panda that generated this file. More... | |
BamEnums::BamTextureMode | getFileTextureMode () |
Returns the BamTextureMode preference indicated by the Bam file currently being written. Texture objects written to this Bam file will be encoded according to the specified mode. More... | |
DatagramSink | getTarget () |
Returns the current target of the BamWriter as set by set_target() or the constructor. More... | |
bool | hasObject (const TypedWritable obj) |
Returns true if the object has previously been written (or at least requested to be written) to the bam file, or false if we've never heard of it before. More... | |
bool | init () |
Initializes the BamWriter prior to writing any objects to its output stream. This includes writing out the Bam header. More... | |
setFileTextureMode (BamEnums::BamTextureMode file_texture_mode) | |
Changes the BamTextureMode preference for the Bam file currently being written. Texture objects written to this Bam file will be encoded according to the specified mode. More... | |
setTarget (DatagramSink target) | |
Changes the destination of future datagrams written by the BamWriter. This also implicitly calls init() if it has not already been called. More... | |
bool | writeObject (const TypedWritable obj) |
Writes a single object to the Bam file, so that the BamReader::read_object() can later correctly restore the object and all its pointers. More... | |
Additional Inherited Members | |
![]() | |
enum | BamEndian { BE_bigendian = 0, BE_littleendian = 1, BE_native = 1 } |
This defines an enumerated type used to represent the endianness of certain numeric values stored in a Bam file. It really has only two possible values, either BE_bigendian or BE_littleendian; but through a preprocessor trick we also add BE_native, which is the same numerically as whichever value the hardware supports natively. More... | |
enum | BamObjectCode { BOC_push = 0, BOC_pop = 1, BOC_adjunct = 2, BOC_remove = 3, BOC_file_data = 4 } |
This is the code written along with each object. It is used to control object scoping. A BOC_push includes an object definition, and will always be eventually paired with a BOC_pop (which does not). A BOC_adjunct includes an object definition but does not push the level; it is associated with the current level. BOC_remove lists object ID's that have been deallocated on the sender end. BOC_file_data may appear at any level and indicates the following datagram contains auxiliary file data that may be referenced by a later object. More... | |
enum | BamTextureMode { BTM_unchanged = 0, BTM_fullpath = 1, BTM_relative = 2, BTM_basename = 3, BTM_rawdata = 4 } |
This enum is used to control how textures are written to a bam stream. More... | |
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by a BamReader.
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; the BamWriter automatically manages these (with help from code within each class) and writes all referenced objects to the file in such a way that the pointers may be correctly restored later.
This is the abstract interface and does not specifically deal with disk files, but rather with a DatagramSink of some kind, which simply accepts a linear stream of Datagrams. It is probably written to a disk file, but it might conceivably be streamed directly to 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.
__init__ | ( | DatagramSink | target | ) |
flush | ( | ) |
Ensures that all data written thus far is manifested on the output stream.
BamEnums::BamEndian getFileEndian | ( | ) |
Returns the endian preference indicated by the Bam file currently being written. 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.
const Filename getFilename | ( | ) |
If a BAM is a file, then the BamWriter should contain the name of the file. This enables the writer to convert pathnames in the BAM to relative to the directory containing the BAM.
bool getFileStdfloatDouble | ( | ) |
Returns true if the file will store all "standard" floats as 64-bit doubles, or false if they are 32-bit floats. This isn't runtime settable; it's based on the compilation flags of the version of Panda that generated this file.
BamEnums::BamTextureMode getFileTextureMode | ( | ) |
Returns the BamTextureMode preference indicated by the Bam file currently being written. Texture objects written to this Bam file will be encoded according to the specified mode.
DatagramSink getTarget | ( | ) |
Returns the current target of the BamWriter as set by set_target() or the constructor.
bool hasObject | ( | const TypedWritable | obj | ) |
Returns true if the object has previously been written (or at least requested to be written) to the bam file, or false if we've never heard of it before.
bool init | ( | ) |
setFileTextureMode | ( | BamEnums::BamTextureMode | file_texture_mode | ) |
Changes the BamTextureMode preference for the Bam file currently being written. Texture objects written to this Bam file will be encoded according to the specified mode.
setTarget | ( | DatagramSink | target | ) |
bool writeObject | ( | const TypedWritable | obj | ) |
Writes a single object to the Bam file, so that the BamReader::read_object() can later correctly restore the object and all its pointers.
This implicitly also writes any additional objects this object references (if they haven't already been written), so that pointers may be fully resolved.
This may be called repeatedly to write a sequence of objects to the Bam file, but typically (especially for scene graph files, indicated with the .bam extension), only one object is written directly from the Bam file: the root of the scene graph. The remaining objects will all be written recursively by the first object.
Returns true if the object is successfully written, false otherwise.