Panda3D
dcField.I
1 // Filename: dcField.I
2 // Created by: drose (10Jan06)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: DCField::get_number
18 // Access: Published
19 // Description: Returns a unique index number associated with this
20 // field. This is defined implicitly when the .dc
21 // file(s) are read.
22 ////////////////////////////////////////////////////////////////////
23 INLINE int DCField::
24 get_number() const {
25  return _number;
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: DCField::get_class
30 // Access: Published
31 // Description: Returns the DCClass pointer for the class that
32 // contains this field.
33 ////////////////////////////////////////////////////////////////////
34 INLINE DCClass *DCField::
35 get_class() const {
36  return _dclass;
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: DCField::has_default_value
41 // Access: Published
42 // Description: Returns true if a default value has been explicitly
43 // established for this field, false otherwise.
44 ////////////////////////////////////////////////////////////////////
45 INLINE bool DCField::
47  return _has_default_value;
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: DCField::get_default_value
52 // Access: Published
53 // Description: Returns the default value for this field. If a
54 // default value has been explicitly set
55 // (e.g. has_default_value() returns true), returns that
56 // value; otherwise, returns an implicit default for the
57 // field.
58 ////////////////////////////////////////////////////////////////////
59 INLINE const string &DCField::
61  if (_default_value_stale) {
62  ((DCField *)this)->refresh_default_value();
63  }
64  return _default_value;
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: DCField::is_bogus_field
69 // Access: Published
70 // Description: Returns true if the field has been flagged as a bogus
71 // field. This is set for fields that are generated by
72 // the parser as placeholder for missing fields, as
73 // when reading a partial file; it should not occur in a
74 // normal valid dc file.
75 ////////////////////////////////////////////////////////////////////
76 INLINE bool DCField::
77 is_bogus_field() const {
78  return _bogus_field;
79 }
80 
81 ////////////////////////////////////////////////////////////////////
82 // Function: DCField::is_required
83 // Access: Published
84 // Description: Returns true if the "required" flag is set for this
85 // field, false otherwise.
86 ////////////////////////////////////////////////////////////////////
87 INLINE bool DCField::
88 is_required() const {
89  return has_keyword("required");
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: DCField::is_broadcast
94 // Access: Published
95 // Description: Returns true if the "broadcast" flag is set for this
96 // field, false otherwise.
97 ////////////////////////////////////////////////////////////////////
98 INLINE bool DCField::
99 is_broadcast() const {
100  return has_keyword("broadcast");
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: DCField::is_ram
105 // Access: Published
106 // Description: Returns true if the "ram" flag is set for this
107 // field, false otherwise.
108 ////////////////////////////////////////////////////////////////////
109 INLINE bool DCField::
110 is_ram() const {
111  return has_keyword("ram");
112 }
113 
114 ////////////////////////////////////////////////////////////////////
115 // Function: DCField::is_db
116 // Access: Published
117 // Description: Returns true if the "db" flag is set for this
118 // field, false otherwise.
119 ////////////////////////////////////////////////////////////////////
120 INLINE bool DCField::
121 is_db() const {
122  return has_keyword("db");
123 }
124 
125 ////////////////////////////////////////////////////////////////////
126 // Function: DCField::is_clsend
127 // Access: Published
128 // Description: Returns true if the "clsend" flag is set for this
129 // field, false otherwise.
130 ////////////////////////////////////////////////////////////////////
131 INLINE bool DCField::
132 is_clsend() const {
133  return has_keyword("clsend");
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: DCField::is_clrecv
138 // Access: Published
139 // Description: Returns true if the "clrecv" flag is set for this
140 // field, false otherwise.
141 ////////////////////////////////////////////////////////////////////
142 INLINE bool DCField::
143 is_clrecv() const {
144  return has_keyword("clrecv");
145 }
146 
147 ////////////////////////////////////////////////////////////////////
148 // Function: DCField::is_ownsend
149 // Access: Published
150 // Description: Returns true if the "ownsend" flag is set for this
151 // field, false otherwise.
152 ////////////////////////////////////////////////////////////////////
153 INLINE bool DCField::
154 is_ownsend() const {
155  return has_keyword("ownsend");
156 }
157 
158 ////////////////////////////////////////////////////////////////////
159 // Function: DCField::is_ownrecv
160 // Access: Published
161 // Description: Returns true if the "ownrecv" flag is set for this
162 // field, false otherwise.
163 ////////////////////////////////////////////////////////////////////
164 INLINE bool DCField::
165 is_ownrecv() const {
166  return has_keyword("ownrecv");
167 }
168 
169 ////////////////////////////////////////////////////////////////////
170 // Function: DCField::is_airecv
171 // Access: Published
172 // Description: Returns true if the "airecv" flag is set for this
173 // field, false otherwise.
174 ////////////////////////////////////////////////////////////////////
175 INLINE bool DCField::
176 is_airecv() const {
177  return has_keyword("airecv");
178 }
179 
180 ////////////////////////////////////////////////////////////////////
181 // Function : DCField::output
182 // Access : Published
183 // Description : Write a string representation of this instance to
184 // <out>.
185 ////////////////////////////////////////////////////////////////////
186 INLINE void DCField::
187 output(ostream &out) const {
188  output(out, true);
189 }
190 
191 ////////////////////////////////////////////////////////////////////
192 // Function : DCField::
193 // Access : Published
194 // Description : Write a string representation of this instance to
195 // <out>.
196 ////////////////////////////////////////////////////////////////////
197 INLINE void DCField::
198 write(ostream &out, int indent_level) const {
199  write(out, false, indent_level);
200 }
201 
202 ////////////////////////////////////////////////////////////////////
203 // Function: DCField::set_number
204 // Access: Public
205 // Description: Assigns the unique number to this field. This is
206 // normally called only by the DCClass interface as the
207 // field is added.
208 ////////////////////////////////////////////////////////////////////
209 INLINE void DCField::
210 set_number(int number) {
211  _number = number;
212 }
213 
214 ////////////////////////////////////////////////////////////////////
215 // Function: DCField::set_class
216 // Access: Public
217 // Description: Assigns the class pointer to this field. This is
218 // normally called only by the DCClass interface as the
219 // field is added.
220 ////////////////////////////////////////////////////////////////////
221 INLINE void DCField::
222 set_class(DCClass *dclass) {
223  _dclass = dclass;
224 }
225 
226 ////////////////////////////////////////////////////////////////////
227 // Function: DCField::set_default_value
228 // Access: Public
229 // Description: Establishes a default value for this field.
230 ////////////////////////////////////////////////////////////////////
231 INLINE void DCField::
232 set_default_value(const string &default_value) {
233  _default_value = default_value;
234  _has_default_value = true;
235  _default_value_stale = false;
236 }
bool is_clsend() const
Returns true if the "clsend" flag is set for this field, false otherwise.
Definition: dcField.I:132
int get_number() const
Returns a unique index number associated with this field.
Definition: dcField.I:24
DCClass * get_class() const
Returns the DCClass pointer for the class that contains this field.
Definition: dcField.I:35
const string & get_default_value() const
Returns the default value for this field.
Definition: dcField.I:60
A single field of a Distributed Class, either atomic or molecular.
Definition: dcField.h:40
void set_class(DCClass *dclass)
Assigns the class pointer to this field.
Definition: dcField.I:222
void set_number(int number)
Assigns the unique number to this field.
Definition: dcField.I:210
bool is_broadcast() const
Returns true if the "broadcast" flag is set for this field, false otherwise.
Definition: dcField.I:99
Defines a particular DistributedClass as read from an input .dc file.
Definition: dcClass.h:47
bool is_required() const
Returns true if the "required" flag is set for this field, false otherwise.
Definition: dcField.I:88
bool is_ownsend() const
Returns true if the "ownsend" flag is set for this field, false otherwise.
Definition: dcField.I:154
void output(ostream &out) const
Write a string representation of this instance to <out>.
Definition: dcField.I:187
void set_default_value(const string &default_value)
Establishes a default value for this field.
Definition: dcField.I:232
bool has_default_value() const
Returns true if a default value has been explicitly established for this field, false otherwise...
Definition: dcField.I:46
bool is_airecv() const
Returns true if the "airecv" flag is set for this field, false otherwise.
Definition: dcField.I:176
bool is_ownrecv() const
Returns true if the "ownrecv" flag is set for this field, false otherwise.
Definition: dcField.I:165
bool has_keyword(const string &name) const
Returns true if this list includes the indicated keyword, false otherwise.
bool is_clrecv() const
Returns true if the "clrecv" flag is set for this field, false otherwise.
Definition: dcField.I:143
bool is_db() const
Returns true if the "db" flag is set for this field, false otherwise.
Definition: dcField.I:121
bool is_bogus_field() const
Returns true if the field has been flagged as a bogus field.
Definition: dcField.I:77
bool is_ram() const
Returns true if the "ram" flag is set for this field, false otherwise.
Definition: dcField.I:110
void write(ostream &out, int indent_level) const
Write a string representation of this instance to <out>.
Definition: dcField.I:198