DCField

class DCField

Bases: DCPackerInterface, DCKeywordList

A single field of a Distributed Class, either atomic or molecular.

Inheritance diagram

Inheritance diagram of DCField

Datagram ai_format_update(DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyObject *args) const

Generates a datagram containing the message necessary to send an update for the indicated distributed object from the AI.

Datagram ai_format_update_msg_type(DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, int msg_type, PyObject *args) const

Generates a datagram containing the message necessary to send an update, with the msg type, for the indicated distributed object from the AI.

virtual DCAtomicField *as_atomic_field(void)
virtual DCAtomicField const *as_atomic_field(void) 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(void)
virtual DCField const *as_field(void) const
virtual DCMolecularField *as_molecular_field(void)
virtual DCMolecularField const *as_molecular_field(void) 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(void)
virtual DCParameter const *as_parameter(void) const
Datagram client_format_update(DOID_TYPE do_id, PyObject *args) const

Generates a datagram containing the message necessary to send an update for the indicated distributed object from the client.

std::string format_data(vector_uchar const &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.

DCClass *get_class(void) const

Returns the DCClass pointer for the class that contains this field.

vector_uchar const &get_default_value(void) const

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 get_number(void) const

Returns a unique index number associated with this field. This is defined implicitly when the .dc file(s) are read.

bool has_default_value(void) const

Returns true if a default value has been explicitly established for this field, false otherwise.

bool is_airecv(void) const

Returns true if the “airecv” flag is set for this field, false otherwise.

bool is_bogus_field(void) const

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.

bool is_broadcast(void) const

Returns true if the “broadcast” flag is set for this field, false otherwise.

bool is_clrecv(void) const

Returns true if the “clrecv” flag is set for this field, false otherwise.

bool is_clsend(void) const

Returns true if the “clsend” flag is set for this field, false otherwise.

bool is_db(void) const

Returns true if the “db” flag is set for this field, false otherwise.

bool is_ownrecv(void) const

Returns true if the “ownrecv” flag is set for this field, false otherwise.

bool is_ownsend(void) const

Returns true if the “ownsend” flag is set for this field, false otherwise.

bool is_ram(void) const

Returns true if the “ram” flag is set for this field, false otherwise.

bool is_required(void) const

Returns true if the “required” flag is set for this field, false otherwise.

void output(std::ostream &out) const

Write a string representation of this instance to <out>.

bool pack_args(DCPacker &packer, PyObject *sequence) const

Packs the Python arguments from the indicated tuple into the packer. Returns true on success, false on failure.

It is assumed that the packer is currently positioned on this field.

vector_uchar parse_string(std::string const &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.

void receive_update(DCPacker &packer, PyObject *distobj) const

Extracts the update message out of the datagram and applies it to the indicated object by calling the appropriate method.

PyObject *unpack_args(DCPacker &packer) const

Unpacks the values from the packer, beginning at the current point in the unpack_buffer, into a Python tuple and returns the tuple.

It is assumed that the packer is currently positioned on this field.

bool validate_ranges(vector_uchar const &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.

void write(std::ostream &out, int indent_level) const

Write a string representation of this instance to <out>.