Panda3D
xFileTemplate.h
1 // Filename: xFileTemplate.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 XFILETEMPLATE_H
16 #define XFILETEMPLATE_H
17 
18 #include "pandatoolbase.h"
19 #include "xFileNode.h"
20 #include "windowsGuid.h"
21 
22 class XFileDataDef;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : XFileTemplate
26 // Description : A template definition in the X file. This defines
27 // the data structures that may be subsequently read.
28 ////////////////////////////////////////////////////////////////////
29 class XFileTemplate : public XFileNode {
30 public:
31  XFileTemplate(XFile *x_file, const string &name, const WindowsGuid &guid);
32  virtual ~XFileTemplate();
33 
34  virtual bool has_guid() const;
35  virtual const WindowsGuid &get_guid() const;
36 
37  virtual bool is_template_def() const;
38 
39  virtual void clear();
40  virtual void write_text(ostream &out, int indent_level) const;
41 
42  INLINE bool is_standard() const;
43 
44  INLINE void set_open(bool open);
45  INLINE bool get_open() const;
46 
47  INLINE void add_option(XFileTemplate *option);
48  INLINE int get_num_options() const;
49  INLINE XFileTemplate *get_option(int n) const;
50 
51  virtual bool matches(const XFileNode *other) const;
52 
53 private:
54  WindowsGuid _guid;
55  bool _is_standard;
56  bool _open;
57 
59  Options _options;
60 
61 public:
62  static TypeHandle get_class_type() {
63  return _type_handle;
64  }
65  static void init_type() {
66  XFileNode::init_type();
67  register_type(_type_handle, "XFileTemplate",
68  XFileNode::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  friend class XFile;
79 };
80 
81 #include "xFileTemplate.I"
82 
83 #endif
84 
85 
86 
virtual bool matches(const XFileNode *other) const
Returns true if the node, particularly a template node, is structurally equivalent to the other node ...
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_option(XFileTemplate *option)
Adds a new type to the list of allowable types of child nodes for an instance of this template...
Definition: xFileTemplate.I:65
This is an implementation of the Windows GUID object, used everywhere as a world-unique identifier fo...
Definition: windowsGuid.h:29
virtual bool has_guid() const
Returns true if this node has a GUID associated.
XFileTemplate * get_option(int n) const
Returns the nth template on the options list.
Definition: xFileTemplate.I:86
virtual bool is_template_def() const
Returns true if this node represents the definition of some template.
void set_open(bool open)
Sets whether the template is considered "open" or not.
Definition: xFileTemplate.I:40
A definition of a single data element appearing within a template record.
Definition: xFileDataDef.h:35
bool is_standard() const
Returns true if this particular template is one of the "standard" templates defined by standardTempla...
Definition: xFileTemplate.I:26
A single node of an X file.
Definition: xFileNode.h:42
virtual void clear()
Removes all children from the node, and otherwise resets it to its initial state. ...
virtual const WindowsGuid & get_guid() const
Returns the GUID associated with this template.
int get_num_options() const
Returns the number of templates on the options list.
Definition: xFileTemplate.I:76
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
bool get_open() const
Returns whether the template is considered "open" or not.
Definition: xFileTemplate.I:54