Panda3D
|
The base class for all kinds of records in a MultiGen OpenFlight file. More...
#include "fltRecord.h"
Public Member Functions | |
FltRecord (FltHeader *header) | |
void | add_ancillary (FltRecord *ancillary) |
Adds a new unsupported ancillary record to the end of the list of ancillary records for this record. | |
void | add_child (FltRecord *child) |
Adds a new child to the end of the list of children for this record. | |
void | add_extension (FltRecord *extension) |
Adds a new extension to the end of the list of extensions for this record. | |
void | add_subface (FltRecord *subface) |
Adds a new subface to the end of the list of subfaces for this record. | |
virtual void | apply_converted_filenames () |
Walks the hierarchy at this record and below and copies the _converted_filename record into the _orig_filename record, so the flt file will be written out with the converted filename instead of what was originally read in. | |
void | check_remaining_size (const DatagramIterator &di, const string &name=string()) const |
Checks that the iterator has no bytes left, as it should at the end of a successfully read record. | |
void | clear_ancillary () |
Removes all unsupported ancillary records from this record. | |
void | clear_children () |
Removes all children from this record. | |
void | clear_comment () |
Removes the comment for this record. | |
void | clear_extensions () |
Removes all extensions from this record. | |
void | clear_subfaces () |
Removes all subfaces from this record. | |
virtual TypeHandle | force_init_type () |
FltRecord * | get_ancillary (int n) const |
Returns the nth unsupported ancillary record of this record. | |
FltRecord * | get_child (int n) const |
Returns the nth child of this record. | |
const string & | get_comment () const |
Retrieves the comment for this record, or empty string if the record has no comment. | |
FltRecord * | get_extension (int n) const |
Returns the nth extension of this record. | |
int | get_num_ancillary () const |
Returns the number of unsupported ancillary records of this record. | |
int | get_num_children () const |
Returns the number of child records of this record. | |
int | get_num_extensions () const |
Returns the number of extension attribute records for this object. | |
int | get_num_subfaces () const |
Returns the number of subface records of this record. | |
FltRecord * | get_subface (int n) const |
Returns the nth subface of this record. | |
virtual TypeHandle | get_type () const |
bool | has_comment () const |
Returns true if this record has a nonempty comment, false otherwise. | |
virtual void | output (ostream &out) const |
Writes a quick one-line description of the record, but not its children. | |
void | set_comment (const string &comment) |
Changes the comment for this record. | |
virtual void | write (ostream &out, int indent_level=0) const |
Writes a multiple-line description of the record and all of its children. | |
Static Public Member Functions | |
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. | |
Protected Member Functions | |
virtual bool | build_record (FltRecordWriter &writer) const |
Fills up the current record on the FltRecordWriter with data for this record, but does not advance the writer. | |
FltRecord * | create_new_record (FltOpcode opcode) const |
Creates a new FltRecord corresponding to the opcode. | |
virtual bool | extract_ancillary (FltRecordReader &reader) |
Checks whether the given record, which follows this record sequentially in the file, is an ancillary record of this record. | |
virtual bool | extract_record (FltRecordReader &reader) |
Fills in the information in this record based on the information given in the indicated datagram, whose opcode has already been read. | |
FltError | read_record_and_children (FltRecordReader &reader) |
Extracts this record information from the current record presented in the reader, then advances the reader and continues to read any children, if present. | |
virtual FltError | write_ancillary (FltRecordWriter &writer) const |
Writes whatever ancillary records are required for this record. | |
void | write_children (ostream &out, int indent_level) const |
Assuming the current write position has been left at the end of the last line of the record description, writes out the list of children. | |
virtual FltError | write_record_and_children (FltRecordWriter &writer) const |
Writes this record out to the flt file, along with all of its ancillary records and children records. | |
Static Protected Member Functions | |
static bool | is_ancillary (FltOpcode opcode) |
Returns true if the indicated opcode corresponds to an ancillary record type, false otherwise. | |
Protected Attributes | |
FltHeader * | _header |
The base class for all kinds of records in a MultiGen OpenFlight file.
A flt file consists of a hierarchy of "beads" of various kinds, each of which may be followed by n ancillary records, written sequentially to the file.
Definition at line 40 of file fltRecord.h.
void FltRecord::add_ancillary | ( | FltRecord * | ancillary | ) |
Adds a new unsupported ancillary record to the end of the list of ancillary records for this record.
This record will be written to the flt file following this record, without attempting to understand what is in it.
Normally, there is no reason to use this function; if the data stored in the FltRecord requires one or more ancillary record, the appropriate records will automatically be generated when the record is written. This function is only required to output a record whose type is not supported by the flt loader. But it would be better to extend the flt loader to know about this new kind of data record.
Definition at line 253 of file fltRecord.cxx.
void FltRecord::add_child | ( | FltRecord * | child | ) |
Adds a new child to the end of the list of children for this record.
Definition at line 102 of file fltRecord.cxx.
Referenced by read_record_and_children().
void FltRecord::add_extension | ( | FltRecord * | extension | ) |
Adds a new extension to the end of the list of extensions for this record.
This should be a record of type FO_extension.
Definition at line 193 of file fltRecord.cxx.
Referenced by read_record_and_children().
void FltRecord::add_subface | ( | FltRecord * | subface | ) |
Adds a new subface to the end of the list of subfaces for this record.
Definition at line 147 of file fltRecord.cxx.
Referenced by read_record_and_children().
void FltRecord::apply_converted_filenames | ( | ) | [virtual] |
Walks the hierarchy at this record and below and copies the _converted_filename record into the _orig_filename record, so the flt file will be written out with the converted filename instead of what was originally read in.
Reimplemented in FltHeader, FltExternalReference, and FltTexture.
Definition at line 340 of file fltRecord.cxx.
bool FltRecord::build_record | ( | FltRecordWriter & | writer | ) | const [protected, virtual] |
Fills up the current record on the FltRecordWriter with data for this record, but does not advance the writer.
Returns true on success, false if there is some error.
Reimplemented in FltHeader, FltTexture, FltGeometry, FltVertex, FltLightSourceDefinition, FltTransformPut, FltLocalVertexPool, FltExternalReference, FltBead, FltTransformRotateScale, FltCurve, FltMaterial, FltMeshPrimitive, FltObject, FltGroup, FltLOD, FltTransformRotateAboutEdge, FltTransformRotateAboutPoint, FltInstanceRef, FltTransformScale, FltVertexList, FltTransformTranslate, FltVectorRecord, FltBeadID, FltInstanceDefinition, FltMesh, FltTransformGeneralMatrix, FltUnsupportedRecord, and FltFace.
Definition at line 819 of file fltRecord.cxx.
Referenced by FltTransformGeneralMatrix::build_record(), FltVectorRecord::build_record(), FltTransformTranslate::build_record(), FltVertexList::build_record(), FltTransformScale::build_record(), FltTransformRotateAboutEdge::build_record(), FltTransformRotateAboutPoint::build_record(), FltMaterial::build_record(), FltTransformRotateScale::build_record(), FltBead::build_record(), FltLocalVertexPool::build_record(), FltTransformPut::build_record(), FltLightSourceDefinition::build_record(), FltVertex::build_record(), FltTexture::build_record(), and write_record_and_children().
void FltRecord::check_remaining_size | ( | const DatagramIterator & | di, |
const string & | name = string() |
||
) | const |
Checks that the iterator has no bytes left, as it should at the end of a successfully read record.
If there *are* remaining bytes, print a warning message but otherwise don't worry about it.
If we are attempting to read a flt file whose version is newer than the newest this program understands, don't even print a warning message, since this is exactly the sort of thing we expect.
Definition at line 313 of file fltRecord.cxx.
References FltHeader::get_flt_version(), DatagramIterator::get_remaining_size(), and FltHeader::max_flt_version().
Referenced by FltFace::extract_record(), FltTransformGeneralMatrix::extract_record(), FltMesh::extract_record(), FltInstanceDefinition::extract_record(), FltVectorRecord::extract_record(), FltTransformTranslate::extract_record(), FltVertexList::extract_record(), FltInstanceRef::extract_record(), FltTransformScale::extract_record(), FltGroup::extract_record(), FltTransformRotateAboutEdge::extract_record(), FltLOD::extract_record(), FltTransformRotateAboutPoint::extract_record(), FltObject::extract_record(), FltMaterial::extract_record(), FltMeshPrimitive::extract_record(), FltCurve::extract_record(), FltTransformRotateScale::extract_record(), FltExternalReference::extract_record(), FltLocalVertexPool::extract_record(), FltTransformPut::extract_record(), FltLightSourceDefinition::extract_record(), FltVertex::extract_record(), FltTexture::extract_record(), and FltHeader::extract_record().
void FltRecord::clear_ancillary | ( | ) |
Removes all unsupported ancillary records from this record.
See get_num_ancillary().
Definition at line 231 of file fltRecord.cxx.
void FltRecord::clear_children | ( | ) |
Removes all children from this record.
Definition at line 91 of file fltRecord.cxx.
void FltRecord::clear_comment | ( | ) |
Removes the comment for this record.
Definition at line 285 of file fltRecord.cxx.
void FltRecord::clear_extensions | ( | ) |
Removes all extensions from this record.
Definition at line 181 of file fltRecord.cxx.
void FltRecord::clear_subfaces | ( | ) |
Removes all subfaces from this record.
Definition at line 136 of file fltRecord.cxx.
FltRecord * FltRecord::create_new_record | ( | FltOpcode | opcode | ) | const [protected] |
Creates a new FltRecord corresponding to the opcode.
If the opcode is unknown, creates a FltUnsupportedRecord.
Definition at line 521 of file fltRecord.cxx.
Referenced by read_record_and_children().
bool FltRecord::extract_ancillary | ( | FltRecordReader & | reader | ) | [protected, virtual] |
Checks whether the given record, which follows this record sequentially in the file, is an ancillary record of this record.
If it is, extracts the relevant information and returns true; otherwise, leaves it alone and returns false.
Reimplemented in FltHeader, FltBead, FltBeadID, and FltMesh.
Definition at line 709 of file fltRecord.cxx.
References FltRecordReader::get_iterator(), FltRecordReader::get_opcode(), and DatagramIterator::get_remaining_bytes().
Referenced by read_record_and_children().
bool FltRecord::extract_record | ( | FltRecordReader & | reader | ) | [protected, virtual] |
Fills in the information in this record based on the information given in the indicated datagram, whose opcode has already been read.
Returns true on success, false if the datagram is invalid.
Reimplemented in FltHeader, FltTexture, FltGeometry, FltVertex, FltLightSourceDefinition, FltTransformPut, FltLocalVertexPool, FltExternalReference, FltTransformRotateScale, FltBead, FltCurve, FltMaterial, FltMeshPrimitive, FltObject, FltGroup, FltLOD, FltTransformRotateAboutEdge, FltTransformRotateAboutPoint, FltTransformScale, FltInstanceRef, FltVertexList, FltTransformTranslate, FltVectorRecord, FltInstanceDefinition, FltBeadID, FltMesh, FltTransformGeneralMatrix, FltUnsupportedRecord, and FltFace.
Definition at line 695 of file fltRecord.cxx.
Referenced by FltBead::extract_ancillary(), FltTransformGeneralMatrix::extract_record(), FltVectorRecord::extract_record(), FltTransformTranslate::extract_record(), FltVertexList::extract_record(), FltTransformScale::extract_record(), FltTransformRotateAboutEdge::extract_record(), FltTransformRotateAboutPoint::extract_record(), FltMaterial::extract_record(), FltBead::extract_record(), FltTransformRotateScale::extract_record(), FltLocalVertexPool::extract_record(), FltTransformPut::extract_record(), FltLightSourceDefinition::extract_record(), FltVertex::extract_record(), FltTexture::extract_record(), and read_record_and_children().
FltRecord * FltRecord::get_ancillary | ( | int | n | ) | const |
Returns the nth unsupported ancillary record of this record.
See get_num_ancillary().
Definition at line 219 of file fltRecord.cxx.
FltRecord * FltRecord::get_child | ( | int | n | ) | const |
Returns the nth child of this record.
Definition at line 80 of file fltRecord.cxx.
const string & FltRecord::get_comment | ( | ) | const |
Retrieves the comment for this record, or empty string if the record has no comment.
Definition at line 275 of file fltRecord.cxx.
FltRecord * FltRecord::get_extension | ( | int | n | ) | const |
Returns the nth extension of this record.
Definition at line 170 of file fltRecord.cxx.
int FltRecord::get_num_ancillary | ( | ) | const |
Returns the number of unsupported ancillary records of this record.
These are ancillary records that appeared following this record in the flt file but that aren't directly understood by the flt loader--normally, an ancillary record is examined and decoded on the spot, and no pointer to it is kept.
Definition at line 208 of file fltRecord.cxx.
int FltRecord::get_num_children | ( | ) | const |
Returns the number of child records of this record.
This reflects the normal scene graph hierarchy.
Definition at line 70 of file fltRecord.cxx.
int FltRecord::get_num_extensions | ( | ) | const |
Returns the number of extension attribute records for this object.
These are auxiliary nodes, presumably of type FO_extension, that have some local meaning to the object.
Definition at line 160 of file fltRecord.cxx.
int FltRecord::get_num_subfaces | ( | ) | const |
Returns the number of subface records of this record.
Normally, subfaces will only be present on object records, although it is logically possible for them to appear anywhere.
Definition at line 115 of file fltRecord.cxx.
FltRecord * FltRecord::get_subface | ( | int | n | ) | const |
Returns the nth subface of this record.
Definition at line 125 of file fltRecord.cxx.
bool FltRecord::has_comment | ( | ) | const |
Returns true if this record has a nonempty comment, false otherwise.
Definition at line 264 of file fltRecord.cxx.
static void FltRecord::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 TypedReferenceCount.
Reimplemented in FltHeader, FltTexture, FltGeometry, FltBead, FltVertex, FltLightSourceDefinition, FltTransformPut, FltLocalVertexPool, FltExternalReference, FltMaterial, FltTransformRotateScale, FltCurve, FltMeshPrimitive, FltVertexList, FltObject, FltGroup, FltLOD, FltTransformRotateAboutEdge, FltTransformRotateAboutPoint, FltInstanceRef, FltTransformScale, FltBeadID, FltTransformTranslate, FltVectorRecord, FltMesh, FltInstanceDefinition, FltUnsupportedRecord, FltTransformRecord, FltTransformGeneralMatrix, and FltFace.
Definition at line 113 of file fltRecord.h.
bool FltRecord::is_ancillary | ( | FltOpcode | opcode | ) | [static, protected] |
Returns true if the indicated opcode corresponds to an ancillary record type, false otherwise.
In general, this function is used to identify ancillary records that are not presently supported by the FltReader; these will be ignored. Normally, ancillary records will be detected and processed by extract_ancillary().
Definition at line 429 of file fltRecord.cxx.
Referenced by read_record_and_children().
void FltRecord::output | ( | ostream & | out | ) | const [virtual] |
Writes a quick one-line description of the record, but not its children.
This is a human-readable description, primarily for debugging; to write a flt file, use FltHeader::write_flt().
Reimplemented in FltVertexList, FltBeadID, FltExternalReference, and FltUnsupportedRecord.
Definition at line 359 of file fltRecord.cxx.
FltError FltRecord::read_record_and_children | ( | FltRecordReader & | reader | ) | [protected] |
Extracts this record information from the current record presented in the reader, then advances the reader and continues to read any children, if present.
On return, the reader is position on the next sibling record to this record.
Returns FE_ok if successful, otherwise on error.
Definition at line 580 of file fltRecord.cxx.
References add_child(), add_extension(), FltHeader::add_instance(), add_subface(), FltRecordReader::advance(), create_new_record(), FltRecordReader::eof(), FltRecordReader::error(), extract_ancillary(), extract_record(), FltRecordReader::get_opcode(), is_ancillary(), and read_record_and_children().
Referenced by FltHeader::read_flt(), and read_record_and_children().
void FltRecord::set_comment | ( | const string & | comment | ) |
Changes the comment for this record.
Definition at line 295 of file fltRecord.cxx.
void FltRecord::write | ( | ostream & | out, |
int | indent_level = 0 |
||
) | const [virtual] |
Writes a multiple-line description of the record and all of its children.
This is a human-readable description, primarily for debugging; to write a flt file, use FltHeader::write_flt().
Reimplemented in FltInstanceRef.
Definition at line 372 of file fltRecord.cxx.
References write_children().
Referenced by FltInfo::list_hierarchy().
FltError FltRecord::write_ancillary | ( | FltRecordWriter & | writer | ) | const [protected, virtual] |
Writes whatever ancillary records are required for this record.
Returns FE_ok on success, or something else if there is some error.
Reimplemented in FltHeader, FltBead, FltBeadID, and FltMesh.
Definition at line 831 of file fltRecord.cxx.
References FltRecordWriter::write_record().
Referenced by write_record_and_children().
void FltRecord::write_children | ( | ostream & | out, |
int | indent_level | ||
) | const [protected] |
Assuming the current write position has been left at the end of the last line of the record description, writes out the list of children.
Definition at line 385 of file fltRecord.cxx.
Referenced by FltInstanceRef::write(), and write().
FltError FltRecord::write_record_and_children | ( | FltRecordWriter & | writer | ) | const [protected, virtual] |
Writes this record out to the flt file, along with all of its ancillary records and children records.
Returns FE_ok on success, or something else on error.
Reimplemented in FltInstanceRef.
Definition at line 726 of file fltRecord.cxx.
References FltRecordWriter::advance(), build_record(), write_ancillary(), and FltRecordWriter::write_record().
Referenced by FltHeader::write_flt(), and FltRecordWriter::write_instance_def().