24 DCSwitchParameter(
const DCSwitch *dswitch) :
29 _has_fixed_byte_size =
true;
31 _has_fixed_structure =
false;
37 _has_nested_fields =
true;
38 _num_nested_fields = 1;
40 _pack_type = PT_switch;
47 int num_cases = _dswitch->get_num_cases();
49 _fixed_byte_size = _dswitch->get_case(0)->get_fixed_byte_size();
52 for (
int i = 0; i < num_cases; i++) {
60 _has_fixed_byte_size =
false;
64 _has_default_value = _has_default_value || fields->_has_default_value;
71 if (fields !=
nullptr) {
74 _has_fixed_byte_size =
false;
78 _has_default_value = _has_default_value || fields->_has_default_value;
88 _dswitch(copy._dswitch)
96 as_switch_parameter() {
104 as_switch_parameter()
const {
140 return _dswitch->get_key_parameter();
150 return _dswitch->apply_switch(value_data, length);
159 const string &name,
const string &postname)
const {
160 if (get_typedef() !=
nullptr) {
161 output_typedef_name(out, brief, prename, name, postname);
164 _dswitch->output_instance(out, brief, prename, name, postname);
174 const string &prename,
const string &name,
175 const string &postname)
const {
176 if (get_typedef() !=
nullptr) {
177 write_typedef_name(out, brief, indent_level, prename, name, postname);
180 _dswitch->write_instance(out, brief, indent_level, prename, name, postname);
190 _dswitch->generate_hash(hashgen);
201 if (has_default_value()) {
205 return _dswitch->pack_default_value(pack_data, pack_error);
213 bool DCSwitchParameter::
222 bool DCSwitchParameter::
224 return _dswitch->do_check_match_switch(other->_dswitch);
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this type into the hash.
This is a block of data that receives the results of DCPacker.
const DCSwitch * get_switch() const
Returns the switch object this parameter represents.
DCField * get_key_parameter() const
Returns the key parameter on which the switch is based.
A single field of a Distributed Class, either atomic or molecular.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_instance(std::ostream &out, bool brief, int indent_level, const std::string &prename, const std::string &name, const std::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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
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 std::string & get_name() const
Returns the name of this switch.
bool has_default_value() const
Returns true if a default value has been explicitly established for this field, false otherwise.
This class generates an arbitrary hash number from a sequence of ints.
virtual void output_instance(std::ostream &out, bool brief, const std::string &prename, const std::string &name, const std::string &postname) const
Formats the parameter in the C++-like dc syntax as a typename and identifier.
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.
This defines the internal interface for packing values into a DCField.
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...