GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATRegistry.h

Go to the documentation of this file.
00001 /** @file GATRegistry.h
00002  * Header file for the GATRegistry class.
00003  * 
00004  * The Registry keeps track of all capabilities and their providers.
00005  * 
00006  * @date Thu Sep 18 2003
00007  * 
00008  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATRegistry.h,v 1.21 2004/04/18 18:35:10 hartmutkaiser Exp $
00009  *
00010  *  Copyright (C) Tom Goodale
00011  *  This file is part of the GAT Engine.
00012  *  Contributed by Tom Goodale <goodale@aei.mpg.de>.
00013  *
00014  *  Use, modification and distribution is subject to the Gridlab Software
00015  *  License. (See accompanying file GLlicense.txt or copy at
00016  *  http://www.gridlab.org/GLlicense.txt)
00017  */
00018 
00019 #ifndef _GATREGISTRY_H_
00020 #define _GATREGISTRY_H_ 1
00021 
00022 #include "GATPreferences.h"
00023 
00024 /* typedef's */
00025 typedef struct CPIRegistryList_S *CPIRegistryList;
00026 typedef struct CPIRegistryList_S const *CPIRegistryList_const;
00027 
00028 typedef GATResult (*GATCPICallback)(CPIRegistryList_const, void *);
00029 
00030 /* Define a macro so it is easy to add more CPI types.
00031  * Macro takes one argument, which is the base name of the CPI,
00032  * i.e. no GAT prefix.
00033  *
00034  * Defines four functions which need to be implemented in GATRegistry.c,
00035  * schematically
00036  * int GATRegistry_Add<type>(arguments)
00037  * List<type> = GATRegistry_Find<type>(preferences)
00038  * List<type>_Destroy(List<type>)
00039  * List<type> = GATRegistry_CloneList<type>(list<type>)
00040  *
00041  * where List<type> is a single-linked list with a next member to the next
00042  * one in the list, and a cpi member which contains the current object
00043  */
00044 
00045 #define CPI(object)                                                           \
00046   int GATRegistry_AddGAT ## object ## CPI(GATRegistry registry,               \
00047                                        GAT ## object ## CPI cpi,              \
00048                                        void *token,                           \
00049                                        GATPreferences_const preferences);     \
00050   \
00051   struct GAT ## object ## CPIList_S                                           \
00052   {                                                                           \
00053     struct GAT ## object ## CPIList_S *next;                                  \
00054     GAT ## object ## CPI cpi;                                                 \
00055   };                                                                          \
00056   \
00057   typedef struct GAT ## object ## CPIList_S *GAT ## object ## CPIList;        \
00058   typedef struct GAT ## object ## CPIList_S const *                           \
00059     GAT ## object ## CPIList_const;                                           \
00060   \
00061   GAT ## object ## CPIList GATRegistry_FindGAT ## object ## CPI(              \
00062     GATRegistry_const reg, GATPreferences_const preferences);                 \
00063   \
00064   void GAT ## object ## CPIList_Destroy(GAT ## object ## CPIList list);       \
00065   \
00066   GAT ## object ## CPIList GATRegistry_CloneGAT ## object ## CPIList(         \
00067     GAT ## object ## CPIList_const list);                                     \
00068   \
00069   typedef GATResult (*GAT ## object ## CPICallback)(GAT ## object ## CPI,     \
00070     void *);                                                                  \
00071   \
00072   GATResult GATRegistry_WalkGAT ## object ## CPIList(GATRegistry_const registry,\
00073     GATCPICallback, void *data);                                              \
00074   \
00075   GATResult GATRegistry_AddGAT ## object ## ToCPIList(GATContext ctx,         \
00076     GAT ## object ## CPI cpi, GAT ## object obj);                             \
00077   \
00078   GATResult GATRegistry_RemoveGAT ## object ## FromCPIList(                   \
00079     GATContext ctx, GAT ## object ## CPI cpi,                                 \
00080     GAT ## object obj)                                                        \
00081   /**/
00082 
00083 /* Now include all CPI header files */
00084 #include "GATFileStreamCPI.h"
00085 #include "GATPipeCPI.h"
00086 #include "GATEndpointCPI.h"
00087 #include "GATFileCPI.h"
00088 #include "GATLogicalFileCPI.h"
00089 #include "GATResourceBrokerCPI.h"
00090 #include "GATReservationCPI.h"
00091 #include "GATResourceCPI.h"
00092 #include "GATJobCPI.h"
00093 #include "GATSelfCPI.h"
00094 #include "GATRequestCPI.h"
00095 #include "GATAdvertServiceCPI.h"
00096 
00097 #ifdef __cplusplus
00098 extern "C" {
00099 #endif
00100 
00101 /* generic registry API */
00102 GATRegistry GATRegistry_Create(void);
00103 
00104 void GATRegistry_Destroy(GATRegistry *registry);
00105 
00106 int GATRegistry_RemoveByToken(GATRegistry registry, void *token);
00107 
00108 /*  GATRegistry_internal_ServiceAction
00109  *
00110  *  The ServiceActions call is used to allow the GAT Engine to service 
00111  *  asynchronous actions, such as GATRequests and GATMetricEvents. In a 
00112  *  single-threaded application it is likely that a timeout would be supplied, 
00113  *  in a multi-threaded application one thread may be used for the GAT by using 
00114  *  this call and no timeout. 
00115  *
00116  *  @param timeout This may be a 0 timeout to indicate no timeout at all, or
00117  *        a specific time length.
00118  *
00119  *  @return An error code.
00120  */
00121 GATResult
00122   GATRegistry_internal_ServiceActions(GATRegistry_const registry, 
00123     GATContext context, GATTimePeriod_const timeout);
00124 
00125 /* declare the concrete CPI API functions */
00126 CPI(FileStream);
00127 CPI(Pipe);
00128 CPI(Endpoint);
00129 CPI(File);
00130 CPI(LogicalFile);
00131 CPI(ResourceBroker);
00132 CPI(Reservation);
00133 CPI(Resource);
00134 CPI(Job);
00135 CPI(Self);
00136 CPI(Request);
00137 CPI(AdvertService);
00138 
00139 #ifdef __cplusplus
00140 }
00141 #endif
00142 
00143 /* Undefine macro to alleviate namespace conflicts */
00144 #undef CPI
00145 
00146 #endif /* _GATREGISTRY_H_ */