Panda3D
|
A single atomic field of a Distributed Class, as read from a .dc file. More...
#include "dcAtomicField.h"
Public Member Functions | |
DCAtomicField (const string &name, DCClass *dclass, bool bogus_field) | |
void | add_element (DCParameter *element) |
Adds a new element (parameter) to the field. | |
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 void | generate_hash (HashGenerator &hashgen) const |
Accumulates the properties of this field into the hash. | |
DCParameter * | get_element (int n) const |
Returns the parameter object describing the nth element. | |
string | get_element_default (int n) const |
Returns the pre-formatted default value associated with the nth element of the field. | |
int | get_element_divisor (int n) const |
Returns the divisor associated with the nth element of the field. | |
string | get_element_name (int n) const |
Returns the name of the nth element of the field. | |
DCSubatomicType | get_element_type (int n) const |
Returns the numeric type of the nth element of the field. | |
virtual DCPackerInterface * | get_nested_field (int n) const |
Returns the DCPackerInterface object that represents the nth nested field. | |
int | get_num_elements () const |
Returns the number of elements (parameters) of the atomic field. | |
bool | has_element_default (int n) const |
Returns true if the nth element of the field has a default value specified, false otherwise. | |
virtual void | output (ostream &out, bool brief) const |
virtual void | write (ostream &out, bool brief, int indent_level) const |
Generates a parseable description of the object to the indicated output stream. | |
Protected Member Functions | |
virtual bool | do_check_match (const DCPackerInterface *other) const |
Returns true if the other interface is bitwise the same as this one--that is, a uint32 only matches a uint32, etc. | |
virtual bool | do_check_match_atomic_field (const DCAtomicField *other) const |
Returns true if this field matches the indicated atomic field, false otherwise. |
A single atomic field of a Distributed Class, as read from a .dc file.
This defines an interface to the Distributed Class, and is always implemented as a remote procedure method.
Definition at line 34 of file dcAtomicField.h.
void DCAtomicField::add_element | ( | DCParameter * | element | ) |
Adds a new element (parameter) to the field.
Normally this is called only during parsing. The DCAtomicField object becomes the owner of the new pointer and will delete it upon destruction.
Definition at line 267 of file dcAtomicField.cxx.
References DCPackerInterface::get_fixed_byte_size(), DCField::has_default_value(), DCPackerInterface::has_fixed_byte_size(), DCPackerInterface::has_fixed_structure(), and DCPackerInterface::has_range_limits().
DCAtomicField * DCAtomicField::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 from DCField.
Definition at line 58 of file dcAtomicField.cxx.
const DCAtomicField * DCAtomicField::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 from DCField.
Definition at line 70 of file dcAtomicField.cxx.
bool DCAtomicField::do_check_match | ( | const DCPackerInterface * | other | ) | const [protected, virtual] |
Returns true if the other interface is bitwise the same as this one--that is, a uint32 only matches a uint32, etc.
Names of components, and range limits, are not compared.
Implements DCPackerInterface.
Definition at line 297 of file dcAtomicField.cxx.
References DCPackerInterface::do_check_match_atomic_field().
bool DCAtomicField::do_check_match_atomic_field | ( | const DCAtomicField * | other | ) | const [protected, virtual] |
Returns true if this field matches the indicated atomic field, false otherwise.
Reimplemented from DCPackerInterface.
Definition at line 308 of file dcAtomicField.cxx.
References DCPackerInterface::check_match().
void DCAtomicField::generate_hash | ( | HashGenerator & | hashgen | ) | const [virtual] |
Accumulates the properties of this field into the hash.
Reimplemented from DCField.
Definition at line 232 of file dcAtomicField.cxx.
References HashGenerator::add_int().
DCParameter * DCAtomicField::get_element | ( | int | n | ) | const |
Returns the parameter object describing the nth element.
Definition at line 92 of file dcAtomicField.cxx.
string DCAtomicField::get_element_default | ( | int | n | ) | const |
Returns the pre-formatted default value associated with the nth element of the field.
This is only valid if has_element_default() returns true, in which case this string represents the bytes that should be assigned to the field as a default value.
If the element is an array-type element, the returned value will include the two-byte length preceding the array data.
This is deprecated; use get_element() instead.
Definition at line 113 of file dcAtomicField.cxx.
int DCAtomicField::get_element_divisor | ( | int | n | ) | const |
Returns the divisor associated with the nth element of the field.
This implements an implicit fixed-point system; floating-point values are to be multiplied by this value before encoding into a packet, and divided by this number after decoding.
This method is deprecated; use get_element()->get_divisor() instead.
Definition at line 177 of file dcAtomicField.cxx.
string DCAtomicField::get_element_name | ( | int | n | ) | const |
Returns the name of the nth element of the field.
This name is strictly for documentary purposes; it does not generally affect operation. If a name is not specified, this will be the empty string.
This method is deprecated; use get_element()->get_name() instead.
Definition at line 144 of file dcAtomicField.cxx.
DCSubatomicType DCAtomicField::get_element_type | ( | int | n | ) | const |
Returns the numeric type of the nth element of the field.
This method is deprecated; use get_element() instead.
Definition at line 157 of file dcAtomicField.cxx.
DCPackerInterface * DCAtomicField::get_nested_field | ( | int | n | ) | const [virtual] |
Returns the DCPackerInterface object that represents the nth nested field.
This may return NULL if there is no such field (but it shouldn't do this if n is in the range 0 <= n < get_num_nested_fields()).
Reimplemented from DCPackerInterface.
Definition at line 253 of file dcAtomicField.cxx.
Referenced by DCMolecularField::add_atomic().
int DCAtomicField::get_num_elements | ( | ) | const |
Returns the number of elements (parameters) of the atomic field.
Definition at line 81 of file dcAtomicField.cxx.
bool DCAtomicField::has_element_default | ( | int | n | ) | const |
Returns true if the nth element of the field has a default value specified, false otherwise.
This is deprecated; use get_element() instead.
Definition at line 127 of file dcAtomicField.cxx.
void DCAtomicField::write | ( | ostream & | out, |
bool | brief, | ||
int | indent_level | ||
) | const [virtual] |
Generates a parseable description of the object to the indicated output stream.
Implements DCField.
Definition at line 215 of file dcAtomicField.cxx.