Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes

FltRecord Class Reference

The base class for all kinds of records in a MultiGen OpenFlight file. More...

#include "fltRecord.h"

Inheritance diagram for FltRecord:
TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase FltBead FltLightSourceDefinition FltLocalVertexPool FltMaterial FltTexture FltTransformRecord FltUnsupportedRecord FltVectorRecord FltVertex FltVertexList

List of all members.

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 ()
FltRecordget_ancillary (int n) const
 Returns the nth unsupported ancillary record of this record.
FltRecordget_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.
FltRecordget_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.
FltRecordget_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.
FltRecordcreate_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

Detailed Description

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.


Member Function Documentation

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 FltExternalReference, FltHeader, and FltTexture.

Definition at line 340 of file fltRecord.cxx.

bool FltRecord::build_record ( FltRecordWriter writer) const [protected, virtual]
void FltRecord::check_remaining_size ( const DatagramIterator di,
const string &  name = string() 
) const
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 FltBead, FltBeadID, FltHeader, 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]
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]
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 FltBeadID, FltExternalReference, FltUnsupportedRecord, and FltVertexList.

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 FltBead, FltBeadID, FltHeader, 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 write(), and FltInstanceRef::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().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations