Panda3D

xFileDataNodeReference.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 xFileDataNodeReference.h
10 * @author drose
11 * @date 2004-10-08
12 */
13
14 #ifndef XFILEDATANODEREFERENCE_H
15 #define XFILEDATANODEREFERENCE_H
16
17 #include "pandatoolbase.h"
18 #include "xFileDataNodeTemplate.h"
19 #include "pointerTo.h"
20
21 /**
22 * This is a nested reference to an instance of a template object, declared
23 * via the syntax:
24 *
25 * { InstanceName }
26 *
27 * in the X File.
28 */
29 class XFileDataNodeReference : public XFileDataNode {
30 public:
31 XFileDataNodeReference(XFileDataNodeTemplate *object);
32
33 INLINE XFileTemplate *get_template() const;
34 INLINE XFileDataNodeTemplate *get_object() const;
35
36 virtual bool is_reference() const;
37 virtual bool is_complex_object() const;
38
39 virtual void write_text(std::ostream &out, int indent_level) const;
40
41 protected:
42 virtual int get_num_elements() const;
43 virtual XFileDataObject *get_element(int n);
44 virtual XFileDataObject *get_element(const std::string &name);
45
46 private:
47 PT(XFileDataNodeTemplate) _object;
48
49 public:
50 static TypeHandle get_class_type() {
51 return _type_handle;
52 }
53 static void init_type() {
54 XFileDataNode::init_type();
55 register_type(_type_handle, "XFileDataNodeReference",
56 XFileDataNode::get_class_type());
57 }
58 virtual TypeHandle get_type() const {
59 return get_class_type();
60 }
61 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
62
63 private:
64 static TypeHandle _type_handle;
65 };
66
67 #include "xFileDataNodeReference.I"
68
69 #endif
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
XFileDataNodeReference
This is a nested reference to an instance of a template object, declared via the syntax:
Definition: xFileDataNodeReference.h:29
XFileDataNodeReference::write_text
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.
Definition: xFileDataNodeReference.cxx:65
XFileDataNodeReference::get_object
XFileDataNodeTemplate * get_object() const
Returns the actual data object being referenced.
Definition: xFileDataNodeReference.I:18
XFileDataNodeReference::is_complex_object
virtual bool is_complex_object() const
Returns true if this kind of data object is a complex object that can hold nested data elements,...
Definition: xFileDataNodeReference.cxx:57
XFileDataNodeReference::is_reference
virtual bool is_reference() const
Returns true if this node represents an indirect reference to an object defined previously in the fil...
Definition: xFileDataNodeReference.cxx:48
XFileDataNodeTemplate
This is a node which contains all of the data elements defined by a template.
Definition: xFileDataNodeTemplate.h:30
XFileDataNode
This is an abstract base class for an XFileNode which is also an XFileDataObject.
Definition: xFileDataNode.h:33
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
XFileTemplate
A template definition in the X file.
Definition: xFileTemplate.h:27
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.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
xFileDataNodeReference.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
xFileDataNodeTemplate.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.