GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

GATTable.h

Go to the documentation of this file.
00001 /** @file GATTable.h
00002  * Header file for the GATTable class.
00003  * 
00004  * GatTable is a set of routines for implementing 
00005  * hash tables within the GAT engine
00006  * 
00007  * @date Sun Sep 21 2003
00008  * 
00009  *  Copyright (C) Gavin Powell
00010  *  This file is part of the GAT Engine.
00011  *  Contributed by Gavin Powell <g.r.powell@cs.cf.ac.uk>.
00012  *
00013  *  Use, modification and distribution is subject to the Gridlab Software
00014  *  License. (See accompanying file GLlicense.txt or copy at
00015  *  http://www.gridlab.org/GLlicense.txt)
00016  */
00017 
00018 #ifndef _GATHASH_H_
00019 #define _GATHASH_H_ 1
00020 
00021 #include "GATType.h"
00022 #include "GATObject.h"
00023 
00024 /* typedefs */
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030 /* Declare the converters to/from GATObject */
00031 GATOBJECT_DECLARE_CONVERTERS(GATTable);
00032 
00033 /* GATTable with a string as a key */
00034 
00035 /** GATTable_Create
00036  *  Create the GATTable object.
00037  *  this_ is the method used by any 
00038  *  application code to create the GATTable
00039  *  object.
00040  *  
00041  * @param void.
00042  *
00043  * @return The GATTable object
00044  */
00045 GATTable GATTable_Create(void);
00046 
00047 /** int GATTable_GetType(GATTable_const file)
00048  *  @brief Return the type of the GATTable
00049  *
00050  *  The function @c GATTable_GetType always returns GATType_GATTable. 
00051  *
00052  *  @param object The object to inspect
00053  *
00054  *  @return returns always @c #GATType_GATTable.
00055  */
00056 GATType GATTable_GetType(GATTable_const table);
00057 
00058 /** GATTable_Destroy
00059  *  The GATTable destructor.
00060  *  This is the destructor for GATTable objects.
00061  *
00062  * @param this An old GATTable
00063  */
00064 void GATTable_Destroy(GATTable *table);
00065 
00066 /** int GATTable_Equals(GATTable_const lhs, GATTable_const rhs, GATBool *isequal)
00067  *  @brief Compares two GATTable objects
00068  *
00069  *  The function @c GATTable_Equals compares two file objects of type 
00070  *  @c #GATTable.
00071  *
00072  *  @param lhs The first file object to compare
00073  *  @param rhs The second file object to compare
00074  *  @param isequal The pointer to the GATBool variable, which should receive 
00075  *        the result if the comparison
00076  *
00077  *  @return An error code.
00078  */
00079 GATResult 
00080   GATTable_Equals(GATTable_const lhs, GATTable_const rhs, GATBool *isequal);
00081 
00082 /** int GATTable_Clone(GATTable_const filehandle, GATTable *new_file)
00083  *  @brief Clone the given GATTable
00084  *
00085  *  The function @c GATTable_Clone generates a (deep) copy of the given
00086  *  GATTable. 
00087  *
00088  *  @param filehandle The object to clone
00089  *  @param new_file The pointer, through which the result is to be 
00090  *        returned.
00091  *
00092  *  @return An error type.
00093  */
00094 GATResult GATTable_Clone(GATTable_const table, GATTable *new_table);
00095 
00096 /** int GATTable_GetInterface(GATTable_const table, GATInterface iftype, void const **ifp)
00097  *  @brief Get an interface supported by a GATList
00098  *
00099  *  The function GATTable_GetInterface allows to get a pointer to an 
00100  *  additional interface supported by this GATList.
00101  *
00102  *  @param object The object to be asked for the new interface.
00103  *  @param iftype The interface the object is to be asked for.
00104  *  @param ifp The pointer, through which the result is to be returned.
00105  *
00106  *  @return An error type.
00107  */
00108 GATResult 
00109 GATTable_GetInterface(GATTable_const table, GATInterface iftype, void const **ifp);
00110 
00111 /** GATTable_Remove
00112  *  Remove a key,value pair from the hash table.
00113  *  
00114  * @param this_ The hash table to remove from.
00115  * @param key The the key for the key,value pair to be removed
00116  *
00117  * @return GAT error code
00118  */
00119 GATResult GATTable_Remove(GATTable table, const void *key);
00120 
00121 /** GATTable_Add_Int
00122  *  Add a type int to the hash table.
00123  *  
00124  * @param table The hash table to add the data to.
00125  * @param key The key value to associate the data to.
00126  * @param data The int data to be added
00127  *
00128  * @return GAT error code
00129  */
00130 GATResult GATTable_Add_int(GATTable table, const void *key, GATint32 data);
00131 
00132 /** GATTable_Add_Short
00133  *  Add a type short to the hash table.
00134  *  
00135  * @param table The hash table to add the data to.
00136  * @param key The key value to associate the data to.
00137  * @param data The short data to be added
00138  *
00139  * @return GAT error code
00140  */
00141 GATResult GATTable_Add_short(GATTable table, const void *key, GATint16 data);
00142 
00143 /** GATTable_Add_Double
00144  *  Add a type double to the hash table.
00145  *  
00146  * @param table The hash table to add the data to.
00147  * @param key The key value to associate the data to.
00148  * @param data The double data to be added
00149  *
00150  * @return GAT error code
00151  */
00152 GATResult GATTable_Add_double(GATTable table, const void *key, GATdouble64 data);
00153 
00154 /** GATTable_Add_Float
00155  *  Add a type float to the hash table.
00156  *  
00157  * @param table The hash table to add the data to.
00158  * @param key The key value to associate the data to.
00159  * @param data The float data to be added
00160  *
00161  * @return GAT error code
00162  */
00163 GATResult GATTable_Add_float(GATTable table, const void *key, GATfloat32 data);
00164 
00165 /** GATTable_Add_String
00166  *  Add a type string to the hash table.
00167  *  
00168  * @param table The hash table to add the data to.
00169  * @param key The key value to associate the data to.
00170  * @param data The string data to be added
00171  *
00172  * @return GAT error code
00173  */
00174 GATResult GATTable_Add_String(GATTable table, const void *key, const char *data);
00175 
00176 /** GATTable_Add_GATObject
00177  *  Add a type GATObject to the hash table.
00178  *  
00179  * @param table The hash table to add the data to.
00180  * @param key The key value to associate the data to.
00181  * @param data The float data to be added
00182  *
00183  * @return GAT error code
00184  */
00185 GATResult GATTable_Add_GATObject(GATTable table, const void *key, 
00186   GATObject_const object);
00187   
00188 /** GATTable_Get_ElementType
00189  *  Get the type associated with a key.
00190  *  
00191  * @param table The hash table to get the type from.
00192  * @param key The key value associated with the data type.
00193  *
00194  * @return GATType
00195  */
00196 GATType GATTable_Get_ElementType(GATTable_const table, const void *key);
00197 
00198 /** GATTable_GetKeys
00199  *  Get a list of all the current keys in the hash table. The key list is 
00200  *  terminated by a NULL
00201  *  
00202  * @param table The hash table to get the keys from.
00203  *
00204  * @return the list of keys
00205  */
00206 void **GATTable_GetKeys(GATTable_const table);
00207 
00208 /** GATTable_ReleaseKeys
00209  *
00210  *  The function GATTable_ReleaseKeys may be used to free all the keys 
00211  *  allocated by a call to the GATTable_GetKeys function.
00212  *
00213  *  @param table The table, from which the keys where retrieved.
00214  *  @param keys The pointer to the array of keys returned by a call to the 
00215  *        GATTable_GetKeys function.
00216  */
00217 void GATTable_ReleaseKeys(GATTable_const table, void ***keys);
00218 
00219 /** GATTable_Get_Int
00220  *  Get the int type data associated with a key.
00221  *  
00222  * @param table The hash table get the data from.
00223  * @param key The key value to associate the data to.
00224  * @param data The recovered int data
00225  *
00226  * @return GAT error code
00227  */
00228 GATResult GATTable_Get_int(GATTable_const table, const void *key, GATint32 *data);
00229 
00230 /** GATTable_Get_Short
00231  *  Get the short type data associated with a key.
00232  *  
00233  * @param table The hash table get the data from.
00234  * @param key The key value to associate the data to.
00235  * @param data The recovered short data
00236  *
00237  * @return GAT error code
00238  */
00239 GATResult GATTable_Get_short(GATTable_const table, const void *key, GATint16 *data);
00240 
00241 /** GATTable_Get_Double
00242  *  Get the double type data associated with a key.
00243  *  
00244  * @param table The hash table get the data from.
00245  * @param key The key value to associate the data to.
00246  * @param data The recovered double data
00247  *
00248  * @return GAT error code
00249  */
00250 GATResult GATTable_Get_double(GATTable_const table, const void *key, double *data);
00251 
00252 /** GATTable_Get_Float
00253  *  Get the float type data associated with a key.
00254  *  
00255  * @param table The hash table get the data from.
00256  * @param key The key value to associate the data to.
00257  * @param data The recovered float data
00258  *
00259  * @return GAT error code
00260  */
00261 GATResult GATTable_Get_float(GATTable_const table, const void *key, float *data);
00262 
00263 /** GATTable_Get_String
00264  *  Get the string type data associated with a key.  
00265  *
00266  * @param table The hash table get the data from.
00267  * @param key The key value to associate the data to.
00268  * @param data The recovered string data. If table parameter is 0 (zero), the 
00269  *        function does not try to recover the data but simply returns the
00270  *        required size of the buffer needed to recover the data.
00271  * @param length length of the string buffer arg data
00272  *
00273  * @return length of string found or error code
00274  */
00275 GATResult GATTable_Get_String(GATTable_const table, const void *key, char *data, 
00276   GATuint32 length);
00277 
00278 /** GATTable_Get_GATObject
00279  *  Get the GATObject type data associated with a key.
00280  *  
00281  * @param table The hash table get the data from.
00282  * @param key The key value to associate the data to.
00283  * @param data The recovered GATObject data
00284  *
00285  * @return GAT error code
00286  */
00287 GATResult GATTable_Get_GATObject(GATTable_const table, const void *key, 
00288   GATObject_const *object);
00289 
00290 /** GATTable_Size
00291  *  @brief Return the number of elements stored inside a table
00292  *
00293  *  The function @c GATTable_Size returns the number of elements, currently
00294  *  stored inside the given table.
00295  *
00296  *  @param table The table to be queried for its number of elements
00297  *
00298  *  @return If successful, the function returns number of elements. If an error 
00299  *        occures, (size_t)(-1) is returned.
00300  */
00301 GATuint32 GATTable_Size(GATTable_const table);
00302 
00303 
00304 /* GATAdvertiseable API */
00305 #define GATTABLE_VERSION1    0x0100
00306 #define GATTABLE_LASTVERSION GATTABLE_VERSION1
00307 #define GATTABLE_MINOR_MASK  0x00ff
00308 
00309 /** int GATTable_Serialise(GATTable file, GATObject stream, GATBool clear_dirty)
00310  *  @brief Serialise a GATTable object
00311  *
00312  *  The function GATTable_Serialise serialises the given GATTable object into 
00313  *  the given stream. 
00314  *
00315  *  @param file The GATTable object to serialise.
00316  *  @param stream The stream interface to use for the serialisation.
00317  *  @param clear_dirty If the clear_dirty parameter is set to GATTrue, the 
00318  *        internal dirty flag of this object is to be reset (no used here)
00319  *
00320  *  @return An error code.
00321  */
00322 GATResult GATTable_Serialise(GATTable file, GATObject stream, GATBool clear_dirty);
00323 
00324 /** GATTable GATTable_DeSerialise(GATContext context, GATObject stream, GATBool clear_dirty)
00325  *  @brief De-serialise a GATTable object
00326  *
00327  *  The function GATTable_DeSerialise de-serialises a streamed GATTable object  
00328  *  from the given stream  It constructs a new instance of the de-serialised 
00329  *  object.
00330  *
00331  *  @param context The GAT context to be used for object construction.
00332  *  @param stream The stream interface to use for the serialisation.
00333  *  @param result The pointer to a variable, which receives the status code of
00334  *        the operation.
00335  *
00336  *  @return The newly constructed GATTable object.
00337  */
00338 GATTable GATTable_DeSerialise(GATContext context, GATObject stream, 
00339   GATResult *result);
00340 
00341 /** GATTable_GetIsDirty
00342  *  
00343  *  The function GATTable_GetIsDirty retrieves the status of the dirty flag of 
00344  *  this GATTable object.
00345  *
00346  *  @param file The GATTable object to inspect for its dirty status.
00347  *  @param isdirty The pointer to a variable, which receives the dirty status.
00348  *
00349  *  @return An error code.
00350  */
00351 GATResult GATTable_GetIsDirty(GATTable_const file, GATBool *isdirty);
00352   
00353 #ifdef __cplusplus
00354 }
00355 #endif
00356 
00357 #endif /* _GATHASH_H_ */