GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATList.h

Go to the documentation of this file.
00001 /** @file GATList.h
00002  * Header file for the type specific GATList interface declaration.
00003  * 
00004  * GATList is a set of functions for implementing double linked lists of
00005  * objects of arbitrary type.
00006  * 
00007  * @date Fri Sep 26 2003
00008  *
00009  * @version: $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATList.h,v 1.25 2004/03/24 19:30:58 hartmutkaiser Exp $
00010  *
00011  *  Copyright (C) Hartmut Kaiser
00012  *  This file is part of the GAT Engine.
00013  *  Contributed by Hartmut Kaiser <hartmutkaiser [at] t-online [dot] de>.
00014  *
00015  *  Use, modification and distribution is subject to the Gridlab Software
00016  *  License. (See accompanying file GLlicense.txt or copy at
00017  *  http://www.gridlab.org/GLlicense.txt)
00018  */
00019 
00020 #if !defined(_GATLIST_H_)
00021 #define _GATLIST_H_ 1
00022 
00023 #include <stdlib.h>
00024 
00025 #include "GATObject.h"
00026 #include "GATType.h"
00027 
00028 /** GATList_type GATList_type_Create()
00029  *  @brief Create a new list of @c type's
00030  *
00031  *  The function @c GATList_type_Create creates a new list @c GATList_type, 
00032  *  which holds objects of the given @c type. 
00033  *
00034  *  @return Returns a handle to the newly created list. If an error occures
00035  *        0 (zero) is returned.
00036  *
00037  *  @remark The concrete function name to use is determined by the type to be
00038  *        stored inside the list. For instance, a list containing @c int's  
00039  *        would be created with the function @c GATList_int_Create.
00040  */
00041 #if defined(DOXYGEN)
00042 GATList_type 
00043   GATList_type_Create();
00044 #endif
00045 
00046 /** int GATList_type_Equals(GATList_type const lhs, GATList_type const rhs, GATBool *isequal)
00047  *  @brief Compare two lists of @c type's
00048  *
00049  *  The function @c GATList_type_Equals compares two lists @c GATList_type, 
00050  *  which holds objects of the given @c type. 
00051  *
00052  *  @param lhs The first list to compare
00053  *  @param rhs The second list to compare
00054  *  @param isequal The pointer, through which the result is to be returned
00055  *
00056  *  @return An error code.
00057  *
00058  *  @remark The concrete function name to use is determined by the type to be
00059  *        stored inside the lists. For instance, a list containing @c int's  
00060  *        would be compared with the function @c GATList_int_Equals.
00061  */
00062 #if defined(DOXYGEN)
00063 GATList_type 
00064   GATList_type_Equals(GATList_type const lhs, GATList_type const rhs, 
00065     GATBool *isequal);
00066 #endif
00067 
00068 /** GATType GATList_type_GetType(GATList_type const object)
00069  *  @brief Return the type of the GATList
00070  *
00071  *  The function @c GATList_type_GetType always returns GATType_GATList. 
00072  *
00073  *  @param object The object to inspect
00074  *
00075  *  @return returns always @c #GATType_GATList.
00076  *
00077  *  @remark The concrete function name to use is determined by the type to be
00078  *        stored inside the lists. For instance, a list containing @c int's  
00079  *        would be return its type with @c GATList_int_GetType.
00080  */
00081 #if defined(DOXYGEN)
00082 GATType 
00083   GATList_type_GetType(GATList_type const lhs);
00084 #endif
00085 
00086 /** GATType GATList_type_Clone(GATList_type const list, GATList *new_list)
00087  *  @brief Clone the given list
00088  *
00089  *  The function @c GATList_type_Clone generates a (deep) copy of the given
00090  *  list. 
00091  *
00092  *  @param list The object to clone
00093  *  @param new_object The pointer, through which the result is to be returned.
00094  *
00095  *  @return An error type.
00096  *
00097  *  @remark The concrete function name to use is determined by the type to be
00098  *        stored inside the lists. For instance, a list containing @c int's  
00099  *        would be return its type with @c GATList_int_GetType.
00100  */
00101 #if defined(DOXYGEN)
00102 GATResult 
00103   GATList_type_Clone(GATList_type const list, GATList *new_list);
00104 #endif
00105 
00106 /** int GATList_type_GetInterface(GATList_const file, GATInterface iftype, void const **ifp)
00107  *  @brief Get an interface supported by a GATList
00108  *
00109  *  The function GATList_GetInterface allows to get a pointer to an 
00110  *  additional interface supported by this GATList.
00111  *
00112  *  @param object The object to be asked for the new interface.
00113  *  @param iftype The interface the object is to be asked for.
00114  *  @param ifp The pointer, through which the result is to be returned.
00115  *
00116  *  @return An error type.
00117  *
00118  *  @remark The concrete function name to use is determined by the type to be
00119  *        stored inside the lists. For instance, a list containing @c int's  
00120  *        would be return its type with @c GATList_int_GetType.
00121  */
00122 #if defined(DOXYGEN)
00123 GATResult 
00124   GATList_type_GetInterface(GATList_const file, GATInterface iftype, 
00125     void const **ifp);
00126 #endif
00127 
00128 /** void GATList_type_Destroy(GATList_type list)
00129  *  @brief Destroy the given list and all of its contents
00130  *
00131  *  The function @c GATList_type_Destroy destroys the given list and all of its
00132  *  elements. If during creation time of this list there was specified a 
00133  *  @c destroyfunc, this function will be called for every element to be 
00134  *  destroyed. 
00135  *
00136  *  @param list The list to be destroyed
00137  *
00138  *  @return Returns @c GAT_SUCCESS if the list was destroyed successfully. If
00139  *        the given parameter was not a valid list, then @c GAT_INVALID_HANLDE 
00140  *        is returned.
00141  *
00142  *  @remark The concrete function name to use is determined by the type to be
00143  *        stored inside the list. For instance, a list containing @c int's 
00144  *        would  be destroyed with the function @c GATList_int_Destroy.
00145  */
00146 #if defined(DOXYGEN)
00147 void 
00148   GATList_type_Destroy(GATList_type *list);
00149 #endif
00150 
00151 /** size_t GATList_type_Size(GATList_type list)
00152  *  @brief Return the number of elements stored inside a list
00153  *
00154  *  The function @c GATList_type_Size returns the number of elements, currently
00155  *  stored inside the given list.
00156  *
00157  *  @param list The list to be queried for its number of elements
00158  *
00159  *  @return If successful, the function returns number of elements. If an error 
00160  *        occures, (size_t)(-1) is returned.
00161  *
00162  *  @remark The concrete function name to use is determined by the type to be
00163  *        stored inside the list. For instance, a list containing @c int's 
00164  *        would be queried for its number of stored elements with the function 
00165  *        @c GATList_int_Size.
00166  */
00167 #if defined(DOXYGEN)
00168 size_t 
00169   GATList_type_Size(GATList_type list);
00170 #endif
00171 
00172 /** GATList_type_Iterator GATList_type_Begin(GATList_type list)
00173  *  @brief Return a pointer to the first element of the list
00174  *
00175  *  The function @c GATList_type_Begin returns a @c GATList_type_Iterator 
00176  *  pointing to the first element of the inspected list.
00177  *
00178  *  @param list The list to be queried for its begin iterator
00179  *
00180  *  @return If successful, the function returns the begin iterator of the list. 
00181  *        If an error occures, 0 (zero) is returned.
00182  *
00183  *  @remark The concrete function name to use is determined by the type to be
00184  *        stored inside the list. For instance, a list containing @c int's 
00185  *        would be queried for its begin iterator with the function 
00186  *        @c GATList_int_Begin.
00187  */
00188 #if defined(DOXYGEN)
00189 GATList_type_Iterator
00190   GATList_type_Begin(GATList_type list);
00191 #endif
00192 
00193 /** GATList_type_Iterator GATList_type_End(GATList_type listhandle)
00194  *  @brief Return a pointer to the first element beyond the last element of the 
00195  *        list.
00196  *
00197  *  The function @c GATList_type_End returns a @c GATList_type_Iterator 
00198  *  pointing to the first element beyond the last of element of the the 
00199  *  inspected list. Please note, that the returned @c GATList_type_Iterator may 
00200  *  @b not be used for accessing a valid element of the list, it may be used 
00201  *  for testing against the end of list condition only.
00202  *
00203  *  @param listhandle The list to be queried for its begin iterator
00204  *
00205  *  @return If successful, the function returns the end iterator of the list. 
00206  *        If an error occures, 0 (zero) is returned.
00207  *
00208  *  @remark The concrete function name to use is determined by the type to be
00209  *        stored inside the list. For instance, a list containing @c int's 
00210  *        would be queried for its end iterator with the function 
00211  *        @c GATList_int_End.
00212  */
00213 #if defined(DOXYGEN)
00214 GATList_type_Iterator
00215   GATList_type_End(GATList_type list);
00216 #endif
00217 
00218 /** GATList_type_Iterator GATList_type_Next(GATList_type_Iterator iter)
00219  *  @brief Return a pointer to the next element beyond the given iterator.
00220  *
00221  *  The function @c GATList_type_Next returns a @c GATList_type_Iterator 
00222  *  pointing to the list element following the element, to which points the 
00223  *  given iterator. 
00224  *
00225  *  @param iter The iterator, which is to be incremented
00226  *
00227  *  @return If successful, the function returns the next iterator of the given
00228  *        one. If the end of the list is reached, the function returns an 
00229  *        iterator, which has the same value as the iterator returned by the
00230  *        function @c #GATList_type_End.
00231  *        If an error occures, 0 (zero) is returned.
00232  *
00233  *  @remark Calling this function with an end iterator of a list will result in 
00234  *        undefined behaviour.
00235  *  @remark The concrete function name to use is determined by the type to be
00236  *        stored inside the list. For instance, a list containing @c int's 
00237  *        would be queried for its next iterator with the function 
00238  *        @c GATList_int_Next.
00239  */
00240 #if defined(DOXYGEN)
00241 GATList_type_Iterator
00242   GATList_type_Next(GATList_type_Iterator iter);
00243 #endif
00244 
00245 /** GATList_type_Iterator GATList_type_Previous(GATList_type_Iterator iter)
00246  *  @brief Return a pointer to the element preceeding the given iterator.
00247  *
00248  *  The function @c GATList_type_Previous returns a @c GATList_type_Iterator 
00249  *  pointing to the list element preceeding the element, to which points the 
00250  *  given iterator. 
00251  *
00252  *  @param iter The iterator, which is to be decremented
00253  *
00254  *  @return If successful, the function returns the previous iterator of the 
00255  *        given one. 
00256  *        If an error occures, 0 (zero) is returned.
00257  *
00258  *  @remark Calling this function with an begin iterator of a list will result 
00259  *        in  undefined behaviour.
00260  *  @remark The concrete function name to use is determined by the type to be
00261  *        stored inside the list. For instance, a list containing @c int's 
00262  *        would be queried for its previous iterator with the function 
00263  *        @c GATList_int_Previous.
00264  */
00265 #if defined(DOXYGEN)
00266 GATList_type_Iterator
00267   GATList_type_Previous(GATList_type_Iterator iter);
00268 #endif
00269 
00270 /** GATList_type_Iterator GATList_type_Insert(GATList_type list, GATList_type_Iterator where, type data)
00271  *  @brief Insert a new element into a list.
00272  *
00273  *  The function @c GATList_type_Insert inserts the new element @c data into 
00274  *  the given list. The new element is inerted just before the element pointed 
00275  *  to by the iterator @c where.
00276  *
00277  *  @param list The list, into which the new element is to be inserted.
00278  *  @param where The position inside the list, where the new element is to be 
00279  *        inserted.
00280  *  @param data The new element, a copy of which is to be inserted into the 
00281  *        list.
00282  *
00283  *  @return If successful, the function returns an iterator pointing to the 
00284  *        newly inserted element
00285  *        If an error occures, 0 (zero) is returned.
00286  *
00287  *  @remark If the given position @c where is the begin iterator of the list
00288  *        the new element is inserted as the first element, if the position is 
00289  *        the end iterator of the list, the new element is inserted as the last 
00290  *        element.
00291  *  @remark The concrete function name to use is determined by the type to be
00292  *        stored inside the list. For instance, to insert a new element into a 
00293  *        list containing @c int's the function @c GATList_int_Insert would be
00294  *        used.
00295  */
00296 #if defined(DOXYGEN)
00297 GATList_type_Iterator
00298   GATList_type_Insert(GATList_type list, GATList_type_Iterator where, type data);
00299 #endif
00300 
00301 /** GATList_type_Iterator GATList_type_Erase(GATList_type list, GATList_type_Iterator where)
00302  *  @brief Remove an existing element from a list.
00303  *
00304  *  The function @c GATList_type_Erase removes the existing element pointed to 
00305  *  by the iterator @c where from the given list. If during creation time of 
00306  *  the list there was specified a @c destroyfunc, this function will be called 
00307  *  for the element to be destroyed.
00308  *
00309  *  @param list The list, from which the existing element is to be removed.
00310  *  @param where The position inside the list, where the new element is to be 
00311  *        inserted.
00312  *
00313  *  @return If successful, the function returns an iterator pointing to the 
00314  *        next element adjacent to the removed element.
00315  *        If an error occures, 0 (zero) is returned.
00316  *
00317  *  @remark Calling this function with an end iterator of a list will result in 
00318  *        undefined behaviour.
00319  *  @remark The concrete function name to use is determined by the type to be
00320  *        stored inside the list. For instance, to remove an existing element 
00321  *        from a list containing @c int's the function @c GATList_int_Erase 
00322  *        would be used.
00323  */
00324 #if defined(DOXYGEN)
00325 GATList_type_Iterator
00326   GATList_type_Erase(GATList_type list, GATList_type_Iterator where);
00327 #endif
00328 
00329 /** type *GATList_type_Get(GATList_type_Iterator where)
00330  *  @brief Access the data of a stored element of a list.
00331  *
00332  *  The function @c GATList_type_Get allows to access the data stored inside an 
00333  *  element of a list. It returns a pointer to the contained data.
00334  *
00335  *  @param where The position inside the list, from which the stored data is to 
00336  *        be returned.
00337  *
00338  *  @return If successful, the function returns a pointer to the data stored 
00339  *        inside the referenced list element.
00340  *        If an error occures, 0 (zero) is returned.
00341  *
00342  *  @remark Calling this function with an end iterator of a list will result in 
00343  *        undefined behaviour.
00344  *  @remark The concrete function name to use is determined by the type to be
00345  *        stored inside the list. For instance, to access an element 
00346  *        inside a list containing @c int's the function @c GATList_int_Get 
00347  *        would be used.
00348  */
00349 #if defined(DOXYGEN)
00350 type *
00351   GATList_type_Get(GATList_type_Iterator where);
00352 #endif
00353 
00354 /** GATList_type_Iterator GATList_type_Splice(GATList_type dest, GATList_type_Iterator where, GATList_type source, GATList_type_Iterator first, GATList_type_Iterator last, size_t count)
00355  *  @brief Removes elements from the source list and inserts them into the 
00356  *        destination list.
00357  *
00358  *  The function @c GATList_type_Splice allows to remove a sequence of elements
00359  *  from an source list and inserts this sequence into a destination list. The 
00360  *  source and the destination list may refer to be the same list.
00361  *
00362  *  @param dest The destination list, where the sequence is to be inserted.
00363  *  @param where The position inside the destination list, where the sequence 
00364  *        is to be inserted.
00365  *  @param source The source list, from where the sequence is to be taken.
00366  *  @param first The starting position inside the source list of the sequence 
00367  *        to transfer.
00368  *  @param last The end position inside the source list of the sequence to
00369  *        transfer. This parameter may be 0 (zero), in which case the end of 
00370  *        the source list is assumed.
00371  *  @param count The number of elements in the sequence to transfer. This 
00372  *        parameter is an optimization aid and may be set to 0 (zero), in which 
00373  *        case the number of elements to transfer is determined.
00374  *
00375  *  @return If successful, the function returns an iterator pointing to the 
00376  *        first element beyond the newliy inserted sequence.
00377  *        If an error occures, 0 (zero) is returned.
00378  *
00379  *  @remark Using lists of different element type for the source and 
00380  *        destination lists will result in undefined behaviour.
00381  *  @remark The concrete function name to use is determined by the type to be
00382  *        stored inside the list. For instance, to splice a sequence
00383  *        from a list containing @c int's the function @c GATList_int_Splice 
00384  *        would be used.
00385  */
00386 #if defined(DOXYGEN)
00387 GATList_type_Iterator GATList_type_Splice(
00388   GATList_type dest, GATList_type_Iterator here, 
00389   GATList_type src, GATList_type_Iterator first, GATList_type_Iterator last, 
00390   size_t count);
00391 #endif
00392 
00393 /** int GATList_type_Serialise(GATList list, GATObject stream, GATBool clear_dirty)
00394 *  @brief Serialise a GATList object
00395 *
00396 *  The function GATList_Serialise serialises the given GATList object into the
00397 *  given stream. 
00398 *
00399 *  @param file The GATList object to serialise.
00400 *  @param stream The stream interface to use for the serialisation.
00401 *  @param clear_dirty If the clear_dirty parameter is set to GATTrue, the 
00402 *        internal dirty flag of this object is to be reset (no used here)
00403 *
00404 *  @return An error code.
00405 *
00406 *  @remark The concrete function name to use is determined by the type to be
00407 *        stored inside the list. For instance, to serialise
00408 *        a list containing @c int's the function @c GATList_int_Serialise 
00409 *        would be used.
00410 */
00411 #if defined(DOXYGEN)
00412 GATResult 
00413   GATList_type_Serialise(GATList list, GATObject stream, GATBool clear_dirty);
00414 #endif
00415 
00416 /** GATList GATList_type_DeSerialise(GATContext context, GATObject stream, GATBool clear_dirty)
00417 *  @brief De-serialise a GATList object
00418 *
00419 *  The function GATList_DeSerialise de-serialises a streamed GATList object  
00420 *  from the given stream  It constructs a new instance of the de-serialised 
00421 *  object.
00422 *
00423 *  @param context The GAT context to be used for object construction.
00424 *  @param stream The stream interface to use for the serialisation.
00425 *  @param result The pointer to a variable, which receives the status code of
00426 *        the operation.
00427 *
00428 *  @return The newly constructed GATList object.
00429 *
00430 *  @remark The concrete function name to use is determined by the type to be
00431 *        stored inside the list. For instance, to deserialise 
00432 *        a list containing @c int's the function @c GATList_int_DeSerialise 
00433 *        would be used.
00434 */
00435 #if defined(DOXYGEN)
00436 GATList GATList_type_DeSerialise(GATContext context, GATObject stream, 
00437   GATResult *result);
00438 #endif
00439 
00440 /** GATList_GetIsDirty
00441 *  
00442 *  The function GATList_type_GetIsDirty retrieves the status of the dirty flag of 
00443 *  this GATList object.
00444 *
00445 *  @param file The GATList object to inspect for its dirty status.
00446 *  @param isdirty The pointer to a variable, which receives the dirty status.
00447 *
00448 *  @return An error code.
00449 *
00450 *  @remark The concrete function name to use is determined by the type to be
00451 *        stored inside the list. For instance, to get the dirty status from
00452 *        a list containing @c int's the function @c GATList_int_GetIsDirty 
00453 *        would be used.
00454 */
00455 #if defined(DOXYGEN)
00456 GATResult GATList_type_GetIsDirty(GATList_const list, GATBool *isdirty);
00457 #endif
00458   
00459 #if (__STDC_VERSION__ >= 199901) || defined(__cplusplus) /* use C99 or C++ */
00460 #define GAT_INLINE_FUNC inline
00461 #else
00462 #define GAT_INLINE_FUNC static
00463 #endif /* (__STDC_VERSION__ >= 199901) || defined(__cplusplus) */
00464 
00465 /** @def GATHANDLE_DECLARE(handletype)
00466  *  @hideinitializer
00467  *
00468  *  Helper macro used internally to define the handletype of type specific 
00469  *  lists and iterators for this lists.
00470  */
00471 #define GATHANDLE_DECLARE(handletype)                                         \
00472   struct handletype ## _handle { int dummy; };                                \
00473   typedef struct handletype ## _handle *handletype;                           \
00474   typedef struct handletype ## _handle const *handletype ## _const            \
00475   /**/
00476 
00477 /* Helper macro to declare the type specific list function prototypes */
00478 #define GATLIST_PROTOTYPES(qualifier, type, listtype)                         \
00479   \
00480   GATOBJECT_DECLARE_CONVERTERS_QUALIFIED(qualifier, listtype);                \
00481   \
00482   qualifier listtype listtype ## _Create(void);                               \
00483   qualifier GATResult listtype ## _Equals(listtype ## _const lhs,             \
00484     listtype ## _const rhs, GATBool *isequal);                                \
00485   qualifier void listtype ## _Destroy(listtype *list);                        \
00486   qualifier GATType listtype ## _GetType(listtype ## _const object);          \
00487   qualifier GATResult listtype ## _Clone(listtype ## _const object,           \
00488     listtype *new_obj);                                                       \
00489   qualifier GATResult listtype ## _GetInterface(listtype ## _const file,      \
00490     GATInterface iftype, void const **ifp);                                   \
00491   \
00492   qualifier size_t listtype ## _Size(listtype ## _const list);                \
00493   qualifier listtype ## _Iterator listtype ## _Begin(listtype ## _const list); \
00494   qualifier listtype ## _Iterator listtype ## _End(listtype ## _const list);  \
00495   qualifier listtype ## _Iterator listtype ## _Next(                          \
00496     listtype ## _Iterator_const iterator);                                    \
00497   qualifier listtype ## _Iterator listtype ## _Previous(                      \
00498     listtype ## _Iterator_const iterator);                                    \
00499   qualifier listtype ## _Iterator listtype ## _Insert(                        \
00500     listtype list, listtype ## _Iterator iterator, type const data);          \
00501   qualifier listtype ## _Iterator listtype ## _Erase(                         \
00502     listtype list, listtype ## _Iterator iterator);                           \
00503   qualifier type *listtype ## _Get(                                           \
00504     listtype ## _Iterator_const iterator);                                    \
00505   \
00506   qualifier listtype ## _Iterator_const listtype ## _Splice(                  \
00507     listtype dest, listtype ## _Iterator here,                                \
00508     listtype  src, listtype ## _Iterator first,                               \
00509     listtype ## _Iterator last, size_t count);                                \
00510   \
00511   qualifier GATResult listtype ## _Serialise(listtype list,                   \
00512     GATObject stream, GATBool clear_dirty);                                   \
00513   qualifier listtype listtype ## _DeSerialise(GATContext context,             \
00514     GATObject stream, GATResult *result);                                     \
00515   qualifier GATResult listtype ## _GetIsDirty(listtype ## _const list,        \
00516     GATBool *isdirty)                                                         \
00517   /**/
00518 
00519 /* Helper macro to define the type specific list function prototypes */
00520 #define GATLIST_IMPLEMENT(qualifier, type, listtype, gattype)                 \
00521   \
00522   qualifier listtype listtype ## _Create(void)                                \
00523   {                                                                           \
00524     return (listtype) GATList_i_Create(gattype, sizeof(type));                \
00525   }                                                                           \
00526   \
00527   qualifier GATResult listtype ## _Equals(listtype ## _const lhs,             \
00528     listtype ## _const rhs, GATBool *isequal)                                 \
00529   {                                                                           \
00530     return GATList_i_Equals((GATList_const) lhs, (GATList_const) rhs,         \
00531       isequal);                                                               \
00532   }                                                                           \
00533   \
00534   qualifier void listtype ## _Destroy(listtype *list)                         \
00535   {                                                                           \
00536     GATList_i_Destroy((GATList *) list);                                      \
00537   }                                                                           \
00538   \
00539   qualifier GATType listtype ## _GetType(listtype ## _const list)             \
00540   {                                                                           \
00541     return GATList_i_GetType((GATList_const) list);                           \
00542   }                                                                           \
00543   \
00544   qualifier GATResult listtype ## _Clone(listtype ## _const list,             \
00545     listtype *new_list)                                                       \
00546   {                                                                           \
00547     return GATList_i_Clone((GATList_const) list, (GATList *)new_list);        \
00548   }                                                                           \
00549   \
00550   qualifier GATResult listtype ## _GetInterface(listtype ## _const list,      \
00551     GATInterface iftype, void const **ifp)                                    \
00552   {                                                                           \
00553     return GATList_i_GetInterface((GATList_const) list, iftype, ifp);         \
00554   }                                                                           \
00555   \
00556   qualifier size_t listtype ## _Size(listtype ## _const list)                 \
00557   {                                                                           \
00558     return GATList_i_Size((GATList_const) list);                              \
00559   }                                                                           \
00560   \
00561   qualifier listtype ## _Iterator listtype ## _Begin(listtype ## _const list) \
00562   {                                                                           \
00563     return (listtype ## _Iterator) GATList_i_Begin((GATList_const)list);      \
00564   }                                                                           \
00565   \
00566   qualifier listtype ## _Iterator listtype ## _End(listtype ## _const list)   \
00567   {                                                                           \
00568     return (listtype ## _Iterator) GATList_i_End((GATList_const) list);       \
00569   }                                                                           \
00570   \
00571   qualifier listtype ## _Iterator listtype ## _Next(                          \
00572     listtype ## _Iterator_const iterator)                                     \
00573   {                                                                           \
00574     return (listtype ## _Iterator) GATList_i_Next(                            \
00575       (GATListIterator_const) iterator);                                      \
00576   }                                                                           \
00577   \
00578   qualifier listtype ## _Iterator listtype ## _Previous(                      \
00579     listtype ## _Iterator_const iterator)                                     \
00580   {                                                                           \
00581     return (listtype ## _Iterator) GATList_i_Previous(                        \
00582       (GATListIterator_const) iterator);                                      \
00583   }                                                                           \
00584   \
00585   qualifier listtype ## _Iterator listtype ## _Insert(                        \
00586     listtype list, listtype ## _Iterator iterator, type const data)           \
00587   {                                                                           \
00588     return (listtype ## _Iterator) GATList_i_Insert((GATList)list,            \
00589       (GATListIterator) iterator, &data);                                     \
00590   }                                                                           \
00591   \
00592   qualifier listtype ## _Iterator listtype ## _Erase(                         \
00593     listtype list, listtype ## _Iterator iterator)                            \
00594   {                                                                           \
00595     return (listtype ## _Iterator) GATList_i_Erase((GATList)list,             \
00596       (GATListIterator) iterator);                                            \
00597   }                                                                           \
00598   \
00599   qualifier type *listtype ## _Get(                                           \
00600     listtype ## _Iterator_const iterator)                                     \
00601   {                                                                           \
00602     return (type *) GATList_i_Get((GATListIterator_const) iterator);          \
00603   }                                                                           \
00604   \
00605   qualifier listtype ## _Iterator_const listtype ## _Splice(                  \
00606     listtype dest, listtype ## _Iterator here,                                \
00607     listtype src, listtype ## _Iterator first,                                \
00608       listtype ## _Iterator last, size_t count)                               \
00609   {                                                                           \
00610     return (listtype ## _Iterator_const) GATList_i_Splice(                    \
00611       (GATList) dest, (GATListIterator) here,                                 \
00612       (GATList) src, (GATListIterator) first,                                 \
00613       (GATListIterator) last, count);                                         \
00614   }                                                                           \
00615   \
00616   qualifier GATResult listtype ## _Serialise(listtype list,                   \
00617     GATObject stream, GATBool clear_dirty)                                    \
00618   {                                                                           \
00619     return GATList_i_Serialise((GATList) list, stream, clear_dirty);          \
00620   }                                                                           \
00621   \
00622   qualifier listtype listtype ## _DeSerialise(GATContext context,             \
00623     GATObject stream, GATResult *result)                                      \
00624   {                                                                           \
00625     return (listtype) GATList_i_DeSerialise(context, stream, result);         \
00626   }                                                                           \
00627   \
00628   qualifier GATResult listtype ## _GetIsDirty(listtype ## _const list,        \
00629     GATBool *isdirty)                                                         \
00630   {                                                                           \
00631     return GATList_i_GetIsDirty((GATList_const) list, isdirty);               \
00632   }                                                                           \
00633   /**/
00634 
00635 /** @def GATLIST_DECLARE(type)
00636  *  Helper macros for declaring @a type specific lists on top of the 
00637  *  generic list implementation.
00638  *  You must use this macro to declare a type specific list for a given 
00639  *  @a type in every translation unit, which uses this list of @a types.
00640  *  This macro generates the access functions for the required list, which 
00641  *  follow some specific naming conventions. The list type itself is named
00642  *  @c GATList_type and the access functions are named @c GATList_type_whatever.
00643  */
00644 #define GATLIST_DECLARE_QUALIFIED(qualifier, type, name)                      \
00645   GATHANDLE_DECLARE(name);                                                    \
00646   GATHANDLE_DECLARE(name ## _Iterator);                                       \
00647   GATLIST_PROTOTYPES(qualifier, type, name)                                   \
00648   /**/
00649 
00650 #define GATLIST_DECLARE(type)                                                 \
00651   GATLIST_DECLARE_QUALIFIED(GAT_INLINE_FUNC, type, GATList_ ## type)          \
00652   /**/
00653   
00654 #define GATLIST_DECLARE_LIST(type)                                            \
00655   GATLIST_DECLARE_QUALIFIED(GAT_INLINE_FUNC, type, GATList_ ## type)          \
00656   /**/
00657   
00658 /** @def GATLIST_DECLARE(type)
00659  *  Helper macros for defining @a type specific lists on top of the 
00660  *  generic list implementation.
00661  *  You must use this macro to define a type specific list for a given 
00662  *  @a type in every translation unit, which uses this list of @a types.
00663  *  This macro generates the access functions for the required list, which 
00664  *  follow some specific naming conventions. The list type itself is named
00665  *  @c GATList_type and the access functions are named @c GATList_type_whatever.
00666  */
00667 #define GATLIST_DEFINE_QUALIFIED(qualifier, type, name, gattype)              \
00668   GATLIST_DECLARE_QUALIFIED(qualifier, type, name);                           \
00669   GATLIST_IMPLEMENT(qualifier, type, name, gattype)                           \
00670   /**/
00671 
00672 #define GATLIST_DEFINE(type)                                                  \
00673   GATLIST_DEFINE_QUALIFIED(GAT_INLINE_FUNC, type, GATList_ ## type,           \
00674     GATType_ ## type)                                                         \
00675   /**/
00676 
00677 #define GATLIST_DEFINE_LIST(type)                                             \
00678   GATLIST_DEFINE_QUALIFIED(GAT_INLINE_FUNC, type, GATList_ ## type,           \
00679     GATType_GATList)                                                          \
00680   /**/
00681 
00682 /* Versioning for the GATAdvertisable API */
00683 #define GATLIST_VERSION1      0x0100
00684 #define GATLIST_LASTVERSION   GATLIST_VERSION1
00685 #define GATLIST_MINOR_MASK    0x00ff
00686 
00687 /* 
00688  *  Special list interface for the datatype 'const char *'
00689  */
00690 GATHANDLE_DECLARE(GATList_String);
00691 GATHANDLE_DECLARE(GATList_String_Iterator);
00692 
00693 /* Versioning information for the Serializable interface */
00694 #define GATLIST_VERSION1    0x0100
00695 #define GATLIST_LASTVERSION GATLIST_VERSION1
00696 #define GATLIST_MINOR_MASK  0x00ff
00697 
00698 /* Prototypes */
00699 #if defined(__cplusplus)
00700 extern "C" {
00701 #endif /* defined(__cplusplus) */
00702 
00703 /* Declare the converters to/from GATObject */
00704 GATOBJECT_DECLARE_CONVERTERS(GATList);
00705 GATOBJECT_DECLARE_CONVERTERS(GATList_String);
00706 
00707   /* 
00708    *  Generic list interface - do not use directly! 
00709    */
00710   /* Create a new generic list */
00711   GATList 
00712     GATList_i_Create(GATType type, size_t size);
00713 
00714   /* compare two lists */
00715   GATResult
00716     GATList_i_Equals(GATList_const lhs, GATList_const rhs, GATBool *isequal);
00717   
00718   /* get the type of a list */
00719   GATType
00720     GATList_i_GetType(GATList_const list);
00721     
00722   /* make a copy of a list */
00723   GATResult
00724     GATList_i_Clone(GATList_const list, GATList *new_list);
00725 
00726   /* get an interface of this list instance */    
00727   GATResult 
00728     GATList_i_GetInterface(GATList_const file, GATInterface iftype, 
00729       void const **ifp);
00730 
00731   /* destroy a generic list */
00732   void 
00733     GATList_i_Destroy(GATList *listhandle);
00734 
00735   /* return the current list size (element count) */
00736   size_t 
00737     GATList_i_Size(GATList_const listhandle);
00738 
00739   /* 
00740    *  Generic list iterator interface - do not use directly! 
00741    */
00742   /* 
00743    *  Return the Iterator to the first and last (one past the end) elements of 
00744    *  a list, further, return the next and previous elements of a given element 
00745    */
00746   GATListIterator GATList_i_Begin(GATList_const listhandle);
00747   GATListIterator GATList_i_End(GATList_const listhandle);
00748   GATListIterator GATList_i_Next(GATListIterator_const iterator);
00749   GATListIterator GATList_i_Previous(GATListIterator_const iterator);
00750 
00751   /* Add a new element to a generic list */
00752   GATListIterator 
00753     GATList_i_Insert(GATList listhandle, GATListIterator iterator, 
00754       void const *data);
00755 
00756   /* Remove an element from a generic list */
00757   GATListIterator 
00758     GATList_i_Erase(GATList listhandle, GATListIterator iterator);
00759 
00760   /* Access the data of an element */
00761   void *
00762     GATList_i_Get(GATListIterator_const iterator);
00763 
00764   /* 
00765    *  Generic list algorithms  - do not call directly!
00766    */
00767   /* 
00768    *  Splice a given sub-list into the target list right before the given 
00769    *  position 
00770    */
00771   GATListIterator_const  
00772     GATList_i_Splice(GATList dest, GATListIterator here, 
00773       GATList src, GATListIterator first, 
00774       GATListIterator last, size_t count);
00775   
00776 /* GATAdvertiseable API */
00777 
00778   /*  Serialise a GATList object */
00779   GATResult 
00780     GATList_i_Serialise(GATList list, GATObject stream, GATBool clear_dirty);
00781 
00782   /*  De-serialise a GATList object */
00783   GATList GATList_i_DeSerialise(GATContext context, GATObject stream, 
00784     GATResult *result);
00785 
00786   /*  Retrieves the status of the dirty flag of a GATList object. */
00787   GATResult GATList_i_GetIsDirty(GATList_const list, GATBool *isdirty);
00788   
00789  /* 
00790   *  Special list interface for the datatype 'const char *'
00791   */
00792   /* Create a new list of strings */
00793   GATList_String 
00794     GATList_String_Create(void);
00795 
00796   /* return the type of a list of strings */
00797   GATType
00798     GATList_String_GetType(GATList_String_const list);
00799     
00800   /* make a copy of a slist of strings */
00801   GATResult
00802     GATList_String_Clone(GATList_String_const list, GATList_String *new_list);
00803     
00804   /* get an interface of this list instance */    
00805   GATResult 
00806     GATList_String_GetInterface(GATList_String_const list, GATInterface iftype, 
00807       void const **ifp);
00808 
00809   /* compare two lists of strings */
00810   GATResult
00811     GATList_String_Equals(GATList_String_const lhs, GATList_String_const rhs,
00812       GATBool *isequal);
00813     
00814   /* destroy a list of strings */
00815   void 
00816     GATList_String_Destroy(GATList_String *list);
00817     
00818   /* return the current list size (element count) */
00819   size_t 
00820     GATList_String_Size(GATList_String_const list);
00821     
00822   /* 
00823    *  Return the Iterator to the first and last (one past the end) elements of 
00824    *  a list, further, return the next and previous elements of a given element 
00825    */
00826   GATList_String_Iterator GATList_String_Begin(GATList_String_const list);
00827   GATList_String_Iterator GATList_String_End(GATList_String_const list);
00828   GATList_String_Iterator GATList_String_Next(
00829     GATList_String_Iterator_const iter);
00830   GATList_String_Iterator GATList_String_Previous(
00831     GATList_String_Iterator_const iter);
00832     
00833   /* Add a new string to a list of strings */
00834   GATList_String_Iterator 
00835     GATList_String_Insert(GATList_String list, 
00836       GATList_String_Iterator iterator, char const *data);
00837       
00838   /* Remove a string from a list of strings */
00839   GATList_String_Iterator 
00840     GATList_String_Erase(GATList_String list, 
00841       GATList_String_Iterator iterator);
00842       
00843   /* Access the stored string (do not free!) */
00844   char const *
00845     GATList_String_Get(GATList_String_Iterator_const iterator);
00846     
00847   /* 
00848    *  Splice a given sub-list into the target list right before the given 
00849    *  position 
00850    */
00851   GATList_String_Iterator_const 
00852     GATList_String_Splice(GATList_String dest, 
00853       GATList_String_Iterator here, GATList_String src, 
00854       GATList_String_Iterator first,
00855       GATList_String_Iterator last, size_t count);
00856 
00857 /* GATAdvertiseable API */
00858 
00859   /*  Serialise a GATList object */
00860   GATResult GATList_String_Serialise(GATList_String list, GATObject stream, 
00861     GATBool clear_dirty);
00862 
00863   /*  De-serialise a GATList object */
00864   GATList_String GATList_String_DeSerialise(GATContext context, 
00865     GATObject stream, GATResult *result);
00866 
00867   /*  Retrieves the status of the dirty flag of a GATList object.`*/
00868   GATResult 
00869     GATList_String_GetIsDirty(GATList_String_const list, GATBool *isdirty);
00870   
00871 #if defined(__cplusplus)
00872 }   /* extern "C" */
00873 #endif /* defined(__cplusplus) */
00874 
00875 #endif /* !defined(_GATLIST_H_) */