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

A definition of a single data element appearing within a template record. More...

#include "xFileDataDef.h"

Inheritance diagram for XFileDataDef:
XFileNode TypedObject Namable ReferenceCount MemoryBase MemoryBase MemoryBase

Public Types

enum  Type {
  T_word, T_dword, T_float, T_double,
  T_char, T_uchar, T_sword, T_sdword,
  T_string, T_cstring, T_unicode, T_template
}
 
- Public Types inherited from XFileNode
typedef pmap< const XFileDataDef *, XFileDataObject * > PrevData
 

Public Member Functions

 XFileDataDef (XFile *x_file, const std::string &name, Type type, XFileTemplate *xtemplate=nullptr)
 
void add_array_def (const XFileArrayDef &array_def)
 Adds an additional array dimension to the data description. 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...
 
virtual TypeHandle force_init_type ()
 
const XFileArrayDefget_array_def (int i) const
 Returns the description of the nth dimension of array elements on this data object. More...
 
Type get_data_type () const
 Returns the primitive type of this element, or T_template if this represents a nested template object. More...
 
int get_num_array_defs () const
 Returns the number of dimensions of array elements on this data object, or 0 if the data object is not an array. More...
 
XFileTemplateget_template () const
 If get_data_type() returned T_template, this returns the particular template pointer that this object represents. More...
 
virtual TypeHandle get_type () const
 
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 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...
 
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_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...
 
- 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...
 

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 ()
 

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...
 

Detailed Description

A definition of a single data element appearing within a template record.

This class represents the *definition* of the data element (e.g. DWORD nVertices); see XFileDataObject for its *value* (e.g. 12).

Definition at line 31 of file xFileDataDef.h.

Member Function Documentation

◆ add_array_def()

void XFileDataDef::add_array_def ( const XFileArrayDef array_def)

Adds an additional array dimension to the data description.

Definition at line 48 of file xFileDataDef.cxx.

◆ clear()

void XFileDataDef::clear ( )
virtual

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

Reimplemented from XFileNode.

Definition at line 39 of file xFileDataDef.cxx.

References XFileNode::clear().

◆ fill_zero_data()

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

Definition at line 192 of file xFileDataDef.cxx.

References XFileNode::fill_zero_data().

◆ get_array_def()

const XFileArrayDef & XFileDataDef::get_array_def ( int  i) const
inline

Returns the description of the nth dimension of array elements on this data object.

Definition at line 58 of file xFileDataDef.I.

◆ get_data_type()

XFileDataDef::Type XFileDataDef::get_data_type ( ) const
inline

Returns the primitive type of this element, or T_template if this represents a nested template object.

Definition at line 31 of file xFileDataDef.I.

◆ get_num_array_defs()

int XFileDataDef::get_num_array_defs ( ) const
inline

Returns the number of dimensions of array elements on this data object, or 0 if the data object is not an array.

Definition at line 49 of file xFileDataDef.I.

◆ get_template()

XFileTemplate * XFileDataDef::get_template ( ) const
inline

If get_data_type() returned T_template, this returns the particular template pointer that this object represents.

Definition at line 40 of file xFileDataDef.I.

◆ matches()

bool XFileDataDef::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 235 of file xFileDataDef.cxx.

References XFileNode::matches().

◆ repack_data()

bool XFileDataDef::repack_data ( XFileDataObject object,
const XFileParseDataList parse_data_list,
XFileDataDef::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 from XFileNode.

Definition at line 135 of file xFileDataDef.cxx.

References XFileNode::repack_data().

◆ write_text()

void XFileDataDef::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 56 of file xFileDataDef.cxx.

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


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