GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATObject.h

Go to the documentation of this file.
00001 /** @file GATObject.h
00002  * Header file for the GATObject class.
00003  * 
00004  *  A GATObject can represent any GAT Object.
00005  *  This file contains mostly declarations of generic implementations for the 
00006  *  different interfaces used throughout the GAT engine.
00007  *
00008  * @date Wed Sep 24 2003
00009  * 
00010  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATObject.h,v 1.25 2004/03/24 19:30:58 hartmutkaiser Exp $
00011  *
00012  *  Copyright (C) Tom Goodale
00013  *  This file is part of the GAT Engine.
00014  *  Contributed by Tom Goodale <goodale@aei.mpg.de>.
00015  *
00016  *  Use, modification and distribution is subject to the Gridlab Software
00017  *  License. (See accompanying file GLlicense.txt or copy at
00018  *  http://www.gridlab.org/GLlicense.txt)
00019  */
00020 
00021 #ifndef _GATOBJECT_H_
00022 #define _GATOBJECT_H_ 1
00023 
00024 #include "GATType.h"
00025 
00026 /* macros */
00027 
00028 /* 
00029  *  Conversion helper functions for every GAT object. The corresponding 
00030  *  *_DEFINE macros are located inside the GATInternal.h file, because these 
00031  *  are not meant for public consumtion. 
00032  *
00033  */
00034 #define GATOBJECT_DECLARE_CONVERTERS_QUALIFIED_EX(qualifier, type, base)      \
00035   qualifier type base ## _To ## type(base object);                            \
00036   qualifier base type ## _To ## base(type derived);                           \
00037   qualifier type ## _const base ## _To ## type ## _const(                     \
00038     base ## _const object);                                                   \
00039   qualifier base ## _const type ## _To ## base ## _const(                     \
00040     type ## _const derived)                                                   \
00041   /**/
00042 
00043 #define GATOBJECT_DECLARE_CONVERTERS_QUALIFIED(qualifier, type)               \
00044     GATOBJECT_DECLARE_CONVERTERS_QUALIFIED_EX(qualifier, type, GATObject)     \
00045     /**/
00046     
00047 #define GATOBJECT_DECLARE_CONVERTERS(type)                                    \
00048   GATOBJECT_DECLARE_CONVERTERS_QUALIFIED(extern, type)                        \
00049   /**/
00050 
00051 /* Conversion helper functions for every GAT object */
00052 #define GATOBJECT_DEFINE_CONVERTERS_QUALIFIED_EX(                             \
00053     qualifier, type, gattype, base)                                           \
00054   \
00055   qualifier type base ## _To ## type(base object)                             \
00056   {                                                                           \
00057     return (gattype == GATObject_GetType(base ## _ToGATObject(object))) ?     \
00058       (type)object : 0;                                                       \
00059   }                                                                           \
00060   \
00061   qualifier base type ## _To ## base(type derived)                            \
00062   {                                                                           \
00063     return (base) derived;                                                    \
00064   }                                                                           \
00065   \
00066   qualifier type ## _const base ## _To ## type ## _const(                     \
00067     base ## _const object)                                                    \
00068   {                                                                           \
00069     return (gattype == GATObject_GetType(base ## _ToGATObject_const(object))) ? \
00070       (type ## _const) object : 0;                                            \
00071   }                                                                           \
00072   \
00073   qualifier base ## _const type ## _To ## base ## _const(                     \
00074     type ## _const derived)                                                   \
00075   {                                                                           \
00076     return (base ## _const) derived;                                          \
00077   }                                                                           \
00078   /**/
00079 
00080 #define GATOBJECT_DEFINE_CONVERTERS_QUALIFIED(qualifier, type, gattype)       \
00081   GATOBJECT_DEFINE_CONVERTERS_QUALIFIED_EX(                                   \
00082     qualifier, type, gattype, GATObject)                                      \
00083   /**/
00084   
00085 #define GATOBJECT_DEFINE_CONVERTERS(type)                                     \
00086   GATOBJECT_DEFINE_CONVERTERS_QUALIFIED(extern, type, GATType_ ## type)       \
00087   /**/
00088   
00089 #ifdef __cplusplus
00090 extern "C" {
00091 #endif
00092 
00093 /* genericity support for all GAT objects */
00094 
00095 /** GATType GATObject_GetType(GATObject const object)
00096  *  @brief Get the type from a GATObject
00097  *
00098  *  The function GATObject_GetType implements a generic way to return the 
00099  *  actual type of a given GATObject.
00100  *
00101  *  @param object The GATObject, for which its type has to be returned
00102  *
00103  *  @return The @c #GATType of the object under inspection
00104  */
00105 GATType GATObject_GetType(GATObject_const object);
00106 
00107 /** void GATObject_Destroy(GATObject *object)
00108  *  @brief Destroy a GATObject
00109  *
00110  *  The function GATObject_Destroy implements a generic way to destroy an
00111  *  arbitrary GATObject.
00112  *
00113  *  @param object The GATObject, which has to be destroyed.
00114  */
00115 void GATObject_Destroy(GATObject *object);
00116 
00117 /** int GATObject_Equals(GATObject const lhs, GATObject const rhs, GATBool *isequal)
00118  *  @brief Compare to GATObject's
00119  *
00120  *  The function GATObject_Equals allows to compare generically two arbitrary 
00121  *  GATObject's.
00122  *
00123  *  @param lhs The first GATObject to compare.
00124  *  @param rhs The second GATObject to compare.
00125  *  @param isequal The pointer, through which the result is to be returned.
00126  *
00127  *  @result An error code.
00128  */
00129 GATResult GATObject_Equals(GATObject_const lhs, GATObject_const rhs, 
00130   GATBool *isequal);
00131 
00132 /** int GATObject_Clone(GATObject const object, GATObject *new_object)
00133  *  @brief Clone a GATObject
00134  *
00135  *  The function GATObject_Clone allows to get a exact copy of an arbitrary
00136  *  GATObject. If the object to copy is a container object (i.e. GATTable, 
00137  *  GATList or similar), all the contained therein elements are copied too.
00138  *
00139  *  @param object The object to be copied.
00140  *  @param new_object The pointer, through which the result is to be returned.
00141  *
00142  *  @return An error type.
00143  */
00144 GATResult GATObject_Clone(GATObject_const object, GATObject *result);
00145 
00146 /** int GATObject_GetInterface(GATObject_const object, GATInterface iftype, void const **ifp)
00147  *  @brief Get an interface supported by a GATObject
00148  *
00149  *  The function GATObject_GetInterface allows to get a pointer to an 
00150  *  additional interface supported by this GATObject.
00151  *
00152  *  @param object The object to be asked for the new interface.
00153  *  @param iftype The interface the object is to be asked for.
00154  *  @param ifp The pointer, through which the result is to be returned.
00155  *
00156  *  @return An error type.
00157  */
00158 GATResult GATObject_GetInterface(GATObject_const object, GATInterface iftype, 
00159   void const **ifp);
00160 
00161 GATResult GATObject_GetCPIInstanceData(GATObject object, void **data);
00162 
00163 /* Helper functions needed for proper generic type conversion */
00164 GATObject GATObject_ToGATObject(GATObject object);
00165 GATObject_const GATObject_ToGATObject_const(GATObject_const object);
00166 
00167 /* generic serialisation support for GATObject's */
00168 GATResult 
00169   GATSerialisable_Serialise(GATObject object, GATObject stream, 
00170     GATBool clear_dirty);
00171 GATObject 
00172   GATSerialisable_DeSerialise(GATContext context, GATObject stream, GATResult *result);
00173 GATResult
00174   GATSerialisable_GetIsDirty(GATObject_const object, GATBool *isdirty);
00175   
00176 /* generic streaming support for GATObject's */
00177 GATResult 
00178   GATStreamable_Read(GATObject object, void *buffer, 
00179     GATuint32 size, GATuint32 *read_bytes);
00180 GATResult
00181   GATStreamable_Write(GATObject object, void const *buffer, 
00182     GATuint32 size, GATuint32 *written_bytes);
00183 GATResult 
00184   GATStreamable_Seek(GATObject object, GATOrigin origin, GATint32 offset, 
00185     GATuint32 *new_position);
00186 
00187 /* generic GATMonitorable interface */
00188 GATResult 
00189   GATMonitorable_AddMetricListener(GATObject object, 
00190     GATMetricListener listener, void *listener_data, GATMetric metric, 
00191     GATuint32 *cookie);
00192 
00193 GATResult 
00194   GATMonitorable_RegisterPolling(GATObject object,
00195     GATMetric metric, GATMetricEvent *event, GATuint32 *cookie);
00196 
00197 GATResult 
00198   GATMonitorable_RemoveRegisteredMetric(GATObject object, 
00199     GATMetric metric, GATuint32 cookie);
00200 
00201 struct GATList_GATMetric_handle;   /* forward declaration only */
00202 GATResult 
00203   GATMonitorable_GetMetrics(GATObject_const object, 
00204     struct GATList_GATMetric_handle **metrics);
00205 
00206 /* generic GATResource access support */
00207 GATResult
00208   GATResource_GetResourceDescription(GATObject_const object,
00209     GATResourceDescription_const *description);
00210 
00211 GATResult
00212   GATResource_GetReservation(GATObject_const object,  
00213     GATReservation_const *reservation);
00214   
00215 /* Serialize primitive data items */
00216 GATResult
00217   GATuint32_Serialise(GATuint32 data, GATObject stream);
00218 GATResult
00219   GATuint32_DeSerialise(GATObject stream, GATuint32 *data);
00220 
00221 #ifdef __cplusplus
00222 }
00223 #endif
00224 
00225 #endif /* _GATOBJECT_H_ */