14#ifndef DCSIMPLEPARAMETER_H
15#define DCSIMPLEPARAMETER_H
28class EXPCL_DIRECT_DCPARSER DCSimpleParameter :
public DCParameter {
31 DCSimpleParameter(
const DCSimpleParameter ©);
34 virtual DCSimpleParameter *as_simple_parameter();
35 virtual const DCSimpleParameter *as_simple_parameter()
const;
36 virtual DCParameter *make_copy()
const;
48 bool set_range(
const DCDoubleRange &range);
54 bool &pack_error,
bool &range_error)
const;
56 bool &pack_error,
bool &range_error)
const;
58 bool &pack_error,
bool &range_error)
const;
60 bool &pack_error,
bool &range_error)
const;
62 bool &pack_error,
bool &range_error)
const;
64 bool &pack_error,
bool &range_error)
const;
66 bool &pack_error,
bool &range_error)
const;
69 virtual void unpack_double(
const char *data,
size_t length,
size_t &p,
70 double &value,
bool &pack_error,
bool &range_error)
const;
71 virtual void unpack_int(
const char *data,
size_t length,
size_t &p,
72 int &value,
bool &pack_error,
bool &range_error)
const;
73 virtual void unpack_uint(
const char *data,
size_t length,
size_t &p,
74 unsigned int &value,
bool &pack_error,
bool &range_error)
const;
75 virtual void unpack_int64(
const char *data,
size_t length,
size_t &p,
76 int64_t &value,
bool &pack_error,
bool &range_error)
const;
77 virtual void unpack_uint64(
const char *data,
size_t length,
size_t &p,
78 uint64_t &value,
bool &pack_error,
bool &range_error)
const;
79 virtual void unpack_string(
const char *data,
size_t length,
size_t &p,
80 std::string &value,
bool &pack_error,
bool &range_error)
const;
81 virtual void unpack_blob(
const char *data,
size_t length,
size_t &p,
82 vector_uchar &value,
bool &pack_error,
bool &range_error)
const;
83 virtual bool unpack_validate(
const char *data,
size_t length,
size_t &p,
84 bool &pack_error,
bool &range_error)
const;
85 virtual bool unpack_skip(
const char *data,
size_t length,
size_t &p,
86 bool &pack_error)
const;
88 virtual void output_instance(std::ostream &out,
bool brief,
const std::string &prename,
89 const std::string &name,
const std::string &postname)
const;
93 virtual bool do_check_match(
const DCPackerInterface *other)
const;
99 unsigned int divisor);
100 static DCPackerInterface *create_uint32uint8_type();
104 unsigned int _divisor;
107 DCPackerInterface *_nested_field;
108 size_t _bytes_per_element;
113 typedef pmap<unsigned int, DCSimpleParameter *> DivisorMap;
114 typedef pmap<DCSubatomicType, DivisorMap> NestedFieldMap;
115 static NestedFieldMap _nested_field_map;
119 DCDoubleRange _orig_range;
121 double _orig_modulus;
124 DCIntRange _int_range;
125 DCUnsignedIntRange _uint_range;
126 DCInt64Range _int64_range;
127 DCUnsignedInt64Range _uint64_range;
128 DCDoubleRange _double_range;
131 unsigned int _uint_modulus;
132 uint64_t _uint64_modulus;
133 double _double_modulus;
This represents an array of some other kind of object, meaning this parameter type accepts an arbitra...
This represents a class (or struct) object used as a parameter itself.
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.
virtual void pack_int64(DCPackData &pack_data, int64_t value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual void unpack_blob(const char *data, size_t length, size_t &p, std::vector< unsigned char > &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void pack_uint(DCPackData &pack_data, unsigned int value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual void unpack_uint64(const char *data, size_t length, size_t &p, uint64_t &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void unpack_double(const char *data, size_t length, size_t &p, double &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void pack_uint64(DCPackData &pack_data, uint64_t value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual bool unpack_validate(const char *data, size_t length, size_t &p, bool &pack_error, bool &range_error) const
Internally unpacks the current numeric or string value and validates it against the type range limits...
virtual int calc_num_nested_fields(size_t length_bytes) const
This flavor of get_num_nested_fields is used during unpacking.
virtual bool do_check_match_simple_parameter(const DCSimpleParameter *other) const
Returns true if this field matches the indicated simple parameter, false otherwise.
virtual void unpack_uint(const char *data, size_t length, size_t &p, unsigned int &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void pack_string(DCPackData &pack_data, const std::string &value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual void unpack_string(const char *data, size_t length, size_t &p, std::string &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void unpack_int(const char *data, size_t length, size_t &p, int &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void pack_int(DCPackData &pack_data, int value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual void pack_double(DCPackData &pack_data, double value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual void unpack_int64(const char *data, size_t length, size_t &p, int64_t &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
virtual bool do_check_match_array_parameter(const DCArrayParameter *other) const
Returns true if this field matches the indicated array parameter, false otherwise.
virtual void pack_blob(DCPackData &pack_data, const std::vector< unsigned char > &value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual bool unpack_skip(const char *data, size_t length, size_t &p, bool &pack_error) const
Increments p to the end of the current field without actually unpacking any data or performing any ra...
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this type into the hash.
DCSubatomicType get_type() const
Returns the particular subatomic type represented by this instance.
bool set_range(const DCDoubleRange &range)
Sets the parameter with the indicated range.
virtual bool is_valid() const
Returns false if the type is an invalid type (e.g.
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.
double get_modulus() const
Returns the modulus associated with this type, if any.
bool set_modulus(double modulus)
Assigns the indicated modulus to the simple type.
bool has_modulus() const
Returns true if there is a modulus associated, false otherwise.,.
bool set_divisor(unsigned int divisor)
Assigns the indicated divisor to the simple type.
int get_divisor() const
Returns the divisor associated with this type.
bool is_numeric_type() const
Returns true if the type is a numeric type (and therefore can accept a divisor and/or a modulus),...
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.
DCSubatomicType
This defines the numeric type of each element of a DCAtomicField; that is, the particular values that...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.