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