Panda3D
xFileDataNodeTemplate.h
1 // Filename: xFileDataNodeTemplate.h
2 // Created by: drose (03Oct04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef XFILEDATANODETEMPLATE_H
16 #define XFILEDATANODETEMPLATE_H
17 
18 #include "pandatoolbase.h"
19 #include "xFileDataNode.h"
20 #include "xFileTemplate.h"
21 #include "xFileParseData.h"
22 #include "pointerTo.h"
23 #include "pta_int.h"
24 #include "pta_double.h"
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : XFileDataNodeTemplate
28 // Description : This is a node which contains all of the data
29 // elements defined by a template. See XFileTemplate
30 // for the definition of the template; this class only
31 // contains the data members for a particular instance
32 // of a template.
33 ////////////////////////////////////////////////////////////////////
35 public:
36  XFileDataNodeTemplate(XFile *x_file, const string &name,
37  XFileTemplate *xtemplate);
38 
39  void zero_fill();
40 
41  virtual bool is_complex_object() const;
42 
43  void add_parse_double(PTA_double double_list);
44  void add_parse_int(PTA_int int_list);
45  void add_parse_string(const string &str);
46  bool finalize_parse_data();
47 
48  virtual bool add_element(XFileDataObject *element);
49 
50  virtual void write_text(ostream &out, int indent_level) const;
51  virtual void write_data(ostream &out, int indent_level,
52  const char *separator) const;
53 
54 protected:
55  virtual int get_num_elements() const;
56  virtual XFileDataObject *get_element(int n);
57  virtual XFileDataObject *get_element(const string &name);
58 
59 private:
60  XFileParseDataList _parse_data_list;
61 
63  NestedElements _nested_elements;
64 
65 public:
66  static TypeHandle get_class_type() {
67  return _type_handle;
68  }
69  static void init_type() {
70  XFileDataNode::init_type();
71  register_type(_type_handle, "XFileDataNodeTemplate",
72  XFileDataNode::get_class_type());
73  }
74  virtual TypeHandle get_type() const {
75  return get_class_type();
76  }
77  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
78 
79 private:
80  static TypeHandle _type_handle;
81 };
82 
83 #include "xFileDataNodeTemplate.I"
84 
85 #endif
86 
87 
88 
89 
virtual bool add_element(XFileDataObject *element)
Adds the indicated element as a nested data element, if this data object type supports it...
virtual void write_text(ostream &out, int indent_level) const
Writes a suitable representation of this node to an .x file in text mode.
void add_parse_double(PTA_double double_list)
Adds the indicated list of doubles as a data element encountered in the parser.
void zero_fill()
Fills the data node with zero-valued elements appropriate to the template.
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.
virtual void write_data(ostream &out, int indent_level, const char *separator) const
Writes a suitable representation of this node to an .x file in text mode.
void add_parse_string(const string &str)
Adds the indicated string as a data element encountered in the parser.
virtual bool is_complex_object() const
Returns true if this kind of data object is a complex object that can hold nested data elements...
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.
This is an abstract base class for an XFileNode which is also an XFileDataObject. ...
Definition: xFileDataNode.h:36
This represents the complete contents of an X file (file.x) in memory.
Definition: xFile.h:35
A template definition in the X file.
Definition: xFileTemplate.h:29
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
The abstract base class for a number of different types of data elements that may be stored in the X ...