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;
48 int num_cases = _dswitch->get_num_cases();
50 _fixed_byte_size = _dswitch->get_case(0)->get_fixed_byte_size();
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 {
157 return _dswitch->get_key_parameter();
170 return _dswitch->apply_switch(value_data, length);
181 const string &name,
const string &postname)
const {
182 if (get_typedef() != (
DCTypedef *)NULL) {
183 output_typedef_name(out, brief, prename, name, postname);
186 _dswitch->output_instance(out, brief, prename, name, postname);
198 const string &prename,
const string &name,
199 const string &postname)
const {
200 if (get_typedef() != (
DCTypedef *)NULL) {
201 write_typedef_name(out, brief, indent_level, prename, name, postname);
204 _dswitch->write_instance(out, brief, indent_level, prename, name, postname);
217 _dswitch->generate_hash(hashgen);
231 if (has_default_value()) {
235 return _dswitch->pack_default_value(pack_data, pack_error);
246 bool DCSwitchParameter::
257 bool DCSwitchParameter::
259 return _dswitch->do_check_match_switch(other->_dswitch);
This represents a single typedef declaration in the dc file.
This is a block of data that receives the results of DCPacker.
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...
A single field of a Distributed Class, either atomic or molecular.
DCField * get_key_parameter() const
Returns the key parameter on which the switch is based.
bool has_default_value() const
Returns true if a default value has been explicitly established for this field, false otherwise...
virtual bool do_check_match_switch_parameter(const DCSwitchParameter *other) const
Returns true if this field matches the indicated switch parameter, false otherwise.
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...
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...
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...
virtual bool is_valid() const
Returns false if the type is an invalid type (e.g.
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 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.
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this type into the hash.
Represents the type specification for a single parameter within a field specification.
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.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this type into the hash.
This class generates an arbitrary hash number from a sequence of ints.
const string & get_name() const
Returns the name of this switch.
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 DCSwitch * get_switch() const
Returns the switch object this parameter represents.
This defines the internal interface for packing values into a DCField.
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...