Panda3D
|
A single field of a Distributed Class, either atomic or molecular. More...
#include "dcField.h"
Public Member Functions | |
DCField (const string &name, DCClass *dclass) | |
virtual DCAtomicField * | as_atomic_field () |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL. | |
virtual const DCAtomicField * | as_atomic_field () const |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL. | |
virtual DCField * | as_field () |
virtual const DCField * | as_field () const |
virtual DCMolecularField * | as_molecular_field () |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL. | |
virtual const DCMolecularField * | as_molecular_field () const |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL. | |
virtual DCParameter * | as_parameter () |
virtual const DCParameter * | as_parameter () const |
string | format_data (const string &packed_data, bool show_field_names=true) |
Given a blob that represents the packed data for this field, returns a string formatting it for human consumption. | |
virtual void | generate_hash (HashGenerator &hashgen) const |
Accumulates the properties of this field into the hash. | |
DCClass * | get_class () const |
Returns the DCClass pointer for the class that contains this field. | |
const string & | get_default_value () const |
Returns the default value for this field. | |
int | get_number () const |
Returns a unique index number associated with this field. | |
bool | has_default_value () const |
Returns true if a default value has been explicitly established for this field, false otherwise. | |
bool | is_airecv () const |
Returns true if the "airecv" flag is set for this field, false otherwise. | |
bool | is_bogus_field () const |
Returns true if the field has been flagged as a bogus field. | |
bool | is_broadcast () const |
Returns true if the "broadcast" flag is set for this field, false otherwise. | |
bool | is_clrecv () const |
Returns true if the "clrecv" flag is set for this field, false otherwise. | |
bool | is_clsend () const |
Returns true if the "clsend" flag is set for this field, false otherwise. | |
bool | is_db () const |
Returns true if the "db" flag is set for this field, false otherwise. | |
bool | is_ownrecv () const |
Returns true if the "ownrecv" flag is set for this field, false otherwise. | |
bool | is_ownsend () const |
Returns true if the "ownsend" flag is set for this field, false otherwise. | |
bool | is_ram () const |
Returns true if the "ram" flag is set for this field, false otherwise. | |
bool | is_required () const |
Returns true if the "required" flag is set for this field, false otherwise. | |
void | output (ostream &out) const |
Write a string representation of this instance to <out>. | |
virtual void | output (ostream &out, bool brief) const =0 |
virtual bool | pack_default_value (DCPackData &pack_data, bool &pack_error) const |
Packs the field's specified default value (or a sensible default if no value is specified) into the stream. | |
string | parse_string (const string &formatted_string) |
Given a human-formatted string (for instance, as returned by format_data(), above) that represents the value of this field, parse the string and return the corresponding packed data. | |
void | set_class (DCClass *dclass) |
Assigns the class pointer to this field. | |
void | set_default_value (const string &default_value) |
Establishes a default value for this field. | |
virtual void | set_name (const string &name) |
Sets the name of this field. | |
void | set_number (int number) |
Assigns the unique number to this field. | |
bool | validate_ranges (const string &packed_data) const |
Verifies that all of the packed values in the field data are within the specified ranges and that there are no extra bytes on the end of the record. | |
void | write (ostream &out, int indent_level) const |
Write a string representation of this instance to <out>. | |
virtual void | write (ostream &out, bool brief, int indent_level) const =0 |
Protected Member Functions | |
void | refresh_default_value () |
Recomputes the default value of the field by repacking it. | |
Protected Attributes | |
bool | _bogus_field |
DCClass * | _dclass |
bool | _default_value_stale |
bool | _has_default_value |
int | _number |
A single field of a Distributed Class, either atomic or molecular.
DCAtomicField * DCField::as_atomic_field | ( | ) | [virtual] |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL.
Reimplemented in DCAtomicField.
Definition at line 120 of file dcField.cxx.
Referenced by DCClass::add_field().
const DCAtomicField * DCField::as_atomic_field | ( | ) | const [virtual] |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL.
Reimplemented in DCAtomicField.
Definition at line 132 of file dcField.cxx.
DCMolecularField * DCField::as_molecular_field | ( | ) | [virtual] |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL.
Reimplemented in DCMolecularField.
Definition at line 144 of file dcField.cxx.
const DCMolecularField * DCField::as_molecular_field | ( | ) | const [virtual] |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL.
Reimplemented in DCMolecularField.
Definition at line 156 of file dcField.cxx.
string DCField::format_data | ( | const string & | packed_data, |
bool | show_field_names = true |
||
) |
Given a blob that represents the packed data for this field, returns a string formatting it for human consumption.
Returns empty string if there is an error.
Definition at line 188 of file dcField.cxx.
References DCPacker::begin_unpack(), DCPacker::end_unpack(), DCPacker::set_unpack_data(), and DCPacker::unpack_and_format().
Referenced by DCSwitch::output_instance(), and DCSwitch::write_instance().
void DCField::generate_hash | ( | HashGenerator & | hashgen | ) | const [virtual] |
Accumulates the properties of this field into the hash.
Reimplemented from DCKeywordList.
Reimplemented in DCSimpleParameter, DCParameter, DCAtomicField, DCArrayParameter, DCSwitchParameter, DCClassParameter, and DCMolecularField.
Definition at line 524 of file dcField.cxx.
References HashGenerator::add_int(), and HashGenerator::add_string().
Referenced by DCSwitch::generate_hash(), and DCClass::generate_hash().
DCClass * DCField::get_class | ( | ) | const [inline] |
Returns the DCClass pointer for the class that contains this field.
Reimplemented in DCClassParameter.
Definition at line 35 of file dcField.I.
Referenced by DCClass::add_field().
const string & DCField::get_default_value | ( | ) | const [inline] |
Returns the default value for this field.
If a default value has been explicitly set (e.g. has_default_value() returns true), returns that value; otherwise, returns an implicit default for the field.
int DCField::get_number | ( | ) | const [inline] |
Returns a unique index number associated with this field.
This is defined implicitly when the .dc file(s) are read.
Definition at line 24 of file dcField.I.
Referenced by DCClass::add_field().
bool DCField::has_default_value | ( | ) | const [inline] |
Returns true if a default value has been explicitly established for this field, false otherwise.
Definition at line 46 of file dcField.I.
Referenced by DCMolecularField::add_atomic(), DCAtomicField::add_element(), and DCSwitch::SwitchFields::add_field().
bool DCField::is_airecv | ( | ) | const [inline] |
Returns true if the "airecv" flag is set for this field, false otherwise.
Definition at line 176 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_bogus_field | ( | ) | const [inline] |
Returns true if the field has been flagged as a bogus field.
This is set for fields that are generated by the parser as placeholder for missing fields, as when reading a partial file; it should not occur in a normal valid dc file.
Definition at line 77 of file dcField.I.
Referenced by DCMolecularField::add_atomic().
bool DCField::is_broadcast | ( | ) | const [inline] |
Returns true if the "broadcast" flag is set for this field, false otherwise.
Definition at line 99 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_clrecv | ( | ) | const [inline] |
Returns true if the "clrecv" flag is set for this field, false otherwise.
Definition at line 143 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_clsend | ( | ) | const [inline] |
Returns true if the "clsend" flag is set for this field, false otherwise.
Definition at line 132 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_db | ( | ) | const [inline] |
Returns true if the "db" flag is set for this field, false otherwise.
Definition at line 121 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_ownrecv | ( | ) | const [inline] |
Returns true if the "ownrecv" flag is set for this field, false otherwise.
Definition at line 165 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_ownsend | ( | ) | const [inline] |
Returns true if the "ownsend" flag is set for this field, false otherwise.
Definition at line 154 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_ram | ( | ) | const [inline] |
Returns true if the "ram" flag is set for this field, false otherwise.
Definition at line 110 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_required | ( | ) | const [inline] |
Returns true if the "required" flag is set for this field, false otherwise.
Definition at line 88 of file dcField.I.
References DCKeywordList::has_keyword().
void DCField::output | ( | ostream & | out | ) | const [inline] |
Write a string representation of this instance to <out>.
Definition at line 187 of file dcField.I.
Referenced by DCSwitch::output_instance(), DCClass::output_instance(), and DCSwitch::write_instance().
bool DCField::pack_default_value | ( | DCPackData & | pack_data, |
bool & | pack_error | ||
) | const [virtual] |
Packs the field's specified default value (or a sensible default if no value is specified) into the stream.
Returns true if the default value is packed, false if the field doesn't know how to pack its default value.
Reimplemented from DCPackerInterface.
Reimplemented in DCSimpleParameter, DCArrayParameter, and DCSwitchParameter.
Definition at line 548 of file dcField.cxx.
References DCPackData::append_data().
Referenced by DCSimpleParameter::pack_default_value().
string DCField::parse_string | ( | const string & | formatted_string | ) |
Given a human-formatted string (for instance, as returned by format_data(), above) that represents the value of this field, parse the string and return the corresponding packed data.
Returns empty string if there is an error.
Definition at line 209 of file dcField.cxx.
References DCPacker::begin_pack(), DCPacker::end_pack(), DCPacker::get_string(), and DCPacker::parse_and_pack().
void DCField::refresh_default_value | ( | ) | [protected] |
Recomputes the default value of the field by repacking it.
Definition at line 620 of file dcField.cxx.
References DCPacker::begin_pack(), DCPacker::end_pack(), DCPacker::get_data(), DCPacker::get_length(), DCPackerInterface::get_name(), and DCPacker::pack_default_value().
void DCField::set_class | ( | DCClass * | dclass | ) | [inline] |
Assigns the class pointer to this field.
This is normally called only by the DCClass interface as the field is added.
Definition at line 222 of file dcField.I.
Referenced by DCClass::add_field().
void DCField::set_default_value | ( | const string & | default_value | ) | [inline] |
void DCField::set_name | ( | const string & | name | ) | [virtual] |
Sets the name of this field.
Reimplemented from DCPackerInterface.
Definition at line 566 of file dcField.cxx.
References DCFile::mark_inherited_fields_stale().
Referenced by DCTypedef::DCTypedef(), and DCTypedef::make_new_parameter().
void DCField::set_number | ( | int | number | ) | [inline] |
Assigns the unique number to this field.
This is normally called only by the DCClass interface as the field is added.
Definition at line 210 of file dcField.I.
Referenced by DCClass::add_field(), and DCFile::set_new_index_number().
bool DCField::validate_ranges | ( | const string & | packed_data | ) | const |
Verifies that all of the packed values in the field data are within the specified ranges and that there are no extra bytes on the end of the record.
Returns true if all fields are valid, false otherwise.
Definition at line 233 of file dcField.cxx.
References DCPacker::begin_unpack(), DCPacker::end_unpack(), DCPacker::get_num_unpacked_bytes(), DCPacker::set_unpack_data(), and DCPacker::unpack_validate().
void DCField::write | ( | ostream & | out, |
int | indent_level | ||
) | const [inline] |
Write a string representation of this instance to <out>.
Definition at line 198 of file dcField.I.
Referenced by DCClass::write().