A single node of an X file. More...
#include "xFileNode.h"
Public Types | |
typedef pmap< const XFileDataDef *, XFileDataObject * > | PrevData |
Public Member Functions | |
XFileNode (XFile *x_file, const std::string &name) | |
void | add_child (XFileNode *node) |
Adds the indicated node as a child of this node. More... | |
XFileDataNode * | add_Frame (const std::string &name) |
Creates a new Frame instance, as a child of this node. More... | |
XFileDataNode * | add_FrameTransformMatrix (const LMatrix4d &mat) |
Creates a new FrameTransformMatrix instance, as a child of this node. More... | |
XFileDataNode * | add_Material (const std::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. More... | |
XFileDataNode * | add_Mesh (const std::string &name) |
Creates a new Mesh instance, as a child of this node. More... | |
XFileDataNode * | add_MeshMaterialList (const std::string &name) |
Creates a new MeshMaterialList instance, as a child of this node. More... | |
XFileDataNode * | add_MeshNormals (const std::string &name) |
Creates a new MeshNormals instance, as a child of this node. More... | |
XFileDataNode * | add_MeshTextureCoords (const std::string &name) |
Creates a new MeshTextureCoords instance, as a child of this node. More... | |
XFileDataNode * | add_MeshVertexColors (const std::string &name) |
Creates a new MeshVertexColors instance, as a child of this node. More... | |
XFileDataNode * | add_TextureFilename (const std::string &name, const Filename &filename) |
Creates a new TextureFilename instance, as a child of this node. More... | |
virtual void | clear () |
Removes all children from the node, and otherwise resets it to its initial state. More... | |
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. More... | |
XFileNode * | find_child (const std::string &name) const |
Returns the child with the indicated name, if any, or NULL if none. More... | |
int | find_child_index (const std::string &name) const |
Returns the index number of the child with the indicated name, if any, or -1 if none. More... | |
int | find_child_index (const XFileNode *child) const |
Returns the index number of the indicated child, or -1 if none. More... | |
XFileNode * | find_descendent (const std::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. More... | |
virtual TypeHandle | force_init_type () |
XFileNode * | get_child (int n) const |
Returns the nth child of this node. More... | |
virtual const WindowsGuid & | get_guid () const |
If has_guid() returned true, returns the particular GUID associated with this node. More... | |
int | get_num_children () const |
Returns the list of children of this node. More... | |
int | get_num_objects () const |
Returns the list of child objects of this node. More... | |
XFileDataNode * | get_object (int n) const |
Returns the nth child object of this node. More... | |
virtual TypeHandle | get_type () const |
XFile * | get_x_file () const |
virtual bool | has_guid () const |
Returns true if this node has a GUID associated. More... | |
virtual bool | is_object () const |
Returns true if this node represents a data object that is the instance of some template, or false otherwise. More... | |
virtual bool | is_reference () const |
Returns true if this node represents an indirect reference to an object defined previously in the file. More... | |
virtual bool | is_standard_object (const std::string &template_name) const |
Returns true if this node represents an instance of the standard template with the indicated name, or false otherwise. More... | |
virtual bool | is_template_def () const |
Returns true if this node represents the definition of some template. More... | |
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). More... | |
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. More... | |
virtual void | write_text (std::ostream &out, int indent_level) const |
Writes a suitable representation of this node to an .x file in text mode. More... | |
Public Member Functions inherited from TypedObject | |
TypedObject (const TypedObject ©)=default | |
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... | |
TypedObject & | operator= (const TypedObject ©)=default |
Public Member Functions inherited from Namable | |
Namable (const std::string &initial_name="") | |
void | clear_name () |
Resets the Namable's name to empty. More... | |
const std::string & | get_name () const |
bool | has_name () const |
Returns true if the Namable has a nonempty name set, false if the name is empty. More... | |
void | output (std::ostream &out) const |
Outputs the Namable. More... | |
void | set_name (const std::string &name) |
Public Member Functions inherited from ReferenceCount | |
int | get_ref_count () const |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | ref_if_nonzero () const |
Atomically increases the reference count of this object if it is not zero. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
WeakReferenceList * | weak_ref () |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref () |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
static std::string | make_nice_name (const std::string &str) |
Transforms the indicated egg name to a name that is acceptable for a node in the X File format. More... | |
Static Public Member Functions inherited from TypedObject | |
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 Member Functions inherited from Namable | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from ReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
Friends | |
class | XFileDataNodeReference |
Additional Inherited Members | |
Public Attributes inherited from TypedObject | |
get_type | |
Public Attributes inherited from Namable | |
get_name | |
set_name | |
Public Attributes inherited from ReferenceCount | |
get_ref_count | |
Returns the current reference count. More... | |
A single node of an X file.
This may be either a template or a data node.
Definition at line 39 of file xFileNode.h.
void XFileNode::add_child | ( | XFileNode * | node | ) |
Adds the indicated node as a child of this node.
Definition at line 191 of file xFileNode.cxx.
References downcase(), get_guid(), has_guid(), Namable::has_name(), and TypedObject::is_of_type().
XFileDataNode * XFileNode::add_Frame | ( | const std::string & | name | ) |
Creates a new Frame instance, as a child of this node.
Definition at line 421 of file xFileNode.cxx.
References XFile::find_standard_template().
XFileDataNode * XFileNode::add_FrameTransformMatrix | ( | const LMatrix4d & | mat | ) |
Creates a new FrameTransformMatrix instance, as a child of this node.
Definition at line 436 of file xFileNode.cxx.
XFileDataNode * XFileNode::add_Material | ( | const std::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 375 of file xFileNode.cxx.
References XFile::find_standard_template().
Referenced by XFileMaterial::make_x_material().
XFileDataNode * XFileNode::add_Mesh | ( | const std::string & | name | ) |
Creates a new Mesh instance, as a child of this node.
Definition at line 300 of file xFileNode.cxx.
References XFile::find_standard_template().
Referenced by XFileMesh::make_x_mesh().
XFileDataNode * XFileNode::add_MeshMaterialList | ( | const std::string & | name | ) |
Creates a new MeshMaterialList instance, as a child of this node.
Definition at line 360 of file xFileNode.cxx.
References XFile::find_standard_template().
Referenced by XFileMesh::make_x_material_list().
XFileDataNode * XFileNode::add_MeshNormals | ( | const std::string & | name | ) |
Creates a new MeshNormals instance, as a child of this node.
Definition at line 315 of file xFileNode.cxx.
References XFile::find_standard_template().
Referenced by XFileMesh::make_x_normals().
XFileDataNode * XFileNode::add_MeshTextureCoords | ( | const std::string & | name | ) |
Creates a new MeshTextureCoords instance, as a child of this node.
Definition at line 345 of file xFileNode.cxx.
References XFile::find_standard_template().
Referenced by XFileMesh::make_x_uvs().
XFileDataNode * XFileNode::add_MeshVertexColors | ( | const std::string & | name | ) |
Creates a new MeshVertexColors instance, as a child of this node.
Definition at line 330 of file xFileNode.cxx.
References XFile::find_standard_template().
Referenced by XFileMesh::make_x_colors().
XFileDataNode * XFileNode::add_TextureFilename | ( | const std::string & | name, |
const Filename & | filename | ||
) |
Creates a new TextureFilename instance, as a child of this node.
Definition at line 404 of file xFileNode.cxx.
References XFile::find_standard_template().
Referenced by XFileMaterial::make_x_material().
|
virtual |
Removes all children from the node, and otherwise resets it to its initial state.
Reimplemented in XFileDataDef, XFile, and XFileTemplate.
Definition at line 209 of file xFileNode.cxx.
Referenced by XFile::clear(), XFileTemplate::clear(), and XFileDataDef::clear().
|
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 261 of file xFileNode.cxx.
Referenced by XFileDataDef::fill_zero_data().
XFileNode * XFileNode::find_child | ( | const std::string & | name | ) | const |
Returns the child with the indicated name, if any, or NULL if none.
Definition at line 55 of file xFileNode.cxx.
References downcase(), and get_child().
Referenced by find_descendent(), and XFile::find_template().
int XFileNode::find_child_index | ( | const std::string & | name | ) | const |
Returns the index number of the child with the indicated name, if any, or -1 if none.
Definition at line 70 of file xFileNode.cxx.
References downcase().
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 84 of file xFileNode.cxx.
XFileNode * XFileNode::find_descendent | ( | const std::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 99 of file xFileNode.cxx.
References find_child(), and find_descendent().
Referenced by XFile::find_data_object(), and find_descendent().
|
inline |
Returns the nth child of this node.
This list includes templates as well as data objects.
Definition at line 36 of file xFileNode.I.
Referenced by find_child().
|
virtual |
If has_guid() returned true, returns the particular GUID associated with this node.
Reimplemented in XFileTemplate.
Definition at line 129 of file xFileNode.cxx.
Referenced by add_child().
|
inline |
Returns the list of children of this node.
This list includes templates as well as data objects.
Definition at line 27 of file xFileNode.I.
Referenced by matches().
|
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 47 of file xFileNode.I.
|
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 57 of file xFileNode.I.
|
virtual |
Returns true if this node has a GUID associated.
Reimplemented in XFileTemplate.
Definition at line 120 of file xFileNode.cxx.
Referenced by add_child().
|
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 170 of file xFileNode.cxx.
|
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 157 of file xFileNode.cxx.
|
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 183 of file xFileNode.cxx.
|
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 143 of file xFileNode.cxx.
|
static |
Transforms the indicated egg name to a name that is acceptable for a node in the X File format.
Definition at line 474 of file xFileNode.cxx.
|
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 278 of file xFileNode.cxx.
References get_num_children().
Referenced by XFileTemplate::matches(), and XFileDataDef::matches().
|
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 236 of file xFileNode.cxx.
Referenced by XFileDataDef::repack_data().
|
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 219 of file xFileNode.cxx.
Referenced by XFileTemplate::write_text(), and XFileDataNodeTemplate::write_text().