Panda3D
xFileDataNode.h
1 // Filename: xFileDataNode.h
2 // Created by: drose (08Oct04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef XFILEDATANODE_H
16 #define XFILEDATANODE_H
17 
18 #include "pandatoolbase.h"
19 #include "xFileNode.h"
20 #include "xFileDataObject.h"
21 #include "xFileTemplate.h"
22 #include "pointerTo.h"
23 #include "dcast.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : XFileDataNode
27 // Description : This is an abstract base class for an XFileNode which
28 // is also an XFileDataObject. That is to say, objects
29 // that inherit from this class may be added to the
30 // toplevel X file graph as nodes, and they also may be
31 // containers for data elements.
32 //
33 // Specifically, this is the base class of both
34 // XFileDataNodeTemplate and XFileDataNodeReference.
35 ////////////////////////////////////////////////////////////////////
36 class XFileDataNode : public XFileNode, public XFileDataObject {
37 public:
38  XFileDataNode(XFile *x_file, const string &name,
39  XFileTemplate *xtemplate);
40 
41  virtual bool is_object() const;
42  virtual bool is_standard_object(const string &template_name) const;
43  virtual string get_type_name() const;
44 
45  INLINE const XFileDataNode &get_data_child(int n) const;
46 
47  INLINE XFileTemplate *get_template() const;
48  INLINE const string &get_template_name() const;
49 
50 protected:
51  PT(XFileTemplate) _template;
52 
53 public:
54  static TypeHandle get_class_type() {
55  return _type_handle;
56  }
57  static void init_type() {
58  XFileNode::init_type();
59  XFileDataObject::init_type();
60  register_type(_type_handle, "XFileDataNode",
61  XFileNode::get_class_type(),
62  XFileDataObject::get_class_type());
63  }
64  virtual TypeHandle get_type() const {
65  return get_class_type();
66  }
67  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
68 
69 private:
70  static TypeHandle _type_handle;
71 };
72 
73 #include "xFileDataNode.I"
74 
75 #endif
76 
77 
78 
79 
const string & get_template_name() const
A convenience function to return the name of the template used to define this data object...
Definition: xFileDataNode.I:53
A single node of an X file.
Definition: xFileNode.h:42
XFileTemplate * get_template() const
Returns the template used to define this data object.
Definition: xFileDataNode.I:42
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 string get_type_name() const
Returns a string that represents the type of object this data object represents.
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...
This is an abstract base class for an XFileNode which is also an XFileDataObject. ...
Definition: xFileDataNode.h:36
This represents the complete contents of an X file (file.x) in memory.
Definition: xFile.h:35
A template definition in the X file.
Definition: xFileTemplate.h:29
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
const XFileDataNode & get_data_child(int n) const
Since the children of an XFileDataNode are syntactically constrained to themselves be XFileDataNodes...
Definition: xFileDataNode.I:26
The abstract base class for a number of different types of data elements that may be stored in the X ...