Panda3D
|
00001 // Filename: dcArrayParameter.h 00002 // Created by: drose (17Jun04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef DCARRAYPARAMETER_H 00016 #define DCARRAYPARAMETER_H 00017 00018 #include "dcbase.h" 00019 #include "dcParameter.h" 00020 #include "dcNumericRange.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : DCArrayParameter 00024 // Description : This represents an array of some other kind of 00025 // object, meaning this parameter type accepts an 00026 // arbitrary (or possibly fixed) number of nested 00027 // fields, all of which are of the same type. 00028 //////////////////////////////////////////////////////////////////// 00029 class EXPCL_DIRECT DCArrayParameter : public DCParameter { 00030 public: 00031 DCArrayParameter(DCParameter *element_type, 00032 const DCUnsignedIntRange &size = DCUnsignedIntRange()); 00033 DCArrayParameter(const DCArrayParameter ©); 00034 virtual ~DCArrayParameter(); 00035 00036 PUBLISHED: 00037 virtual DCArrayParameter *as_array_parameter(); 00038 virtual const DCArrayParameter *as_array_parameter() const; 00039 virtual DCParameter *make_copy() const; 00040 virtual bool is_valid() const; 00041 00042 DCParameter *get_element_type() const; 00043 int get_array_size() const; 00044 00045 public: 00046 virtual DCParameter *append_array_specification(const DCUnsignedIntRange &size); 00047 00048 virtual int calc_num_nested_fields(size_t length_bytes) const; 00049 virtual DCPackerInterface *get_nested_field(int n) const; 00050 virtual bool validate_num_nested_fields(int num_nested_fields) const; 00051 00052 virtual void output_instance(ostream &out, bool brief, const string &prename, 00053 const string &name, const string &postname) const; 00054 virtual void generate_hash(HashGenerator &hashgen) const; 00055 virtual void pack_string(DCPackData &pack_data, const string &value, 00056 bool &pack_error, bool &range_error) const; 00057 virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; 00058 virtual void unpack_string(const char *data, size_t length, size_t &p, 00059 string &value, bool &pack_error, bool &range_error) const; 00060 00061 protected: 00062 virtual bool do_check_match(const DCPackerInterface *other) const; 00063 virtual bool do_check_match_simple_parameter(const DCSimpleParameter *other) const; 00064 virtual bool do_check_match_class_parameter(const DCClassParameter *other) const; 00065 virtual bool do_check_match_array_parameter(const DCArrayParameter *other) const; 00066 00067 private: 00068 DCParameter *_element_type; 00069 int _array_size; 00070 DCUnsignedIntRange _array_size_range; 00071 }; 00072 00073 #endif