Panda3D

xFileDataNodeTemplate.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 xFileDataNodeTemplate.h
10 * @author drose
11 * @date 2004-10-03
12 */
13
14 #ifndef XFILEDATANODETEMPLATE_H
15 #define XFILEDATANODETEMPLATE_H
16
17 #include "pandatoolbase.h"
18 #include "xFileDataNode.h"
19 #include "xFileTemplate.h"
20 #include "xFileParseData.h"
21 #include "pointerTo.h"
22 #include "pta_int.h"
23 #include "pta_double.h"
24
25 /**
26 * This is a node which contains all of the data elements defined by a
27 * template. See XFileTemplate for the definition of the template; this class
28 * only contains the data members for a particular instance of a template.
29 */
30 class XFileDataNodeTemplate : public XFileDataNode {
31 public:
32 XFileDataNodeTemplate(XFile *x_file, const std::string &name,
33 XFileTemplate *xtemplate);
34
35 void zero_fill();
36
37 virtual bool is_complex_object() const;
38
39 void add_parse_double(PTA_double double_list);
40 void add_parse_int(PTA_int int_list);
41 void add_parse_string(const std::string &str);
42 bool finalize_parse_data();
43
44 virtual bool add_element(XFileDataObject *element);
45
46 virtual void write_text(std::ostream &out, int indent_level) const;
47 virtual void write_data(std::ostream &out, int indent_level,
48 const char *separator) const;
49
50 protected:
51 virtual int get_num_elements() const;
52 virtual XFileDataObject *get_element(int n);
53 virtual XFileDataObject *get_element(const std::string &name);
54
55 private:
56 XFileParseDataList _parse_data_list;
57
58 typedef pvector< PT(XFileDataObject) > NestedElements;
59 NestedElements _nested_elements;
60
61 public:
62 static TypeHandle get_class_type() {
63 return _type_handle;
64 }
65 static void init_type() {
66 XFileDataNode::init_type();
67 register_type(_type_handle, "XFileDataNodeTemplate",
68 XFileDataNode::get_class_type());
69 }
70 virtual TypeHandle get_type() const {
71 return get_class_type();
72 }
73 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
74
75 private:
76 static TypeHandle _type_handle;
77 };
78
79 #include "xFileDataNodeTemplate.I"
80
81 #endif
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
XFileDataNodeTemplate
This is a node which contains all of the data elements defined by a template.
Definition: xFileDataNodeTemplate.h:30
XFileDataNodeTemplate::write_data
virtual void write_data(std::ostream &out, int indent_level, const char *separator) const
Writes a suitable representation of this node to an .x file in text mode.
Definition: xFileDataNodeTemplate.cxx:154
XFileDataNodeTemplate::finalize_parse_data
bool finalize_parse_data()
Processes all of the data elements added by add_parse_*(), checks them for syntactic and semantic cor...
Definition: xFileDataNodeTemplate.cxx:97
XFileDataNodeTemplate::add_parse_double
void add_parse_double(PTA_double double_list)
Adds the indicated list of doubles as a data element encountered in the parser.
Definition: xFileDataNodeTemplate.cxx:56
XFileDataNodeTemplate::add_element
virtual bool add_element(XFileDataObject *element)
Adds the indicated element as a nested data element, if this data object type supports it.
Definition: xFileDataNodeTemplate.cxx:123
XFileDataNodeTemplate::zero_fill
void zero_fill()
Fills the data node with zero-valued elements appropriate to the template.
Definition: xFileDataNodeTemplate.cxx:38
XFileDataNodeTemplate::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: xFileDataNodeTemplate.cxx:47
XFileDataNodeTemplate::add_parse_int
void add_parse_int(PTA_int int_list)
Adds the indicated list of ints as a data element encountered in the parser.
Definition: xFileDataNodeTemplate.cxx:69
XFileDataNodeTemplate::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: xFileDataNodeTemplate.cxx:132
XFileDataNodeTemplate::add_parse_string
void add_parse_string(const std::string &str)
Adds the indicated string as a data element encountered in the parser.
Definition: xFileDataNodeTemplate.cxx:82
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
XFileParseDataList
A container for a pvector of the above objects.
Definition: xFileParseData.h:62
XFileTemplate
A template definition in the X file.
Definition: xFileTemplate.h:27
XFile
This represents the complete contents of an X file (file.x) in memory.
Definition: xFile.h:32
pvector
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_double.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_int.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
xFileDataNodeTemplate.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
xFileDataNode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
xFileParseData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
xFileTemplate.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.