37 virtual const DCSwitch *as_switch()
const;
47 vector_uchar
get_value(
int case_index)
const;
54 int add_case(
const vector_uchar &value);
62 virtual void output(std::ostream &out,
bool brief)
const;
63 virtual void write(std::ostream &out,
bool brief,
int indent_level)
const;
64 void output_instance(std::ostream &out,
bool brief,
const std::string &prename,
65 const std::string &name,
const std::string &postname)
const;
66 void write_instance(std::ostream &out,
bool brief,
int indent_level,
67 const std::string &prename,
const std::string &name,
68 const std::string &postname)
const;
75 typedef pvector<DCField *> Fields;
76 typedef pmap<std::string, DCField *> FieldsByName;
78 class SwitchFields :
public DCPackerInterface {
80 SwitchFields(
const std::string &name);
87 void output(std::ostream &out,
bool brief)
const;
88 void write(std::ostream &out,
bool brief,
int indent_level)
const;
91 virtual bool do_check_match(
const DCPackerInterface *other)
const;
95 FieldsByName _fields_by_name;
96 bool _has_default_value;
101 SwitchCase(
const vector_uchar &value,
SwitchFields *fields);
118 typedef pvector<SwitchCase *> Cases;
124 typedef pvector<SwitchFields *> CaseFields;
125 CaseFields _case_fields;
130 Fields _nested_fields;
136 CaseFields _current_fields;
140 typedef pmap<vector_uchar, int> CasesByValue;
141 CasesByValue _cases_by_value;
This is a common interface for a declaration in a DC file.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
void write(std::ostream &out, int indent_level) const
Write a string representation of this instance to <out>.
A single field of a Distributed Class, either atomic or molecular.
This is a block of data that receives the results of DCPacker.
This defines the internal interface for packing values into a DCField.
Represents the type specification for a single parameter within a field specification.
bool do_check_match_switch_case(const SwitchCase *other) const
Returns true if this case matches the indicated case, false otherwise.
bool add_field(DCField *field)
Adds a field to this case.
bool do_check_match_switch_case(const SwitchFields *other) const
Returns true if this case matches the indicated case, false otherwise.
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
const std::string & get_name() const
Returns the name of this switch.
DCPackerInterface * get_case(int n) const
Returns the DCPackerInterface that packs the nth case.
int get_num_fields(int case_index) const
Returns the number of fields in the indicated case.
bool add_default()
Adds a default case to the switch.
DCField * get_field(int case_index, int n) const
Returns the nth field in the indicated case.
int get_case_by_value(const std::vector< unsigned char > &case_value) const
Returns the index number of the case with the indicated packed value, or -1 if no case has this value...
std::vector< unsigned char > get_value(int case_index) const
Returns the packed value associated with the indicated case.
bool add_field(DCField *field)
Adds a field to the currently active cases (those that have been added via add_case() or add_default(...
bool is_field_valid() const
Returns true if it is valid to add a new field at this point (implying that a case or default has bee...
DCSwitch(const std::string &name, DCField *key_parameter)
The key_parameter must be recently allocated via new; it will be deleted via delete when the switch d...
void add_break()
Adds a break statement to the switch.
int get_num_cases() const
Returns the number of different cases within the 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.
void add_invalid_case()
Adds a new case to the switch that will never be matched.
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.
DCPackerInterface * get_default_case() const
Returns the DCPackerInterface that packs the default case, or NULL if there is no default case.
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) ...
int add_case(const std::vector< unsigned char > &value)
Adds a new case to the switch with the indicated value, and returns the new case_index.
DCField * get_field_by_name(int case_index, const std::string &name) const
Returns the field with the given name from the indicated case, or NULL if no field has this name.
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.