alternative to assert
[gtkD.git] / gtkD / srcgda / gda / DataModelHash.d
blob7497268171e9a866964f863dbd37b91801589ab8
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = libgda-GdaDataModelHash.html
26 * outPack = gda
27 * outFile = DataModelHash
28 * strct = GdaDataModelHash
29 * realStrct=
30 * ctorStrct=
31 * clss = DataModelHash
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gda_data_model_hash_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - gda.DataModel
45 * structWrap:
46 * - GdaDataModel* -> DataModel
47 * module aliases:
48 * local aliases:
51 module gda.DataModelHash;
53 version(noAssert)
55 version(Tango)
57 import tango.io.Stdout; // use the tango loging?
61 private import gdac.gdatypes;
63 private import gdac.gda;
66 private import gda.DataModel;
71 /**
72 * Description
73 * Unlike GdaDataModelArray, this data model implementation stores the GdaRow in
74 * a hash table. So it only retrieves from the database backend exactly the
75 * requested rows (while in GdaDataModelArray you have to retrieve all the rows
76 * until the one requested).
78 public class DataModelHash
81 /** the main Gtk struct */
82 protected GdaDataModelHash* gdaDataModelHash;
85 public GdaDataModelHash* getDataModelHashStruct()
87 return gdaDataModelHash;
91 /** the main Gtk struct as a void* */
92 protected void* getStruct()
94 return cast(void*)gdaDataModelHash;
97 /**
98 * Sets our main struct and passes it to the parent class
100 public this (GdaDataModelHash* gdaDataModelHash)
102 version(noAssert)
104 if ( gdaDataModelHash is null )
106 int zero = 0;
107 version(Tango)
109 Stdout("struct gdaDataModelHash is null on constructor").newline;
111 else
113 printf("struct gdaDataModelHash is null on constructor");
115 zero = zero / zero;
118 else
120 assert(gdaDataModelHash !is null, "struct gdaDataModelHash is null on constructor");
122 this.gdaDataModelHash = gdaDataModelHash;
130 * cols :
131 * number of columns for rows in this data model.
132 * Returns :
133 * a pointer to the newly created GdaDataModel.
135 public static DataModel newDataModelHash(int cols)
137 // GdaDataModel* gda_data_model_hash_new (gint cols);
138 return new DataModel( gda_data_model_hash_new(cols) );
142 * Retrieves the value at a specified column and row.
143 * model :
144 * the GdaDataModelHash to retrieve the value from.
145 * col :
146 * column number (starting from 0).
147 * row :
148 * row number (starting from 0).
149 * Returns :
150 * a pointer to a GdaValue.
152 public static GdaValue* getValueAt(DataModel model, int col, int row)
154 // const GdaValue* gda_data_model_hash_get_value_at (GdaDataModel *model, gint col, gint row);
155 return gda_data_model_hash_get_value_at((model is null) ? null : model.getDataModelStruct(), col, row);
159 * Frees all the rows inserted in model.
160 * model :
161 * the model to clear.
163 public void clear()
165 // void gda_data_model_hash_clear (GdaDataModelHash *model);
166 gda_data_model_hash_clear(gdaDataModelHash);
170 * Sets the number of columns for rows inserted in this model.
171 * cols must be greater than or equal to 0.
172 * This function calls gda_data_model_hash_clear to free the
173 * existing rows if any.
174 * model :
175 * the GdaDataModelHash.
176 * cols :
177 * the number of columns for rows inserted in model.
179 public void setNColumns(int cols)
181 // void gda_data_model_hash_set_n_columns (GdaDataModelHash *model, gint cols);
182 gda_data_model_hash_set_n_columns(gdaDataModelHash, cols);
186 * Inserts a row in the model.
187 * model :
188 * the GdaDataModelHash which is gonna hold the row.
189 * rownum :
190 * the number of the row.
191 * row :
192 * the row to insert. The model is responsible of freeing it!
194 public void insertRow(int rownum, GdaRow* row)
196 // void gda_data_model_hash_insert_row (GdaDataModelHash *model, gint rownum, GdaRow *row);
197 gda_data_model_hash_insert_row(gdaDataModelHash, rownum, row);
201 * Retrieves a row from the underlying hash table.
202 * model :
203 * the GdaDataModelHash
204 * row :
205 * row number
206 * Returns :
207 * a GdaRow or NULL if the requested row is not in the hash table.
209 public static GdaRow* getRow(DataModel model, int row)
211 // const GdaRow* gda_data_model_hash_get_row (GdaDataModel *model, gint row);
212 return gda_data_model_hash_get_row((model is null) ? null : model.getDataModelStruct(), row);