Panda3D
Public Member Functions | Static Public Member Functions | List of all members
XFileDataNodeTemplate Class Reference

This is a node which contains all of the data elements defined by a template. More...

#include "xFileDataNodeTemplate.h"

Inheritance diagram for XFileDataNodeTemplate:
XFileDataNode XFileNode XFileDataObject TypedObject Namable ReferenceCount ReferenceCount MemoryBase MemoryBase MemoryBase MemoryBase

Public Member Functions

 XFileDataNodeTemplate (XFile *x_file, const std::string &name, XFileTemplate *xtemplate)
 
virtual bool add_element (XFileDataObject *element)
 Adds the indicated element as a nested data element, if this data object type supports it. More...
 
void add_parse_double (PTA_double double_list)
 Adds the indicated list of doubles as a data element encountered in the parser. More...
 
void add_parse_int (PTA_int int_list)
 Adds the indicated list of ints as a data element encountered in the parser. More...
 
void add_parse_string (const std::string &str)
 Adds the indicated string as a data element encountered in the parser. More...
 
bool finalize_parse_data ()
 Processes all of the data elements added by add_parse_*(), checks them for syntactic and semantic correctness against the Template definition, and stores the appropriate child data elements. More...
 
virtual TypeHandle force_init_type ()
 
virtual TypeHandle get_type () const
 
virtual bool is_complex_object () const
 Returns true if this kind of data object is a complex object that can hold nested data elements, false otherwise. More...
 
virtual void write_data (std::ostream &out, int indent_level, const char *separator) const
 Writes a suitable representation of this node to an .x file in text mode. 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...
 
void zero_fill ()
 Fills the data node with zero-valued elements appropriate to the template. More...
 
- Public Member Functions inherited from XFileDataNode
 XFileDataNode (XFile *x_file, const std::string &name, XFileTemplate *xtemplate)
 
const XFileDataNodeget_data_child (int n) const
 Since the children of an XFileDataNode are syntactically constrained to themselves be XFileDataNodes, this is a convenience function that returns the same thing as XFileNode::get_child(), but it is cast to a type XFileDataNode and dereferenced. More...
 
XFileTemplateget_template () const
 Returns the template used to define this data object. More...
 
const std::string & get_template_name () const
 A convenience function to return the name of the template used to define this data object. More...
 
virtual std::string get_type_name () const
 Returns a string that represents the type of object this data object represents. 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_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...
 
- 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...
 
XFileDataNodeadd_Frame (const std::string &name)
 Creates a new Frame instance, as a child of this node. More...
 
XFileDataNodeadd_FrameTransformMatrix (const LMatrix4d &mat)
 Creates a new FrameTransformMatrix instance, as a child of this node. More...
 
XFileDataNodeadd_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...
 
XFileDataNodeadd_Mesh (const std::string &name)
 Creates a new Mesh instance, as a child of this node. More...
 
XFileDataNodeadd_MeshMaterialList (const std::string &name)
 Creates a new MeshMaterialList instance, as a child of this node. More...
 
XFileDataNodeadd_MeshNormals (const std::string &name)
 Creates a new MeshNormals instance, as a child of this node. More...
 
XFileDataNodeadd_MeshTextureCoords (const std::string &name)
 Creates a new MeshTextureCoords instance, as a child of this node. More...
 
XFileDataNodeadd_MeshVertexColors (const std::string &name)
 Creates a new MeshVertexColors instance, as a child of this node. More...
 
XFileDataNodeadd_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...
 
XFileNodefind_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...
 
XFileNodefind_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...
 
XFileNodeget_child (int n) const
 Returns the nth child of this node. More...
 
virtual const WindowsGuidget_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...
 
XFileDataNodeget_object (int n) const
 Returns the nth child object of this node. More...
 
XFileget_x_file () const
 
virtual bool has_guid () const
 Returns true if this node has a GUID associated. 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_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...
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_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...
 
TypedObjectoperator= (const TypedObject &copy)=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
 
WeakReferenceListget_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...
 
WeakReferenceListweak_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...
 
- Public Member Functions inherited from XFileDataObject
 XFileDataObject (const XFileDataDef *data_def=nullptr)
 
XFileDataObjectadd_Coords2d (XFile *x_file, const LVecBase2d &coords)
 Appends a new Coords2d instance. More...
 
XFileDataObjectadd_double (double double_value)
 Appends a new floating-point value to the data object, if it makes sense to do so. More...
 
XFileDataObjectadd_IndexedColor (XFile *x_file, int index, const LColor &color)
 Appends a new IndexedColor instance. More...
 
XFileDataObjectadd_int (int int_value)
 Appends a new integer value to the data object, if it makes sense to do so. More...
 
XFileDataObjectadd_MeshFace (XFile *x_file)
 Appends a new MeshFace instance. More...
 
XFileDataObjectadd_string (const std::string &string_value)
 Appends a new string value to the data object, if it makes sense to do so. More...
 
XFileDataObjectadd_Vector (XFile *x_file, const LVecBase3d &vector)
 Appends a new Vector instance. More...
 
double d () const
 Unambiguously returns the object's representation as a double, or 0.0 if the object has no double representation. More...
 
const XFileDataDefget_data_def () const
 Returns the data object that this object is represented by, if any, or NULL if there is none. More...
 
int i () const
 Unambiguously returns the object's representation as an integer, or 0 if the object has no integer representation. More...
 
LMatrix4d mat4 () const
 Returns the object's representation as an LMatrix4d. More...
 
const XFileDataObjectoperator [] (int n) const
 Returns the nth nested object within this object. More...
 
const XFileDataObjectoperator [] (const std::string &name) const
 Returns the named nested object within this object. More...
 
XFileDataObjectoperator [] (int n)
 Returns the nth nested object within this object. More...
 
XFileDataObjectoperator [] (const std::string &name)
 Returns the named nested object within this object. More...
 
void operator= (int int_value)
 Stores the indicated integer value into the object, if it makes sense to do so. More...
 
void operator= (double double_value)
 Stores the indicated floating-point value into the object, if it makes sense to do so. More...
 
void operator= (const std::string &string_value)
 Stores the indicated string value into the object, if it makes sense to do so. More...
 
void operator= (const LVecBase2d &vec)
 Stores the indicated Vec2 value into the object, if it makes sense to do so. More...
 
void operator= (const LVecBase3d &vec)
 Stores the indicated Vec3 value into the object, if it makes sense to do so. More...
 
void operator= (const LVecBase4d &vec)
 Stores the indicated Vec4 value into the object, if it makes sense to do so. More...
 
void operator= (const LMatrix4d &mat)
 Stores the indicated Matrix value into the object, if it makes sense to do so. More...
 
virtual void output_data (std::ostream &out) const
 Writes a suitable representation of this node to an .x file in text mode. More...
 
std::string s () const
 Unambiguously returns the object's representation as a string, or empty string if the object has no string representation. More...
 
void set (int int_value)
 Stores the indicated integer value into the object, if it makes sense to do so. More...
 
void set (double double_value)
 Stores the indicated floating-point value into the object, if it makes sense to do so. More...
 
void set (const std::string &string_value)
 Stores the indicated string value into the object, if it makes sense to do so. More...
 
void set (const LVecBase2d &vec)
 Stores the indicated Vec2 value into the object, if it makes sense to do so. More...
 
void set (const LVecBase3d &vec)
 Stores the indicated Vec3 value into the object, if it makes sense to do so. More...
 
void set (const LVecBase4d &vec)
 Stores the indicated Vec4 value into the object, if it makes sense to do so. More...
 
void set (const LMatrix4d &mat)
 Stores the indicated Matrix value into the object, if it makes sense to do so. More...
 
int size () const
 Returns the number of nested data objects within this object. More...
 
LVecBase2d vec2 () const
 Returns the object's representation as an LVecBase2d. More...
 
LVecBase3d vec3 () const
 Returns the object's representation as an LVecBase3d. More...
 
LVecBase4d vec4 () const
 Returns the object's representation as an LVecBase4d. More...
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from XFileDataNode
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 ()
 
- Static Public Member Functions inherited from XFileDataObject
static TypeHandle get_class_type ()
 
static void init_type ()
 

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

This is a node which contains all of the data elements defined by a template.

See XFileTemplate for the definition of the template; this class only contains the data members for a particular instance of a template.

Definition at line 30 of file xFileDataNodeTemplate.h.

Member Function Documentation

◆ add_element()

bool XFileDataNodeTemplate::add_element ( XFileDataObject element)
virtual

Adds the indicated element as a nested data element, if this data object type supports it.

Returns true if added successfully, false if the data object type does not support nested data elements.

Reimplemented from XFileDataObject.

Definition at line 123 of file xFileDataNodeTemplate.cxx.

◆ add_parse_double()

void XFileDataNodeTemplate::add_parse_double ( PTA_double  double_list)

Adds the indicated list of doubles as a data element encountered in the parser.

It will later be processed by finalize_parse_data().

Definition at line 56 of file xFileDataNodeTemplate.cxx.

◆ add_parse_int()

void XFileDataNodeTemplate::add_parse_int ( PTA_int  int_list)

Adds the indicated list of ints as a data element encountered in the parser.

It will later be processed by finalize_parse_data().

Definition at line 69 of file xFileDataNodeTemplate.cxx.

◆ add_parse_string()

void XFileDataNodeTemplate::add_parse_string ( const std::string &  str)

Adds the indicated string as a data element encountered in the parser.

It will later be processed by finalize_parse_data().

Definition at line 82 of file xFileDataNodeTemplate.cxx.

◆ finalize_parse_data()

bool XFileDataNodeTemplate::finalize_parse_data ( )

Processes all of the data elements added by add_parse_*(), checks them for syntactic and semantic correctness against the Template definition, and stores the appropriate child data elements.

Returns true on success, false if there is a mismatch.

Definition at line 97 of file xFileDataNodeTemplate.cxx.

◆ is_complex_object()

bool XFileDataNodeTemplate::is_complex_object ( ) const
virtual

Returns true if this kind of data object is a complex object that can hold nested data elements, false otherwise.

Reimplemented from XFileDataObject.

Definition at line 47 of file xFileDataNodeTemplate.cxx.

◆ write_data()

void XFileDataNodeTemplate::write_data ( std::ostream &  out,
int  indent_level,
const char *  separator 
) const
virtual

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

Reimplemented from XFileDataObject.

Definition at line 154 of file xFileDataNodeTemplate.cxx.

References XFileDataObject::i(), indent(), and XFileDataObject::is_complex_object().

◆ write_text()

void XFileDataNodeTemplate::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 132 of file xFileDataNodeTemplate.cxx.

References Namable::has_name(), indent(), and XFileNode::write_text().

◆ zero_fill()

void XFileDataNodeTemplate::zero_fill ( )

Fills the data node with zero-valued elements appropriate to the template.

Definition at line 38 of file xFileDataNodeTemplate.cxx.


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