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