Panda3D
 All Classes Functions Variables Enumerations
xFileDataNode.cxx
1 // Filename: xFileDataNode.cxx
2 // Created by: drose (08Oct04)
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 #include "xFileDataNode.h"
16 #include "indent.h"
17 
18 TypeHandle XFileDataNode::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: XFileDataNode::Constructor
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 XFileDataNode::
26 XFileDataNode(XFile *x_file, const string &name,
27  XFileTemplate *xtemplate) :
28  XFileNode(x_file, name),
29  _template(xtemplate)
30 {
31 }
32 
33 ////////////////////////////////////////////////////////////////////
34 // Function: XFileDataNode::is_object
35 // Access: Public, Virtual
36 // Description: Returns true if this node represents a data object
37 // that is the instance of some template, or false
38 // otherwise. This also returns true for references to
39 // objects (which are generally treated just like the
40 // objects themselves).
41 //
42 // If this returns true, the node must be of type
43 // XFileDataNode (it is either an XFileDataNodeTemplate
44 // or an XFileDataNodeReference).
45 ////////////////////////////////////////////////////////////////////
46 bool XFileDataNode::
47 is_object() const {
48  return true;
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: XFileDataNode::is_standard_object
53 // Access: Public, Virtual
54 // Description: Returns true if this node represents an instance of
55 // the standard template with the indicated name, or
56 // false otherwise. If this returns true, the object
57 // must be of type XFileDataNode.
58 ////////////////////////////////////////////////////////////////////
59 bool XFileDataNode::
60 is_standard_object(const string &template_name) const {
61  if (_template->is_standard() &&
62  _template->get_name() == template_name) {
63  return true;
64  }
65 
66  return false;
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: XFileDataNode::get_type_name
71 // Access: Public, Virtual
72 // Description: Returns a string that represents the type of object
73 // this data object represents.
74 ////////////////////////////////////////////////////////////////////
75 string XFileDataNode::
76 get_type_name() const {
77  return _template->get_name();
78 }
virtual bool is_standard_object(const string &template_name) const
Returns true if this node represents an instance of the standard template with the indicated name...
virtual string get_type_name() const
Returns a string that represents the type of object this data object represents.
A single node of an X file.
Definition: xFileNode.h:42
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
virtual bool is_object() const
Returns true if this node represents a data object that is the instance of some template, or false otherwise.