Panda3D
Loading...
Searching...
No Matches
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 */
33class XFileDataNode : public XFileNode, public XFileDataObject {
34public:
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
47protected:
48 PT(XFileTemplate) _template;
49
50public:
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
66private:
67 static TypeHandle _type_handle;
68};
69
70#include "xFileDataNode.I"
71
72#endif
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
This is an abstract base class for an XFileNode which is also an XFileDataObject.
const XFileDataNode & get_data_child(int n) const
Since the children of an XFileDataNode are syntactically constrained to themselves be XFileDataNodes,...
virtual bool is_object() const
Returns true if this node represents a data object that is the instance of some template,...
virtual std::string get_type_name() const
Returns a string that represents the type of object this data object represents.
const std::string & get_template_name() const
A convenience function to return the name of the template used to define this data object.
XFileTemplate * get_template() const
Returns the template used to define this data 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,...
The abstract base class for a number of different types of data elements that may be stored in the X ...
A single node of an X file.
Definition xFileNode.h:40
A template definition in the X file.
This represents the complete contents of an X file (file.x) in memory.
Definition xFile.h:32
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.