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  * Description
77  * Unlike GdaDataModelArray, this data model implementation stores the GdaRow in
78  * a hash table. So it only retrieves from the database backend exactly the
79  * requested rows (while in GdaDataModelArray you have to retrieve all the rows
80  * until the one requested).
81  */
82 public class DataModelHash : DataModel
83 {
84 	
85 	/** the main Gtk struct */
86 	protected GdaDataModelHash* gdaDataModelHash;
87 	
88 	
89 	public GdaDataModelHash* getDataModelHashStruct()
90 	{
91 		return gdaDataModelHash;
92 	}
93 	
94 	
95 	/** the main Gtk struct as a void* */
96 	protected override void* getStruct()
97 	{
98 		return cast(void*)gdaDataModelHash;
99 	}
100 	
101 	/**
102 	 * Sets our main struct and passes it to the parent class
103 	 */
104 	public this (GdaDataModelHash* gdaDataModelHash)
105 	{
106 		super(cast(GdaDataModel*)gdaDataModelHash);
107 		this.gdaDataModelHash = gdaDataModelHash;
108 	}
109 	
110 	protected override void setStruct(GObject* obj)
111 	{
112 		super.setStruct(obj);
113 		gdaDataModelHash = cast(GdaDataModelHash*)obj;
114 	}
115 	
116 	/**
117 	 */
118 	
119 	/**
120 	 * Params:
121 	 * cols = number of columns for rows in this data model.
122 	 * Throws: ConstructionException GTK+ fails to create the object.
123 	 */
124 	public this (int cols)
125 	{
126 		// GdaDataModel* gda_data_model_hash_new (gint cols);
127 		auto p = gda_data_model_hash_new(cols);
128 		if(p is null)
129 		{
130 			throw new ConstructionException("null returned by gda_data_model_hash_new(cols)");
131 		}
132 		this(cast(GdaDataModelHash*) p);
133 	}
134 	
135 	/**
136 	 * Retrieves the value at a specified column and row.
137 	 * Params:
138 	 * model = the GdaDataModelHash to retrieve the value from.
139 	 * col = column number (starting from 0).
140 	 * row = row number (starting from 0).
141 	 * Returns: a pointer to a GdaValue.
142 	 */
143 	public static Value getValueAt(DataModel model, int col, int row)
144 	{
145 		// const GdaValue* gda_data_model_hash_get_value_at (GdaDataModel *model,  gint col,  gint row);
146 		auto p = gda_data_model_hash_get_value_at((model is null) ? null : model.getDataModelStruct(), col, row);
147 		
148 		if(p is null)
149 		{
150 			return null;
151 		}
152 		
153 		return ObjectG.getDObject!(Value)(cast(GdaValue*) p);
154 	}
155 	
156 	/**
157 	 * Frees all the rows inserted in model.
158 	 */
159 	public void clear()
160 	{
161 		// void gda_data_model_hash_clear (GdaDataModelHash *model);
162 		gda_data_model_hash_clear(gdaDataModelHash);
163 	}
164 	
165 	/**
166 	 * Sets the number of columns for rows inserted in this model.
167 	 * cols must be greater than or equal to 0.
168 	 * This function calls gda_data_model_hash_clear to free the
169 	 * existing rows if any.
170 	 * Params:
171 	 * cols = the number of columns for rows inserted in model.
172 	 */
173 	public void setNColumns(int cols)
174 	{
175 		// void gda_data_model_hash_set_n_columns (GdaDataModelHash *model,  gint cols);
176 		gda_data_model_hash_set_n_columns(gdaDataModelHash, cols);
177 	}
178 	
179 	/**
180 	 * Inserts a row in the model.
181 	 * Params:
182 	 * rownum = the number of the row.
183 	 * row = the row to insert. The model is responsible of freeing it!
184 	 */
185 	public void insertRow(int rownum, Row row)
186 	{
187 		// void gda_data_model_hash_insert_row (GdaDataModelHash *model,  gint rownum,  GdaRow *row);
188 		gda_data_model_hash_insert_row(gdaDataModelHash, rownum, (row is null) ? null : row.getRowStruct());
189 	}
190 	
191 	/**
192 	 * Retrieves a row from the underlying hash table.
193 	 * Params:
194 	 * model = the GdaDataModelHash
195 	 * row = row number
196 	 * Returns: a GdaRow or NULL if the requested row is not in the hash table.
197 	 */
198 	public static Row getRow(DataModel model, int row)
199 	{
200 		// const GdaRow* gda_data_model_hash_get_row (GdaDataModel *model,  gint row);
201 		auto p = gda_data_model_hash_get_row((model is null) ? null : model.getDataModelStruct(), row);
202 		
203 		if(p is null)
204 		{
205 			return null;
206 		}
207 		
208 		return ObjectG.getDObject!(Row)(cast(GdaRow*) p);
209 	}
210 }