Panda3D
Public Member Functions | Protected Member Functions

DCArrayParameter Class Reference

This represents an array of some other kind of object, meaning this parameter type accepts an arbitrary (or possibly fixed) number of nested fields, all of which are of the same type. More...

#include "dcArrayParameter.h"

Inheritance diagram for DCArrayParameter:
DCParameter DCField DCPackerInterface DCKeywordList

List of all members.

Public Member Functions

 DCArrayParameter (DCParameter *element_type, const DCUnsignedIntRange &size=DCUnsignedIntRange())
 DCArrayParameter (const DCArrayParameter &copy)
virtual DCParameterappend_array_specification (const DCUnsignedIntRange &size)
 Returns the type represented by this_type[size].
virtual DCArrayParameteras_array_parameter ()
virtual const DCArrayParameteras_array_parameter () const
virtual int calc_num_nested_fields (size_t length_bytes) const
 This flavor of get_num_nested_fields is used during unpacking.
virtual void generate_hash (HashGenerator &hashgen) const
 Accumulates the properties of this type into the hash.
int get_array_size () const
 Returns the fixed number of elements in this array, or -1 if the array may contain a variable number of elements.
DCParameterget_element_type () const
 Returns the type of the individual elements of this array.
virtual DCPackerInterfaceget_nested_field (int n) const
 Returns the DCPackerInterface object that represents the nth nested field.
virtual bool is_valid () const
 Returns false if the type is an invalid type (e.g.
virtual DCParametermake_copy () const
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 bool pack_default_value (DCPackData &pack_data, bool &pack_error) const
 Packs the arrayParameter's specified default value (or a sensible default if no value is specified) into the stream.
virtual void pack_string (DCPackData &pack_data, const 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, string &value, bool &pack_error, bool &range_error) const
 Unpacks the current numeric or string value from the stream.
virtual bool validate_num_nested_fields (int num_nested_fields) const
 After a number of fields have been packed via push()

Protected Member Functions

virtual bool do_check_match (const DCPackerInterface *other) const
 Returns true if the other interface is bitwise the same as this one--that is, a uint32 only matches a uint32, etc.
virtual bool do_check_match_array_parameter (const DCArrayParameter *other) const
 Returns true if this field matches the indicated array parameter, false otherwise.
virtual bool do_check_match_class_parameter (const DCClassParameter *other) const
 Returns true if this field matches the indicated class parameter, false otherwise.
virtual bool do_check_match_simple_parameter (const DCSimpleParameter *other) const
 Returns true if this field matches the indicated simple parameter, false otherwise.

Detailed Description

This represents an array of some other kind of object, meaning this parameter type accepts an arbitrary (or possibly fixed) number of nested fields, all of which are of the same type.

Definition at line 29 of file dcArrayParameter.h.


Member Function Documentation

DCParameter * DCArrayParameter::append_array_specification ( const DCUnsignedIntRange size) [virtual]

Returns the type represented by this_type[size].

In the case of a DCArrayParameter, this means it modifies the current type to append the array specification on the innermost type, and returns this same pointer again.

Reimplemented from DCParameter.

Definition at line 175 of file dcArrayParameter.cxx.

References DCParameter::append_array_specification(), and DCParameter::get_typedef().

int DCArrayParameter::calc_num_nested_fields ( size_t  length_bytes) const [virtual]

This flavor of get_num_nested_fields is used during unpacking.

It returns the number of nested fields to expect, given a certain length in bytes (as read from the get_num_length_bytes() stored in the stream on the pack). This will only be called if get_num_length_bytes() returns nonzero.

Reimplemented from DCPackerInterface.

Definition at line 197 of file dcArrayParameter.cxx.

References DCPackerInterface::get_fixed_byte_size(), and DCPackerInterface::has_fixed_byte_size().

bool DCArrayParameter::do_check_match ( const DCPackerInterface other) const [protected, virtual]

Returns true if the other interface is bitwise the same as this one--that is, a uint32 only matches a uint32, etc.

Names of components, and range limits, are not compared.

Implements DCPackerInterface.

Definition at line 402 of file dcArrayParameter.cxx.

References DCPackerInterface::do_check_match_array_parameter().

bool DCArrayParameter::do_check_match_array_parameter ( const DCArrayParameter other) const [protected, virtual]

Returns true if this field matches the indicated array parameter, false otherwise.

Reimplemented from DCPackerInterface.

Definition at line 435 of file dcArrayParameter.cxx.

References DCPackerInterface::check_match().

bool DCArrayParameter::do_check_match_class_parameter ( const DCClassParameter other) const [protected, virtual]

Returns true if this field matches the indicated class parameter, false otherwise.

Reimplemented from DCPackerInterface.

Definition at line 424 of file dcArrayParameter.cxx.

bool DCArrayParameter::do_check_match_simple_parameter ( const DCSimpleParameter other) const [protected, virtual]

Returns true if this field matches the indicated simple parameter, false otherwise.

Reimplemented from DCPackerInterface.

Definition at line 413 of file dcArrayParameter.cxx.

void DCArrayParameter::generate_hash ( HashGenerator hashgen) const [virtual]

Accumulates the properties of this type into the hash.

Reimplemented from DCParameter.

Definition at line 266 of file dcArrayParameter.cxx.

References DCParameter::generate_hash().

int DCArrayParameter::get_array_size ( ) const

Returns the fixed number of elements in this array, or -1 if the array may contain a variable number of elements.

Definition at line 160 of file dcArrayParameter.cxx.

Referenced by DCSimpleParameter::do_check_match_array_parameter(), and DCClassParameter::do_check_match_array_parameter().

DCParameter * DCArrayParameter::get_element_type ( ) const

Returns the type of the individual elements of this array.

Definition at line 148 of file dcArrayParameter.cxx.

Referenced by DCSimpleParameter::do_check_match_array_parameter(), and DCClassParameter::do_check_match_array_parameter().

DCPackerInterface * DCArrayParameter::get_nested_field ( int  n) const [virtual]

Returns the DCPackerInterface object that represents the nth nested field.

This may return NULL if there is no such field (but it shouldn't do this if n is in the range 0 <= n < get_num_nested_fields()).

Reimplemented from DCPackerInterface.

Definition at line 213 of file dcArrayParameter.cxx.

bool DCArrayParameter::is_valid ( ) const [virtual]

Returns false if the type is an invalid type (e.g.

declared from an undefined typedef), true if it is valid.

Implements DCParameter.

Definition at line 137 of file dcArrayParameter.cxx.

void DCArrayParameter::output_instance ( ostream &  out,
bool  brief,
const string &  prename,
const string &  name,
const string &  postname 
) const [virtual]

Formats the parameter in the C++-like dc syntax as a typename and identifier.

Implements DCParameter.

Definition at line 242 of file dcArrayParameter.cxx.

References DCParameter::get_typedef(), and DCParameter::output_typedef_name().

bool DCArrayParameter::pack_default_value ( DCPackData pack_data,
bool &  pack_error 
) const [virtual]

Packs the arrayParameter's specified default value (or a sensible default if no value is specified) into the stream.

Returns true if the default value is packed, false if the arrayParameter doesn't know how to pack its default value.

Reimplemented from DCField.

Definition at line 318 of file dcArrayParameter.cxx.

References DCPackData::append_data(), DCPacker::begin_pack(), DCPacker::end_pack(), DCPacker::get_data(), DCPacker::get_length(), DCNumericRange< NUM >::get_min(), DCNumericRange< NUM >::is_empty(), DCPacker::pack_default_value(), DCPacker::pop(), and DCPacker::push().

void DCArrayParameter::pack_string ( DCPackData pack_data,
const string &  value,
bool &  pack_error,
bool &  range_error 
) const [virtual]

Packs the indicated numeric or string value into the stream.

Reimplemented from DCPackerInterface.

Definition at line 279 of file dcArrayParameter.cxx.

References DCPackData::append_data(), DCSimpleParameter::get_type(), DCPackData::get_write_pointer(), and DCNumericRange< NUM >::validate().

void DCArrayParameter::unpack_string ( const char *  data,
size_t  length,
size_t &  p,
string &  value,
bool &  pack_error,
bool &  range_error 
) const [virtual]

Unpacks the current numeric or string value from the stream.

Reimplemented from DCPackerInterface.

Definition at line 357 of file dcArrayParameter.cxx.

References DCSimpleParameter::get_type().

bool DCArrayParameter::validate_num_nested_fields ( int  num_nested_fields) const [virtual]

After a number of fields have been packed via push()

. pack_*() .. pop(), this is called to confirm that the number of nested fields that were added is valid for this type. This is primarily useful for array types with dynamic ranges that can't validate the number of fields any other way.

Reimplemented from DCPackerInterface.

Definition at line 228 of file dcArrayParameter.cxx.

References DCNumericRange< NUM >::validate().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations