GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATInternal.h

Go to the documentation of this file.
00001 /** @file GATInternal.h
00002  * Global header file for global GAT internals
00003  *
00004  * @date Fri Oct 10 2003
00005  *
00006  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATInternal.h,v 1.39 2004/04/20 12:33:22 hartmutkaiser Exp $
00007  *
00008  *  Copyright (C) Hartmut Kaiser
00009  *  This file is part of the GAT Engine.
00010  *  Contributed by Hartmut Kaiser <hartmutkaiser [at] t-online [dot] de>.
00011  *
00012  *  Use, modification and distribution is subject to the Gridlab Software
00013  *  License. (See accompanying file GLlicense.txt or copy at
00014  *  http://www.gridlab.org/GLlicense.txt)
00015  */
00016  
00017 #if !defined(_GATINTERNAL_H_)
00018 #define _GATINTERNAL_H_
00019 
00020 #include "GATObject.h"
00021 #include "GATInterfaceMap.h"
00022 #include "GATMonitorable.h"
00023 
00024 /* GATSelfCPI handle */
00025 typedef struct GATSelfCPI_S *GATSelfCPI;
00026 typedef struct GATSelfCPI_S const *GATSelfCPI_const;
00027 
00028 /* global internal macros */
00029 
00030 /* The vtable definition for the GATObject interface */
00031 #define GATOBJECT_DEFINE_VTABLE(type)                                         \
00032   typedef GATType (* type ## _GetTypeProc)(type ## _const);                   \
00033   typedef void (* type ## _DestroyProc)(type *);                              \
00034   typedef GATResult (* type ## _EqualsProc)(type ## _const, type ## _const,   \
00035     GATBool *);                                                               \
00036   typedef GATResult (* type ## _CloneProc)(type ## _const, type *);           \
00037   typedef GATResult (* type ## _GetInterfaceProc)(type ## _const,             \
00038     GATInterface, void const **);                                             \
00039   typedef GATResult (* type ## _GetCPIInstanceDataProc)(type, void **data);   \
00040   \
00041   typedef struct type ## _vtable_S {                                          \
00042     type ## _GetTypeProc get_type;                                            \
00043     type ## _DestroyProc destroy;                                             \
00044     type ## _EqualsProc equals;                                               \
00045     type ## _CloneProc clone;                                                 \
00046     type ## _GetInterfaceProc get_interface;                                  \
00047     type ## _GetCPIInstanceDataProc get_instancedata;                         \
00048   } type ## _vtable                                                           \
00049   /**/
00050 
00051 /* The vtable definition for the ISerialisable/IAdvertisable interfaces */
00052 #define GATSERIALISABLE_DEFINE_VTABLE(type)                                   \
00053   typedef GATResult (* type ## _SerialiseProc)(type, GATObject, GATBool);     \
00054   typedef type (* type ## _DeSerialiseProc)(GATContext, GATObject, GATResult *); \
00055   typedef GATResult (* type ## _GetIsDirtyProc)(type ## _const, GATBool *);   \
00056   \
00057   typedef struct type ## _ISerialisable_vtable_S {                            \
00058     type ## _SerialiseProc serialise;                                         \
00059     type ## _DeSerialiseProc deserialise;                                     \
00060     type ## _GetIsDirtyProc isdirty;                                          \
00061   } type ## _ISerialisable_vtable                                             \
00062   /**/
00063 
00064 /* The vtable definition for the IStreamable interface */
00065 #define GATSTREAMABLE_DEFINE_VTABLE(type)                                     \
00066   typedef GATResult (* type ## _ReadProc)(type, void *, GATuint32,            \
00067     GATuint32 *);                                                             \
00068   typedef GATResult (* type ## _WriteProc)(type, void const *, GATuint32,     \
00069     GATuint32 *);                                                             \
00070   typedef GATResult (* type ## _SeekProc)(type, GATOrigin, GATint32,          \
00071     GATuint32 *);                                                             \
00072   typedef GATResult (* type ## _CloseProc)(type);                             \
00073   \
00074   typedef struct type ## _IStreamable_vtable_S {                              \
00075     type ## _ReadProc sread;                                                  \
00076     type ## _WriteProc swrite;                                                \
00077     type ## _SeekProc seek;                                                   \
00078     type ## _CloseProc closestream;                                           \
00079   } type ## _IStreamable_vtable                                               \
00080   /**/
00081 
00082 /* The vtable definition for the IAsyncStreamable interface (this is derived 
00083    from IStreamable) */
00084 #define GATASYNCSTREAMABLE_DEFINE_VTABLE(type)                                \
00085   typedef GATResult (* type ## _ReadProcA)(type, void *, GATuint32,           \
00086     GATuint32 *);                                                             \
00087   typedef GATResult (* type ## _WriteProcA)(type, void const *, GATuint32,    \
00088     GATuint32 *);                                                             \
00089   typedef GATResult (* type ## _SeekProcA)(type, GATOrigin, GATint32,         \
00090     GATuint32 *);                                                             \
00091   typedef GATResult (* type ## _CloseProcA)(type);                            \
00092   typedef GATResult (* type ## _IReadProcA)(type, void *, GATuint32);         \
00093   typedef GATResult (* type ## _ReadFinishProcA)(type, GATBool *,             \
00094     GATuint32 *);                                                             \
00095   typedef GATResult (* type ## _ReadTestProcA)(type, GATBool *);              \
00096   typedef GATResult (* type ## _IWriteProcA)(type, void const *, GATuint32);  \
00097   typedef GATResult (* type ## _WriteFinishProcA)(type, GATuint32 *);         \
00098   typedef GATResult (* type ## _WriteTestProcA)(type, GATuint32 *);           \
00099   \
00100   typedef struct type ## _IAsyncStreamable_vtable_S {                         \
00101     type ## _ReadProcA sread;                                                 \
00102     type ## _WriteProcA swrite;                                               \
00103     type ## _SeekProcA seek;                                                  \
00104     type ## _CloseProcA closestream;                                          \
00105     type ## _IReadProcA iread;                                                \
00106     type ## _ReadFinishProcA read_finish;                                     \
00107     type ## _ReadTestProcA read_test;                                         \
00108     type ## _IWriteProcA iwrite;                                              \
00109     type ## _WriteFinishProcA write_finish;                                   \
00110     type ## _WriteTestProcA write_test;                                       \
00111   } type ## _IAsyncStreamable_vtable                                          \
00112   /**/
00113 
00114 /* The vtable definition for the IMonitorable interface */
00115 #define GATMONITORABLE_DEFINE_VTABLE(type)                                    \
00116   typedef GATResult (* type ## AddMetricListenerProc)(type, GATMetricListener,\
00117     void *, GATMetric, GATuint32 *);                                          \
00118   typedef GATResult (* type ## RegisterPollingProc)(type, GATMetric,          \
00119     GATMetricEvent *, GATuint32 *);                                           \
00120   typedef GATResult (* type ## RemoveRegisteredMetricProc)(type, GATMetric,   \
00121     GATuint32);                                                               \
00122   typedef GATResult (* type ## GetMetricsProc)(type ## _const,                \
00123     GATList_GATMetric *);                                                     \
00124   \
00125   typedef struct type ## _IMonitorable_vtable_S {                             \
00126     type ## AddMetricListenerProc addlistener;                                \
00127     type ## RegisterPollingProc registerpolling;                              \
00128     type ## RemoveRegisteredMetricProc removemetric;                          \
00129     type ## GetMetricsProc getmetrics;                                        \
00130   } type ## _IMonitorable_vtable                                              \
00131   /**/
00132 
00133 /* The vtable definition for the IResource interface */
00134 #define GATRESOURCE_DEFINE_VTABLE(type)                                       \
00135   typedef GATResult (* type ## GetResourceDescription)(type ## _const,        \
00136     GATResourceDescription_const *);                                          \
00137   typedef GATResult (* type ## GetReservation)(type ## _const,                \
00138     GATReservation_const *);                                                  \
00139   \
00140   typedef struct type ## _IResource_vtable_S {                                \
00141     type ## GetResourceDescription getresourcedescription;                    \
00142     type ## GetReservation getreservation;                                    \
00143   } type ## _IResource_vtable;                                                \
00144   /**/
00145   
00146 /* helper macros */
00147 /* FIXME: find a way to 'use' an unused parameter, such that no additional code 
00148    is generated and which makes gcc happy (silent) */
00149 #define GAT_UNUSED_PARAMETER(x) { if (x && !x) {int a = 1; a++; }}
00150 
00151 /* global internal structures */
00152 
00153 
00154 /* 
00155  * Class API functions, which should not be exposed to the user of the GAT 
00156  * engine but which are used internally, so that these must not be static.
00157  */
00158  
00159 /* GATMetric */
00160 
00161 /** GATMetric_i_GetTypeSize
00162  *
00163  *  @return The size of the internal representation of the GATMetric type.
00164  *
00165  *  @remark This is an internal function, do not use it directly.
00166  */
00167 GATuint32 GATMetric_i_GetTypeSize(void);
00168 
00169 /** GATMetric_GetMeasurementType
00170  *
00171  *  The functions GATMetric_GetMeasurementType returns the measurment type of
00172  *  the value associated with the given metric.
00173  *
00174  *  @param metric The metric to ask for its values measurement type.
00175  *
00176  *  @remark This is an internal function, do not use it directly.
00177  *
00178  *  @return The requested measurement type.
00179  */
00180 GATMeasurementType GATMetric_GetMeasurementType(GATMetric_const metric);
00181 
00182 /* GATMetricEvent */
00183 
00184 typedef GATResult (* GATMetricEvent_GetValueProc)(void *, GATType, void *, 
00185   GATuint32);
00186 
00187 /* Registry Helper functions, for internal use only */
00188 GATResult
00189   GATRegistry_internal_AddGATSelfToCPIList(GATRegistry registry, 
00190     GATSelfCPI cpi, GATSelf object);
00191 
00192 GATResult
00193   GATRegistry_internal_RemoveGATSelfFromCPIList(GATRegistry registry, 
00194     GATSelfCPI cpi, GATSelf object);
00195 
00196 
00197 /* GATContext related helper functions */
00198 
00199 /** GATContext_internal_GetSelf
00200  *  Gets the GATSelf object.
00201  *  This is the method used by the GATSelf code to get the GATSelf
00202  *  object from a context
00203  *  
00204  * @param context The GATContext which is used to find the GATSelf object.
00205  *
00206  * @return The GATSelf object
00207  */
00208 GATSelf 
00209   GATContext_internal_GetSelf(GATContext self);
00210 
00211 /** GATContext_internal_GetRegistry
00212  *  Gets the GATRegsitry object.
00213  *  This is the method used by GAT object code to get the registry
00214  *  object from a context
00215  *  
00216  * @param context The GATContext which is used to find the GATRegistry object.
00217  *
00218  * @return A GATRegistry object
00219  */
00220 GATRegistry 
00221   GATContext_internal_GetRegistry(GATContext self);
00222 
00223 
00224 /* GATSelf related helper functions */
00225 GATResult
00226   GATSelf_internal_GetGATJobId(GATSelf_const self, GATContext context, 
00227     GATString_const *gatjobid);
00228   
00229 GATResult
00230   GATSelf_internal_CreateGATJobId(GATSelf_const self, GATContext context, 
00231     GATString *gatjobid);
00232 
00233 GATSelf 
00234   GATSelf_internal_GetInstance(GATContext error_context);
00235 
00236 GATRegistry 
00237   GATSelf_internal_GetRegistry(GATSelf self);
00238 
00239 GATResult 
00240   GATSelf_internal_AddContext(GATSelf self, GATContext context);
00241 
00242 void 
00243   GATSelf_internal_RemoveContext(GATSelf self, GATContext context);
00244 
00245 
00246 /** GATJob_internal_SetGATJobId
00247  *  
00248  *  The function GATJob_internal_SetGatJobId is used by the engine to set the
00249  *  GAT job id associated with this job object.
00250  *
00251  *  @param job The job object for which is GAT job id is to be set.
00252  *  @param gatjobid The new GAT job id.
00253  *
00254  *  @remark This is an internal function, do not use it directly.
00255  *
00256  *  @return An error code.
00257  */
00258 GATResult
00259   GATJob_internal_SetGATJobId(GATJob job, GATString_const gatjobid);
00260 
00261 
00262 /** GATJobDescription_internal_GetEnvironment
00263  *  
00264  *  The function GATJobDescription_internal_GetEnvironment gets a reference to
00265  *  the table, which stores the environment variables for the job described.
00266  *
00267  *  @param jd The job description to query for the environemnt table.
00268  *  @param env The variable receiving the resulting Table reference.
00269  *
00270  *  @remark This is an internal function, do not use it directly.
00271  *
00272  *  @return An error code.
00273  */   
00274 GATResult
00275   GATJobDescription_internal_GetEnvironment(GATJobDescription jd, 
00276     GATTable *env);
00277 
00278 
00279 /** GATTable_internal_Get_GATObjectRef
00280  *  
00281  *  The functions GATTable_internal_Get_GATObjectRef allows to access a 
00282  *  GATObject stored inside a GATTable without copying it.
00283  *
00284  *  @param table The hash table get the data from.
00285  *  @param key The key value to associate the data to.
00286  *  @param data The recovered reference to the GATObject data
00287  *
00288  *  @remark This is an internal function, do not use it directly.
00289  *
00290  *  @return An error code.
00291  */
00292 GATResult 
00293   GATTable_internal_Get_GATObjectRef(GATTable_const table, const void *key, 
00294     GATObject *object);
00295 
00296 
00297 /** GATSoftwareDescription_internal_GetAttributesRef
00298  *  @brief Access the stored set of attributes 
00299  *
00300  *  The function @c GATSoftwareDescription_getAttributes allows to access the
00301  *  attributes stored insoide the given GATSoftwareDescription instance.
00302  *
00303  *  @param object The software description to query for its attributes table.
00304  *  @param attr The pointer to a variable, which receives the reslting 
00305  *        attributes table.
00306  *
00307  *  @return An error code.
00308  */
00309 GATResult
00310   GATSoftwareDescription_internal_GetAttributesRef(
00311     GATSoftwareDescription_const object, GATTable *attr);
00312 
00313 
00314 #endif /* !defined(_GATINTERNAL_H_) */