Panda3D
xFileDataObjectInteger.cxx
1 // Filename: xFileDataObjectInteger.cxx
2 // Created by: drose (07Oct04)
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 "xFileDataObjectInteger.h"
16 #include "string_utils.h"
17 #include "indent.h"
18 
19 TypeHandle XFileDataObjectInteger::_type_handle;
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: XFileDataObjectInteger::Constructor
23 // Access: Public
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 XFileDataObjectInteger::
27 XFileDataObjectInteger(const XFileDataDef *data_def, int value) :
28  XFileDataObject(data_def),
29  _value(value)
30 {
31 }
32 
33 ////////////////////////////////////////////////////////////////////
34 // Function: XFileDataObjectInteger::output_data
35 // Access: Public, Virtual
36 // Description: Writes a suitable representation of this node to an
37 // .x file in text mode.
38 ////////////////////////////////////////////////////////////////////
40 output_data(ostream &out) const {
41  out << _value;
42 }
43 
44 ////////////////////////////////////////////////////////////////////
45 // Function: XFileDataObjectInteger::write_data
46 // Access: Public, Virtual
47 // Description: Writes a suitable representation of this node to an
48 // .x file in text mode.
49 ////////////////////////////////////////////////////////////////////
51 write_data(ostream &out, int indent_level, const char *separator) const {
52  indent(out, indent_level)
53  << _value << separator << "\n";
54 }
55 
56 ////////////////////////////////////////////////////////////////////
57 // Function: XFileDataObjectInt::set_int_value
58 // Access: Protected, Virtual
59 // Description: Sets the object's value as an integer, if this is
60 // legal.
61 ////////////////////////////////////////////////////////////////////
62 void XFileDataObjectInteger::
63 set_int_value(int int_value) {
64  _value = int_value;
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: XFileDataObjectInteger::get_int_value
69 // Access: Protected, Virtual
70 // Description: Returns the object's representation as an integer, if
71 // it has one.
72 ////////////////////////////////////////////////////////////////////
73 int XFileDataObjectInteger::
74 get_int_value() const {
75  return _value;
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: XFileDataObjectInteger::get_double_value
80 // Access: Protected, Virtual
81 // Description: Returns the object's representation as a double, if
82 // it has one.
83 ////////////////////////////////////////////////////////////////////
84 double XFileDataObjectInteger::
85 get_double_value() const {
86  return _value;
87 }
88 
89 ////////////////////////////////////////////////////////////////////
90 // Function: XFileDataObjectInteger::get_string_value
91 // Access: Protected, Virtual
92 // Description: Returns the object's representation as a string, if
93 // it has one.
94 ////////////////////////////////////////////////////////////////////
95 string XFileDataObjectInteger::
96 get_string_value() const {
97  return format_string(_value);
98 }
A definition of a single data element appearing within a template record.
Definition: xFileDataDef.h:35
virtual void output_data(ostream &out) const
Writes a suitable representation of this node to an .x file in text mode.
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.
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 ...