Panda3D

Public Member Functions | Static Public Member Functions | Friends | List of all members
XFileTemplate Class Reference

A template definition in the X file. More...

`#include "xFileTemplate.h"`

Inheritance diagram for XFileTemplate:

## Public Member Functions
| XFileTemplate (XFile *x_file, const std::string &name, const WindowsGuid &guid)
void | add_option (XFileTemplate *option)
| Adds a new type to the list of allowable types of child nodes for an instance of this template. More...
virtual void | clear ()
| Removes all children from the node, and otherwise resets it to its initial state. More...
virtual TypeHandle | force_init_type ()
virtual const WindowsGuid & | get_guid () const
| Returns the GUID associated with this template. More...
int | get_num_options () const
| Returns the number of templates on the options list. More...
bool | get_open () const
| Returns whether the template is considered "open" or not. More...
XFileTemplate * | get_option (int n) const
| Returns the nth template on the options list. More...
virtual TypeHandle | get_type () const
virtual bool | has_guid () const
| Returns true if this node has a GUID associated. More...
bool | is_standard () const
| Returns true if this particular template is one of the "standard" templates defined by standardTemplates.x in this directory (and compiled into the binary), or false if it is a user-custom template. 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...
void | set_open (bool open)
| Sets whether the template is considered "open" or not. 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 XFileNode
| 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 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...
XFileNode * | get_child (int n) const
| Returns the nth child of 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...
XFile * | get_x_file () const
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 | 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...
Public Member Functions inherited from TypedObject
| TypedObject (const TypedObject &copy)=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 &copy)=default
Public Member Functions inherited from MemoryBase
void | operator delete (void *, void *)
void | operator delete (void *ptr)
void | operator delete[] (void *, void *)
void | operator delete[] (void *ptr)
void * | operator new (size_t size)
void * | operator new (size_t size, void *ptr)
void * | operator new[] (size_t size)
void * | operator new[] (size_t size, void *ptr)
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...
bool | unref_if_one () const
| Atomically decreases the reference count of this object if it is one. 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 Public Member Functions inherited from XFileNode
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 | XFile

## Additional Inherited Members
Public Types inherited from XFileNode
typedef pmap< const XFileDataDef *, XFileDataObject * > | PrevData
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...

## Detailed Description

A template definition in the X file.

This defines the data structures that may be subsequently read.

Definition at line 27 of file xFileTemplate.h.

## Member Function Documentation

## ◆ add_option()

void XFileTemplate::add_option | ( | XFileTemplate * | option | ) |
| inline

Adds a new type to the list of allowable types of child nodes for an instance of this template.

Definition at line 50 of file xFileTemplate.I.

## ◆ clear()

void XFileTemplate::clear | ( |  | ) |
| virtual

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

Reimplemented from XFileNode.

Definition at line 72 of file xFileTemplate.cxx.

References XFileNode::clear().

## ◆ get_guid()

const WindowsGuid & XFileTemplate::get_guid | ( |  | ) | const
| virtual

Returns the GUID associated with this template.

Reimplemented from XFileNode.

Definition at line 50 of file xFileTemplate.cxx.

Referenced by write_text().

## ◆ get_num_options()

int XFileTemplate::get_num_options | ( |  | ) | const
| inline

Returns the number of templates on the options list.

Definition at line 58 of file xFileTemplate.I.

## ◆ get_open()

bool XFileTemplate::get_open | ( |  | ) | const
| inline

Returns whether the template is considered "open" or not.

If it is open (this flag is true), the set of options is ignored and the instances of this template may include any types of children. If it is closed (false), only the named types may be added.

Definition at line 41 of file xFileTemplate.I.

Referenced by write_text().

## ◆ get_option()

XFileTemplate * XFileTemplate::get_option | ( | int | n | ) | const
| inline

Returns the nth template on the options list.

Definition at line 66 of file xFileTemplate.I.

## ◆ has_guid()

bool XFileTemplate::has_guid | ( |  | ) | const
| virtual

Returns true if this node has a GUID associated.

Reimplemented from XFileNode.

Definition at line 42 of file xFileTemplate.cxx.

## ◆ is_standard()

bool XFileTemplate::is_standard | ( |  | ) | const
| inline

Returns true if this particular template is one of the "standard" templates defined by standardTemplates.x in this directory (and compiled into the binary), or false if it is a user-custom template.

Definition at line 19 of file xFileTemplate.I.

## ◆ is_template_def()

bool XFileTemplate::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 from XFileNode.

Definition at line 63 of file xFileTemplate.cxx.

## ◆ matches()

bool XFileTemplate::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 from XFileNode.

Definition at line 120 of file xFileTemplate.cxx.

References XFileNode::matches().

## ◆ set_open()

void XFileTemplate::set_open | ( | bool | open | ) |
| inline

Sets whether the template is considered "open" or not.

If it is open (this flag is true), the set of options is ignored and the instances of this template may include any types of children. If it is closed (false), only the named types may be added.

Definition at line 30 of file xFileTemplate.I.

## ◆ write_text()

void XFileTemplate::write_text | ( | std::ostream & | out,
|  | int | indent_level
| ) |  | const
| virtual

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

Reimplemented from XFileNode.

Definition at line 81 of file xFileTemplate.cxx.

References get_guid(), get_open(), indent(), and XFileNode::write_text().

The documentation for this class was generated from the following files:

- pandatool/src/xfile/xFileTemplate.h
- pandatool/src/xfile/xFileTemplate.cxx
- pandatool/src/xfile/xFileTemplate.I