Panda3D
xFileTemplate.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 xFileTemplate.h
10 * @author drose
11 * @date 2004-10-03
12 */
13
14#ifndef XFILETEMPLATE_H
15#define XFILETEMPLATE_H
16
17#include "pandatoolbase.h"
18#include "xFileNode.h"
19#include "windowsGuid.h"
20
21class XFileDataDef;
22
23/**
24 * A template definition in the X file. This defines the data structures that
25 * may be subsequently read.
26 */
27class XFileTemplate : public XFileNode {
28public:
29 XFileTemplate(XFile *x_file, const std::string &name, const WindowsGuid &guid);
30 virtual ~XFileTemplate();
31
32 virtual bool has_guid() const;
33 virtual const WindowsGuid &get_guid() const;
34
35 virtual bool is_template_def() const;
36
37 virtual void clear();
38 virtual void write_text(std::ostream &out, int indent_level) const;
39
40 INLINE bool is_standard() const;
41
42 INLINE void set_open(bool open);
43 INLINE bool get_open() const;
44
45 INLINE void add_option(XFileTemplate *option);
46 INLINE int get_num_options() const;
47 INLINE XFileTemplate *get_option(int n) const;
48
49 virtual bool matches(const XFileNode *other) const;
50
51private:
52 WindowsGuid _guid;
53 bool _is_standard;
54 bool _open;
55
56 typedef pvector< PT(XFileTemplate) > Options;
57 Options _options;
58
59public:
60 static TypeHandle get_class_type() {
61 return _type_handle;
62 }
63 static void init_type() {
64 XFileNode::init_type();
65 register_type(_type_handle, "XFileTemplate",
66 XFileNode::get_class_type());
67 }
68 virtual TypeHandle get_type() const {
69 return get_class_type();
70 }
71 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
72
73private:
74 static TypeHandle _type_handle;
75
76 friend class XFile;
77};
78
79#include "xFileTemplate.I"
80
81#endif
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
This is an implementation of the Windows GUID object, used everywhere as a world-unique identifier fo...
Definition: windowsGuid.h:26
A definition of a single data element appearing within a template record.
Definition: xFileDataDef.h:31
A single node of an X file.
Definition: xFileNode.h:40
A template definition in the X file.
Definition: xFileTemplate.h:27
void set_open(bool open)
Sets whether the template is considered "open" or not.
Definition: xFileTemplate.I:31
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:51
virtual bool matches(const XFileNode *other) const
Returns true if the node, particularly a template node, is structurally equivalent to the other node ...
virtual bool has_guid() const
Returns true if this node has a GUID associated.
int get_num_options() const
Returns the number of templates on the options list.
Definition: xFileTemplate.I:59
XFileTemplate * get_option(int n) const
Returns the nth template on the options list.
Definition: xFileTemplate.I:67
virtual bool is_template_def() const
Returns true if this node represents the definition of some template.
virtual const WindowsGuid & get_guid() const
Returns the GUID associated with this template.
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.
bool is_standard() const
Returns true if this particular template is one of the "standard" templates defined by standardTempla...
Definition: xFileTemplate.I:20
virtual void clear()
Removes all children from the node, and otherwise resets it to its initial state.
bool get_open() const
Returns whether the template is considered "open" or not.
Definition: xFileTemplate.I:42
This represents the complete contents of an X file (file.x) in memory.
Definition: xFile.h:32
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.