1 #ifndef IVL_class_type_H 2 #define IVL_class_type_H 3 /* 4 * Copyright (c) 2012-2014 Stephen Williams (steve@icarus.com) 5 * 6 * This source code is free software; you can redistribute it 7 * and/or modify it in source code form under the terms of the GNU 8 * General Public License as published by the Free Software 9 * Foundation; either version 2 of the License, or (at your option) 10 * any later version 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22 # include <string> 23 # include <vector> 24 # include "vpi_priv.h" 25 26 class class_property_t; 27 class vvp_vector4_t; 28 29 /* 30 * This represents the TYPE information for a class. A %new operator 31 * uses this information to figure out how to construct an actual 32 * instance. 33 */ 34 class class_type : public __vpiHandle { 35 36 public: 37 struct inst_x; 38 typedef inst_x*inst_t; 39 40 public: 41 explicit class_type(const std::string&nam, size_t nprop); 42 ~class_type(); 43 44 // This is the name of the class type. class_name(void)45 inline const std::string&class_name(void) const { return class_name_; } 46 // Number of properties in the class definition. property_count(void)47 inline size_t property_count(void) const { return properties_.size(); } 48 49 // Set the details about the property. This is used during 50 // parse of the .vvp file to fill in the details of the 51 // property for the class definition. 52 void set_property(size_t idx, const std::string&name, const std::string&type, uint64_t array_size); 53 54 // This method is called after all the properties are 55 // defined. This calculates information about the definition. 56 void finish_setup(void); 57 58 public: 59 // Constructors and destructors for making instances. 60 inst_t instance_new() const; 61 void instance_delete(inst_t) const; 62 63 void set_vec4(inst_t inst, size_t pid, const vvp_vector4_t&val) const; 64 void get_vec4(inst_t inst, size_t pid, vvp_vector4_t&val) const; 65 void set_real(inst_t inst, size_t pid, double val) const; 66 double get_real(inst_t inst, size_t pid) const; 67 void set_string(inst_t inst, size_t pid, const std::string&val) const; 68 std::string get_string(inst_t inst, size_t pid) const; 69 void set_object(inst_t inst, size_t pid, const vvp_object_t&val, size_t idx) const; 70 void get_object(inst_t inst, size_t pid, vvp_object_t&val, size_t idx) const; 71 72 void copy_property(inst_t dst, size_t idx, inst_t src) const; 73 74 public: // VPI related methods 75 int get_type_code(void) const; 76 77 private: 78 std::string class_name_; 79 80 struct prop_t { 81 std::string name; 82 class_property_t*type; 83 }; 84 std::vector<prop_t> properties_; 85 size_t instance_size_; 86 }; 87 88 #endif /* IVL_class_type_H */ 89