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  */
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
virtual bool add_element(XFileDataObject *element)
Adds the indicated element as a nested data element, if this data object type supports it.
void add_parse_double(PTA_double double_list)
Adds the indicated list of doubles as a data element encountered in the parser.
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(),...
Definition: register_type.I:22
void zero_fill()
Fills the data node with zero-valued elements appropriate to the template.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_parse_int(PTA_int int_list)
Adds the indicated list of ints as a data element encountered in the parser.
This is a node which contains all of the data elements defined by a template.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
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.
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.
virtual bool is_complex_object() const
Returns true if this kind of data object is a complex object that can hold nested data elements,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool finalize_parse_data()
Processes all of the data elements added by add_parse_*(), checks them for syntactic and semantic cor...
A container for a pvector of the above objects.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract base class for an XFileNode which is also an XFileDataObject.
Definition: xFileDataNode.h:33
This represents the complete contents of an X file (file.x) in memory.
Definition: xFile.h:32
A template definition in the X file.
Definition: xFileTemplate.h:27
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_parse_string(const std::string &str)
Adds the indicated string as a data element encountered in the parser.
The abstract base class for a number of different types of data elements that may be stored in the X ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.