15 #include "dcSwitchParameter.h" 17 #include "hashGenerator.h" 25 DCSwitchParameter(
const DCSwitch *dswitch) :
30 _has_fixed_byte_size =
true;
32 _has_fixed_structure =
false;
38 _has_nested_fields =
true;
39 _num_nested_fields = 1;
41 _pack_type = PT_switch;
53 for (
int i = 0; i < num_cases; i++) {
61 _has_fixed_byte_size =
false;
65 _has_default_value = _has_default_value || fields->_has_default_value;
75 _has_fixed_byte_size =
false;
79 _has_default_value = _has_default_value || fields->_has_default_value;
91 _dswitch(copy._dswitch)
101 as_switch_parameter() {
111 as_switch_parameter()
const {
181 const string &name,
const string &postname)
const {
198 const string &prename,
const string &name,
199 const string &postname)
const {
204 _dswitch->
write_instance(out, brief, indent_level, prename, name, postname);
246 bool DCSwitchParameter::
257 bool DCSwitchParameter::
virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const
Packs the switchParameter's specified default value (or a sensible default if no value is specified) ...
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this type into the hash.
This represents a single typedef declaration in the dc file.
virtual void write_instance(ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const
Formats the parameter in the C++-like dc syntax as a typename and identifier.
This is a block of data that receives the results of DCPacker.
const DCSwitch * get_switch() const
Returns the switch object this parameter represents.
void output_typedef_name(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const
Formats the instance like output_instance, but uses the typedef name instead.
DCField * get_key_parameter() const
Returns the key parameter on which the switch is based.
void write_instance(ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const
Generates a parseable description of the object to the indicated output stream.
void output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const
Generates a parseable description of the object to the indicated output stream.
A single field of a Distributed Class, either atomic or molecular.
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
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 s...
bool has_fixed_byte_size() const
Returns true if this field type always packs to the same number of bytes, false if it is variable...
This represents a switch statement, which can appear inside a class body and represents two or more a...
This represents a switch object used as a parameter itself, which packs the appropriate fields of the...
int get_num_cases() const
Returns the number of different cases within the switch.
void write_typedef_name(ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const
Formats the instance like write_instance, but uses the typedef name instead.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this type into the hash.
size_t get_fixed_byte_size() const
If has_fixed_byte_size() returns true, this returns the number of bytes this field type will use...
bool has_range_limits() const
Returns true if this field, or any sub-field of this field, has a limit imposed in the DC file on its...
Represents the type specification for a single parameter within a field specification.
virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const
Packs the switchParameter's specified default value (or a sensible default if no value is specified) ...
const DCPackerInterface * apply_switch(const char *value_data, size_t length) const
Returns the DCPackerInterface that presents the alternative fields for the case indicated by the give...
const string & get_name() const
Returns the name of this switch.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this switch into the hash.
bool has_default_value() const
Returns true if a default value has been explicitly established for this field, false otherwise...
bool do_check_match_switch(const DCSwitch *other) const
Returns true if this switch matches the indicated other switch–that is, the two switches are bitwise...
This class generates an arbitrary hash number from a sequence of ints.
const DCTypedef * get_typedef() const
If this type has been referenced from a typedef, returns the DCTypedef instance, or NULL if the type ...
virtual bool is_valid() const
Returns false if the type is an invalid type (e.g.
virtual bool do_check_match_switch_parameter(const DCSwitchParameter *other) const
Returns true if this field matches the indicated switch parameter, false otherwise.
virtual void set_name(const string &name)
Sets the name of this field.
DCPackerInterface * get_default_case() const
Returns the DCPackerInterface that packs the default case, or NULL if there is no default case...
DCPackerInterface * get_case(int n) const
Returns the DCPackerInterface that packs the nth case.
This defines the internal interface for packing values into a DCField.
virtual void output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const
Formats the parameter in the C++-like dc syntax as a typename and identifier.
const DCPackerInterface * apply_switch(const char *value_data, size_t length) const
Returns the DCPackerInterface that presents the alternative fields for the case indicated by the give...