Panda3D
|
00001 // Filename: dcField.I 00002 // Created by: drose (10Jan06) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: DCField::get_number 00018 // Access: Published 00019 // Description: Returns a unique index number associated with this 00020 // field. This is defined implicitly when the .dc 00021 // file(s) are read. 00022 //////////////////////////////////////////////////////////////////// 00023 INLINE int DCField:: 00024 get_number() const { 00025 return _number; 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: DCField::get_class 00030 // Access: Published 00031 // Description: Returns the DCClass pointer for the class that 00032 // contains this field. 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE DCClass *DCField:: 00035 get_class() const { 00036 return _dclass; 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function: DCField::has_default_value 00041 // Access: Published 00042 // Description: Returns true if a default value has been explicitly 00043 // established for this field, false otherwise. 00044 //////////////////////////////////////////////////////////////////// 00045 INLINE bool DCField:: 00046 has_default_value() const { 00047 return _has_default_value; 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: DCField::get_default_value 00052 // Access: Published 00053 // Description: Returns the default value for this field. If a 00054 // default value has been explicitly set 00055 // (e.g. has_default_value() returns true), returns that 00056 // value; otherwise, returns an implicit default for the 00057 // field. 00058 //////////////////////////////////////////////////////////////////// 00059 INLINE const string &DCField:: 00060 get_default_value() const { 00061 if (_default_value_stale) { 00062 ((DCField *)this)->refresh_default_value(); 00063 } 00064 return _default_value; 00065 } 00066 00067 //////////////////////////////////////////////////////////////////// 00068 // Function: DCField::is_bogus_field 00069 // Access: Published 00070 // Description: Returns true if the field has been flagged as a bogus 00071 // field. This is set for fields that are generated by 00072 // the parser as placeholder for missing fields, as 00073 // when reading a partial file; it should not occur in a 00074 // normal valid dc file. 00075 //////////////////////////////////////////////////////////////////// 00076 INLINE bool DCField:: 00077 is_bogus_field() const { 00078 return _bogus_field; 00079 } 00080 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: DCField::is_required 00083 // Access: Published 00084 // Description: Returns true if the "required" flag is set for this 00085 // field, false otherwise. 00086 //////////////////////////////////////////////////////////////////// 00087 INLINE bool DCField:: 00088 is_required() const { 00089 return has_keyword("required"); 00090 } 00091 00092 //////////////////////////////////////////////////////////////////// 00093 // Function: DCField::is_broadcast 00094 // Access: Published 00095 // Description: Returns true if the "broadcast" flag is set for this 00096 // field, false otherwise. 00097 //////////////////////////////////////////////////////////////////// 00098 INLINE bool DCField:: 00099 is_broadcast() const { 00100 return has_keyword("broadcast"); 00101 } 00102 00103 //////////////////////////////////////////////////////////////////// 00104 // Function: DCField::is_ram 00105 // Access: Published 00106 // Description: Returns true if the "ram" flag is set for this 00107 // field, false otherwise. 00108 //////////////////////////////////////////////////////////////////// 00109 INLINE bool DCField:: 00110 is_ram() const { 00111 return has_keyword("ram"); 00112 } 00113 00114 //////////////////////////////////////////////////////////////////// 00115 // Function: DCField::is_db 00116 // Access: Published 00117 // Description: Returns true if the "db" flag is set for this 00118 // field, false otherwise. 00119 //////////////////////////////////////////////////////////////////// 00120 INLINE bool DCField:: 00121 is_db() const { 00122 return has_keyword("db"); 00123 } 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: DCField::is_clsend 00127 // Access: Published 00128 // Description: Returns true if the "clsend" flag is set for this 00129 // field, false otherwise. 00130 //////////////////////////////////////////////////////////////////// 00131 INLINE bool DCField:: 00132 is_clsend() const { 00133 return has_keyword("clsend"); 00134 } 00135 00136 //////////////////////////////////////////////////////////////////// 00137 // Function: DCField::is_clrecv 00138 // Access: Published 00139 // Description: Returns true if the "clrecv" flag is set for this 00140 // field, false otherwise. 00141 //////////////////////////////////////////////////////////////////// 00142 INLINE bool DCField:: 00143 is_clrecv() const { 00144 return has_keyword("clrecv"); 00145 } 00146 00147 //////////////////////////////////////////////////////////////////// 00148 // Function: DCField::is_ownsend 00149 // Access: Published 00150 // Description: Returns true if the "ownsend" flag is set for this 00151 // field, false otherwise. 00152 //////////////////////////////////////////////////////////////////// 00153 INLINE bool DCField:: 00154 is_ownsend() const { 00155 return has_keyword("ownsend"); 00156 } 00157 00158 //////////////////////////////////////////////////////////////////// 00159 // Function: DCField::is_ownrecv 00160 // Access: Published 00161 // Description: Returns true if the "ownrecv" flag is set for this 00162 // field, false otherwise. 00163 //////////////////////////////////////////////////////////////////// 00164 INLINE bool DCField:: 00165 is_ownrecv() const { 00166 return has_keyword("ownrecv"); 00167 } 00168 00169 //////////////////////////////////////////////////////////////////// 00170 // Function: DCField::is_airecv 00171 // Access: Published 00172 // Description: Returns true if the "airecv" flag is set for this 00173 // field, false otherwise. 00174 //////////////////////////////////////////////////////////////////// 00175 INLINE bool DCField:: 00176 is_airecv() const { 00177 return has_keyword("airecv"); 00178 } 00179 00180 //////////////////////////////////////////////////////////////////// 00181 // Function : DCField::output 00182 // Access : Published 00183 // Description : Write a string representation of this instance to 00184 // <out>. 00185 //////////////////////////////////////////////////////////////////// 00186 INLINE void DCField:: 00187 output(ostream &out) const { 00188 output(out, true); 00189 } 00190 00191 //////////////////////////////////////////////////////////////////// 00192 // Function : DCField:: 00193 // Access : Published 00194 // Description : Write a string representation of this instance to 00195 // <out>. 00196 //////////////////////////////////////////////////////////////////// 00197 INLINE void DCField:: 00198 write(ostream &out, int indent_level) const { 00199 write(out, false, indent_level); 00200 } 00201 00202 //////////////////////////////////////////////////////////////////// 00203 // Function: DCField::set_number 00204 // Access: Public 00205 // Description: Assigns the unique number to this field. This is 00206 // normally called only by the DCClass interface as the 00207 // field is added. 00208 //////////////////////////////////////////////////////////////////// 00209 INLINE void DCField:: 00210 set_number(int number) { 00211 _number = number; 00212 } 00213 00214 //////////////////////////////////////////////////////////////////// 00215 // Function: DCField::set_class 00216 // Access: Public 00217 // Description: Assigns the class pointer to this field. This is 00218 // normally called only by the DCClass interface as the 00219 // field is added. 00220 //////////////////////////////////////////////////////////////////// 00221 INLINE void DCField:: 00222 set_class(DCClass *dclass) { 00223 _dclass = dclass; 00224 } 00225 00226 //////////////////////////////////////////////////////////////////// 00227 // Function: DCField::set_default_value 00228 // Access: Public 00229 // Description: Establishes a default value for this field. 00230 //////////////////////////////////////////////////////////////////// 00231 INLINE void DCField:: 00232 set_default_value(const string &default_value) { 00233 _default_value = default_value; 00234 _has_default_value = true; 00235 _default_value_stale = false; 00236 }