Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | Friends
XFileNode Class Reference

A single node of an X file. More...

#include "xFileNode.h"

Inheritance diagram for XFileNode:
TypedObject Namable ReferenceCount MemoryBase MemoryBase MemoryBase XFile XFileDataDef XFileDataNode XFileTemplate XFileDataNodeReference XFileDataNodeTemplate

List of all members.

Public Types

typedef pmap< const
XFileDataDef
*, XFileDataObject * > 
PrevData

Public Member Functions

 XFileNode (XFile *x_file, const string &name)
void add_child (XFileNode *node)
 Adds the indicated node as a child of this node.
XFileDataNodeadd_Frame (const string &name)
 Creates a new Frame instance, as a child of this node.
XFileDataNodeadd_FrameTransformMatrix (const LMatrix4d &mat)
 Creates a new FrameTransformMatrix instance, as a child of this node.
XFileDataNodeadd_Material (const string &name, const LColor &face_color, double power, const LRGBColor &specular_color, const LRGBColor &emissive_color)
 Creates a new Material instance, as a child of this node.
XFileDataNodeadd_Mesh (const string &name)
 Creates a new Mesh instance, as a child of this node.
XFileDataNodeadd_MeshMaterialList (const string &name)
 Creates a new MeshMaterialList instance, as a child of this node.
XFileDataNodeadd_MeshNormals (const string &name)
 Creates a new MeshNormals instance, as a child of this node.
XFileDataNodeadd_MeshTextureCoords (const string &name)
 Creates a new MeshTextureCoords instance, as a child of this node.
XFileDataNodeadd_MeshVertexColors (const string &name)
 Creates a new MeshVertexColors instance, as a child of this node.
XFileDataNodeadd_TextureFilename (const string &name, const Filename &filename)
 Creates a new TextureFilename instance, as a child of this node.
virtual void clear ()
 Removes all children from the node, and otherwise resets it to its initial state.
virtual bool fill_zero_data (XFileDataObject *object) const
 This is similar to repack_data(), except it is used to fill the initial values for a newly-created template object to zero.
XFileNodefind_child (const string &name) const
 Returns the child with the indicated name, if any, or NULL if none.
int find_child_index (const string &name) const
 Returns the index number of the child with the indicated name, if any, or -1 if none.
int find_child_index (const XFileNode *child) const
 Returns the index number of the indicated child, or -1 if none.
XFileNodefind_descendent (const string &name) const
 Returns the first child or descendent found with the indicated name after a depth-first search, if any, or NULL if none.
virtual TypeHandle force_init_type ()
XFileNodeget_child (int n) const
 Returns the nth child of this node.
virtual const WindowsGuidget_guid () const
 If has_guid() returned true, returns the particular GUID associated with this node.
int get_num_children () const
 Returns the list of children of this node.
int get_num_objects () const
 Returns the list of child objects of this node.
XFileDataNodeget_object (int n) const
 Returns the nth child object of this node.
virtual TypeHandle get_type () const
XFileget_x_file () const
virtual bool has_guid () const
 Returns true if this node has a GUID associated.
virtual bool is_object () const
 Returns true if this node represents a data object that is the instance of some template, or false otherwise.
virtual bool is_reference () const
 Returns true if this node represents an indirect reference to an object defined previously in the file.
virtual bool is_standard_object (const string &template_name) const
 Returns true if this node represents an instance of the standard template with the indicated name, or false otherwise.
virtual bool is_template_def () const
 Returns true if this node represents the definition of some template.
virtual bool matches (const XFileNode *other) const
 Returns true if the node, particularly a template node, is structurally equivalent to the other node (which must be of the same type).
virtual bool repack_data (XFileDataObject *object, const XFileParseDataList &parse_data_list, PrevData &prev_data, size_t &index, size_t &sub_index) const
 This is called on the template that defines an object, once the data for the object has been parsed.
virtual void write_text (ostream &out, int indent_level) const
 Writes a suitable representation of this node to an .x file in text mode.

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.
static string make_nice_name (const string &str)
 Transforms the indicated egg name to a name that is acceptable for a node in the X File format.

Protected Types

typedef pvector< PT(XFileNode) > Children
typedef pmap< string, int > ChildrenByName
typedef pvector< XFileDataNode * > Objects

Protected Attributes

Children _children
ChildrenByName _children_by_name
Objects _objects
XFile_x_file

Friends

class XFileDataNodeReference

Detailed Description

A single node of an X file.

This may be either a template or a data node.

Definition at line 42 of file xFileNode.h.


Member Function Documentation

void XFileNode::add_child ( XFileNode node)
XFileDataNode * XFileNode::add_Frame ( const string &  name)

Creates a new Frame instance, as a child of this node.

Definition at line 499 of file xFileNode.cxx.

References add_child(), XFile::find_standard_template(), and XFileDataNodeTemplate::zero_fill().

Creates a new FrameTransformMatrix instance, as a child of this node.

Definition at line 517 of file xFileNode.cxx.

References add_child(), XFile::find_standard_template(), and XFileDataNodeTemplate::zero_fill().

XFileDataNode * XFileNode::add_Material ( const string &  name,
const LColor face_color,
double  power,
const LRGBColor specular_color,
const LRGBColor emissive_color 
)

Creates a new Material instance, as a child of this node.

Definition at line 447 of file xFileNode.cxx.

References add_child(), XFile::find_standard_template(), and XFileDataNodeTemplate::zero_fill().

Referenced by XFileMaterial::make_x_material().

XFileDataNode * XFileNode::add_Mesh ( const string &  name)

Creates a new Mesh instance, as a child of this node.

Definition at line 357 of file xFileNode.cxx.

References add_child(), XFile::find_standard_template(), and XFileDataNodeTemplate::zero_fill().

Referenced by XFileMesh::make_x_mesh().

XFileDataNode * XFileNode::add_MeshMaterialList ( const string &  name)

Creates a new MeshMaterialList instance, as a child of this node.

Definition at line 429 of file xFileNode.cxx.

References add_child(), XFile::find_standard_template(), and XFileDataNodeTemplate::zero_fill().

Referenced by XFileMesh::make_x_material_list().

XFileDataNode * XFileNode::add_MeshNormals ( const string &  name)

Creates a new MeshNormals instance, as a child of this node.

Definition at line 375 of file xFileNode.cxx.

References add_child(), XFile::find_standard_template(), and XFileDataNodeTemplate::zero_fill().

Referenced by XFileMesh::make_x_normals().

XFileDataNode * XFileNode::add_MeshTextureCoords ( const string &  name)

Creates a new MeshTextureCoords instance, as a child of this node.

Definition at line 411 of file xFileNode.cxx.

References add_child(), XFile::find_standard_template(), and XFileDataNodeTemplate::zero_fill().

Referenced by XFileMesh::make_x_uvs().

XFileDataNode * XFileNode::add_MeshVertexColors ( const string &  name)

Creates a new MeshVertexColors instance, as a child of this node.

Definition at line 393 of file xFileNode.cxx.

References add_child(), XFile::find_standard_template(), and XFileDataNodeTemplate::zero_fill().

Referenced by XFileMesh::make_x_colors().

XFileDataNode * XFileNode::add_TextureFilename ( const string &  name,
const Filename filename 
)

Creates a new TextureFilename instance, as a child of this node.

Definition at line 479 of file xFileNode.cxx.

References add_child(), XFile::find_standard_template(), and XFileDataNodeTemplate::zero_fill().

Referenced by XFileMaterial::make_x_material().

void XFileNode::clear ( void  ) [virtual]

Removes all children from the node, and otherwise resets it to its initial state.

Reimplemented in XFileDataDef, XFile, and XFileTemplate.

Definition at line 250 of file xFileNode.cxx.

bool XFileNode::fill_zero_data ( XFileDataObject object) const [virtual]

This is similar to repack_data(), except it is used to fill the initial values for a newly-created template object to zero.

Reimplemented in XFileDataDef.

Definition at line 312 of file xFileNode.cxx.

XFileNode * XFileNode::find_child ( const string &  name) const

Returns the child with the indicated name, if any, or NULL if none.

Definition at line 61 of file xFileNode.cxx.

References get_child().

Referenced by find_descendent(), and XFile::find_template().

int XFileNode::find_child_index ( const string &  name) const

Returns the index number of the child with the indicated name, if any, or -1 if none.

Definition at line 78 of file xFileNode.cxx.

Referenced by XFileArrayDef::matches().

int XFileNode::find_child_index ( const XFileNode child) const

Returns the index number of the indicated child, or -1 if none.

Definition at line 95 of file xFileNode.cxx.

XFileNode * XFileNode::find_descendent ( const string &  name) const

Returns the first child or descendent found with the indicated name after a depth-first search, if any, or NULL if none.

Definition at line 113 of file xFileNode.cxx.

References find_child(), and find_descendent().

Referenced by XFile::find_data_object(), and find_descendent().

XFileNode * XFileNode::get_child ( int  n) const [inline]

Returns the nth child of this node.

This list includes templates as well as data objects.

Definition at line 44 of file xFileNode.I.

Referenced by find_child(), XFileDataNode::get_data_child(), and matches().

const WindowsGuid & XFileNode::get_guid ( ) const [virtual]

If has_guid() returned true, returns the particular GUID associated with this node.

Reimplemented in XFileTemplate.

Definition at line 147 of file xFileNode.cxx.

Referenced by add_child().

int XFileNode::get_num_children ( ) const [inline]

Returns the list of children of this node.

This list includes templates as well as data objects.

Definition at line 33 of file xFileNode.I.

Referenced by matches().

int XFileNode::get_num_objects ( ) const [inline]

Returns the list of child objects of this node.

This list does not include template definitions; it is strictly the list of children that are also data objects (instances of templates).

Definition at line 58 of file xFileNode.I.

Referenced by XFileMaterial::fill_material(), XFileMesh::fill_material_list(), and XFileMesh::fill_mesh().

XFileDataNode * XFileNode::get_object ( int  n) const [inline]

Returns the nth child object of this node.

This list does not include template definitions; it is strictly the list of children that are also data objects (instances of templates).

Definition at line 71 of file xFileNode.I.

Referenced by XFileMaterial::fill_material(), XFileMesh::fill_material_list(), and XFileMesh::fill_mesh().

bool XFileNode::has_guid ( ) const [virtual]

Returns true if this node has a GUID associated.

Reimplemented in XFileTemplate.

Definition at line 136 of file xFileNode.cxx.

Referenced by add_child().

static void XFileNode::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 XFileDataDef, XFile, and XFileTemplate.

Definition at line 120 of file xFileNode.h.

bool XFileNode::is_object ( ) const [virtual]

Returns true if this node represents a data object that is the instance of some template, or false otherwise.

This also returns true for references to objects (which are generally treated just like the objects themselves).

If this returns true, the node must be of type XFileDataNode (it is either an XFileDataNodeTemplate or an XFileDataNodeReference).

Reimplemented in XFileDataNode.

Definition at line 203 of file xFileNode.cxx.

bool XFileNode::is_reference ( ) const [virtual]

Returns true if this node represents an indirect reference to an object defined previously in the file.

References are generally transparent, so in most cases you never need to call this, unless you actually need to differentiate between references and instances; you can simply use the reference node as if it were itself the object it references.

If this returns true, the node must be of type XFileDataNodeReference.

Reimplemented in XFileDataNodeReference.

Definition at line 185 of file xFileNode.cxx.

bool XFileNode::is_standard_object ( const string &  template_name) const [virtual]

Returns true if this node represents an instance of the standard template with the indicated name, or false otherwise.

This returns also returns true for references to standard objects.

If this returns true, the node must be of type XFileDataNode (it is either an XFileDataNodeTemplate or an XFileDataNodeReference).

Reimplemented in XFileDataNode.

Definition at line 220 of file xFileNode.cxx.

bool XFileNode::is_template_def ( ) const [virtual]

Returns true if this node represents the definition of some template.

This is the template definition, not an actual data object that represents an instance of the template. If the file strictly uses standard templates, the presence of template definitions is optional.

If this returns true, the node must be of type XFileTemplate.

Reimplemented in XFileTemplate.

Definition at line 166 of file xFileNode.cxx.

string XFileNode::make_nice_name ( const string &  str) [static]

Transforms the indicated egg name to a name that is acceptable for a node in the X File format.

Definition at line 557 of file xFileNode.cxx.

bool XFileNode::matches ( const XFileNode other) const [virtual]

Returns true if the node, particularly a template node, is structurally equivalent to the other node (which must be of the same type).

This checks data element types, but does not compare data element names.

Reimplemented in XFileDataDef, and XFileTemplate.

Definition at line 333 of file xFileNode.cxx.

References get_child(), get_num_children(), and matches().

Referenced by XFileTemplate::matches(), XFileDataDef::matches(), and matches().

bool XFileNode::repack_data ( XFileDataObject object,
const XFileParseDataList parse_data_list,
XFileNode::PrevData &  prev_data,
size_t &  index,
size_t &  sub_index 
) const [virtual]

This is called on the template that defines an object, once the data for the object has been parsed.

It is responsible for identifying which component of the template owns each data element, and packing the data elements appropriately back into the object.

It returns true on success, or false on an error (e.g. not enough data elements, mismatched data type).

Reimplemented in XFileDataDef.

Definition at line 284 of file xFileNode.cxx.

void XFileNode::write_text ( ostream &  out,
int  indent_level 
) const [virtual]

Writes a suitable representation of this node to an .x file in text mode.

Reimplemented in XFileDataDef, XFile, XFileDataNodeTemplate, XFileDataNodeReference, and XFileTemplate.

Definition at line 263 of file xFileNode.cxx.


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