Panda3D
Loading...
Searching...
No Matches
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 */
18INLINE int DCField::
19get_number() const {
20 return _number;
21}
22
23/**
24 * Returns the DCClass pointer for the class that contains this field.
25 */
27get_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 */
35INLINE bool DCField::
36has_default_value() const {
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 */
45INLINE const vector_uchar &DCField::
46get_default_value() const {
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 */
59INLINE bool DCField::
60is_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 */
67INLINE bool DCField::
68is_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 */
76INLINE bool DCField::
77is_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 */
84INLINE bool DCField::
85is_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 */
92INLINE bool DCField::
93is_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 */
100INLINE bool DCField::
101is_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 */
108INLINE bool DCField::
109is_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 */
116INLINE bool DCField::
117is_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 */
124INLINE bool DCField::
125is_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 */
132INLINE bool DCField::
133is_airecv() const {
134 return has_keyword("airecv");
135}
136
137/**
138 * Write a string representation of this instance to <out>.
139 */
140INLINE void DCField::
141output(std::ostream &out) const {
142 output(out, true);
143}
144
145/**
146 * Write a string representation of this instance to <out>.
147 */
148INLINE void DCField::
149write(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 */
157INLINE void DCField::
158set_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 */
166INLINE void DCField::
167set_class(DCClass *dclass) {
168 _dclass = dclass;
169}
170
171/**
172 * Establishes a default value for this field.
173 */
174INLINE void DCField::
175set_default_value(vector_uchar default_value) {
176 _default_value = std::move(default_value);
177 _has_default_value = true;
178 _default_value_stale = false;
179}
Defines a particular DistributedClass as read from an input .dc file.
Definition dcClass.h:44
A single field of a Distributed Class, either atomic or molecular.
Definition dcField.h:37
bool has_default_value() const
Returns true if a default value has been explicitly established for this field, false otherwise.
Definition dcField.I:36
void set_number(int number)
Assigns the unique number to this field.
Definition dcField.I:158
DCClass * get_class() const
Returns the DCClass pointer for the class that contains this field.
Definition dcField.I:27
bool is_clsend() const
Returns true if the "clsend" flag is set for this field, false otherwise.
Definition dcField.I:101
bool is_ownsend() const
Returns true if the "ownsend" flag is set for this field, false otherwise.
Definition dcField.I:117
bool is_bogus_field() const
Returns true if the field has been flagged as a bogus field.
Definition dcField.I:60
bool is_broadcast() const
Returns true if the "broadcast" flag is set for this field, false otherwise.
Definition dcField.I:77
bool is_clrecv() const
Returns true if the "clrecv" flag is set for this field, false otherwise.
Definition dcField.I:109
int get_number() const
Returns a unique index number associated with this field.
Definition dcField.I:19
bool is_required() const
Returns true if the "required" flag is set for this field, false otherwise.
Definition dcField.I:68
void set_default_value(std::vector< unsigned char > default_value)
Establishes a default value for this field.
Definition dcField.I:175
bool is_db() const
Returns true if the "db" flag is set for this field, false otherwise.
Definition dcField.I:93
bool is_airecv() const
Returns true if the "airecv" flag is set for this field, false otherwise.
Definition dcField.I:133
const std::vector< unsigned char > & get_default_value() const
Returns the default value for this field.
Definition dcField.I:46
void write(std::ostream &out, int indent_level) const
Write a string representation of this instance to <out>.
Definition dcField.I:149
void output(std::ostream &out) const
Write a string representation of this instance to <out>.
Definition dcField.I:141
void set_class(DCClass *dclass)
Assigns the class pointer to this field.
Definition dcField.I:167
bool is_ram() const
Returns true if the "ram" flag is set for this field, false otherwise.
Definition dcField.I:85
bool is_ownrecv() const
Returns true if the "ownrecv" flag is set for this field, false otherwise.
Definition dcField.I:125
bool has_keyword(const std::string &name) const
Returns true if this list includes the indicated keyword, false otherwise.