24DCSwitchParameter(
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)
96as_switch_parameter() {
104as_switch_parameter()
const {
149apply_switch(
const char *value_data,
size_t length)
const {
159 const string &name,
const string &postname)
const {
174 const string &prename,
const string &name,
175 const string &postname)
const {
180 _dswitch->
write_instance(out, brief, indent_level, prename, name, postname);
213bool DCSwitchParameter::
222bool DCSwitchParameter::
A single field of a Distributed Class, either atomic or molecular.
bool has_default_value() const
Returns true if a default value has been explicitly established for this field, false otherwise.
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...
This is a block of data that receives the results of DCPacker.
This defines the internal interface for packing values into a DCField.
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_fixed_byte_size() const
Returns true if this field type always packs to the same number of bytes, false if it is variable.
virtual bool do_check_match_switch_parameter(const DCSwitchParameter *other) const
Returns true if this field matches the indicated switch parameter, false otherwise.
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 void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this type into the hash.
void write_typedef_name(std::ostream &out, bool brief, int indent_level, const std::string &prename, const std::string &name, const std::string &postname) const
Formats the instance like write_instance, but uses the typedef name instead.
const DCTypedef * get_typedef() const
If this type has been referenced from a typedef, returns the DCTypedef instance, or NULL if the type ...
void output_typedef_name(std::ostream &out, bool brief, const std::string &prename, const std::string &name, const std::string &postname) const
Formats the instance like output_instance, but uses the typedef name instead.
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.
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(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.
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...
virtual bool is_valid() const
Returns false if the type is an invalid type (e.g.
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.
const DCSwitch * get_switch() const
Returns the switch object this parameter represents.
This represents a switch statement, which can appear inside a class body and represents two or more a...
const std::string & get_name() const
Returns the name of this switch.
void write_instance(std::ostream &out, bool brief, int indent_level, const std::string &prename, const std::string &name, const std::string &postname) const
Generates a parseable description of the object to the indicated output stream.
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...
void output_instance(std::ostream &out, bool brief, const std::string &prename, const std::string &name, const std::string &postname) const
Generates a parseable description of the object to the indicated output stream.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this switch into the hash.
DCField * get_key_parameter() const
Returns the key parameter on which the switch is based.
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 ...
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) ...
This class generates an arbitrary hash number from a sequence of ints.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.