1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = libgda-GdaDataModelHash.html 27 * outPack = gda 28 * outFile = DataModelHash 29 * strct = GdaDataModelHash 30 * realStrct= 31 * ctorStrct=GdaDataModel 32 * clss = DataModelHash 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = GdaDataModel 38 * implements: 39 * prefixes: 40 * - gda_data_model_hash_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - gda.DataModel 47 * - gda.Value 48 * - gda.Row 49 * structWrap: 50 * - GdaDataModel* -> DataModel 51 * - GdaRow* -> Row 52 * - GdaValue* -> Value 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module gda.DataModelHash; 59 60 public import gdac.gdatypes; 61 62 private import gdac.gda; 63 private import glib.ConstructionException; 64 private import gobject.ObjectG; 65 66 67 private import gda.DataModel; 68 private import gda.Value; 69 private import gda.Row; 70 71 72 73 private import gda.DataModel; 74 75 /** 76 * Unlike GdaDataModelArray, this data model implementation stores the GdaRow in 77 * a hash table. So it only retrieves from the database backend exactly the 78 * requested rows (while in GdaDataModelArray you have to retrieve all the rows 79 * until the one requested). 80 */ 81 public class DataModelHash : DataModel 82 { 83 84 /** the main Gtk struct */ 85 protected GdaDataModelHash* gdaDataModelHash; 86 87 88 public GdaDataModelHash* getDataModelHashStruct() 89 { 90 return gdaDataModelHash; 91 } 92 93 94 /** the main Gtk struct as a void* */ 95 protected override void* getStruct() 96 { 97 return cast(void*)gdaDataModelHash; 98 } 99 100 /** 101 * Sets our main struct and passes it to the parent class 102 */ 103 public this (GdaDataModelHash* gdaDataModelHash) 104 { 105 super(cast(GdaDataModel*)gdaDataModelHash); 106 this.gdaDataModelHash = gdaDataModelHash; 107 } 108 109 protected override void setStruct(GObject* obj) 110 { 111 super.setStruct(obj); 112 gdaDataModelHash = cast(GdaDataModelHash*)obj; 113 } 114 115 /** 116 */ 117 118 /** 119 * Params: 120 * cols = number of columns for rows in this data model. 121 * Throws: ConstructionException GTK+ fails to create the object. 122 */ 123 public this (int cols) 124 { 125 // GdaDataModel* gda_data_model_hash_new (gint cols); 126 auto p = gda_data_model_hash_new(cols); 127 if(p is null) 128 { 129 throw new ConstructionException("null returned by gda_data_model_hash_new(cols)"); 130 } 131 this(cast(GdaDataModelHash*) p); 132 } 133 134 /** 135 * Retrieves the value at a specified column and row. 136 * Params: 137 * model = the GdaDataModelHash to retrieve the value from. 138 * col = column number (starting from 0). 139 * row = row number (starting from 0). 140 * Returns: a pointer to a GdaValue. 141 */ 142 public static Value getValueAt(DataModel model, int col, int row) 143 { 144 // const GdaValue* gda_data_model_hash_get_value_at (GdaDataModel *model, gint col, gint row); 145 auto p = gda_data_model_hash_get_value_at((model is null) ? null : model.getDataModelStruct(), col, row); 146 147 if(p is null) 148 { 149 return null; 150 } 151 152 return ObjectG.getDObject!(Value)(cast(GdaValue*) p); 153 } 154 155 /** 156 * Frees all the rows inserted in model. 157 */ 158 public void clear() 159 { 160 // void gda_data_model_hash_clear (GdaDataModelHash *model); 161 gda_data_model_hash_clear(gdaDataModelHash); 162 } 163 164 /** 165 * Sets the number of columns for rows inserted in this model. 166 * cols must be greater than or equal to 0. 167 * This function calls gda_data_model_hash_clear to free the 168 * existing rows if any. 169 * Params: 170 * cols = the number of columns for rows inserted in model. 171 */ 172 public void setNColumns(int cols) 173 { 174 // void gda_data_model_hash_set_n_columns (GdaDataModelHash *model, gint cols); 175 gda_data_model_hash_set_n_columns(gdaDataModelHash, cols); 176 } 177 178 /** 179 * Inserts a row in the model. 180 * Params: 181 * rownum = the number of the row. 182 * row = the row to insert. The model is responsible of freeing it! 183 */ 184 public void insertRow(int rownum, Row row) 185 { 186 // void gda_data_model_hash_insert_row (GdaDataModelHash *model, gint rownum, GdaRow *row); 187 gda_data_model_hash_insert_row(gdaDataModelHash, rownum, (row is null) ? null : row.getRowStruct()); 188 } 189 190 /** 191 * Retrieves a row from the underlying hash table. 192 * Params: 193 * model = the GdaDataModelHash 194 * row = row number 195 * Returns: a GdaRow or NULL if the requested row is not in the hash table. 196 */ 197 public static Row getRow(DataModel model, int row) 198 { 199 // const GdaRow* gda_data_model_hash_get_row (GdaDataModel *model, gint row); 200 auto p = gda_data_model_hash_get_row((model is null) ? null : model.getDataModelStruct(), row); 201 202 if(p is null) 203 { 204 return null; 205 } 206 207 return ObjectG.getDObject!(Row)(cast(GdaRow*) p); 208 } 209 }