GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATResourceCPI.h

Go to the documentation of this file.
00001 /** @file GATResourceCPI.h
00002  *  Header file for the GATResourceCPI class.
00003  *
00004  *  @date Sat Oct 25 2003
00005  *
00006  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATResourceCPI.h,v 1.11 2004/03/24 19:30:58 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(_GATRESOURCECPI_H_)
00018 #define _GATRESOURCECPI_H_
00019 
00020 typedef struct GATResourceCPI_S *GATResourceCPI;
00021 
00022 #include "GATContext.h"
00023 #include "GATPreferences.h"
00024 #include "GATMonitorable.h"
00025 
00026 /* Versioning constants for the GATResourceCPI_Data struct */
00027 #define GATRESOURCECPI_VERSION1 1 
00028 
00029 /* the newest version we know of */
00030 #define GATRESOURCECPI_VERSION  GATRESOURCECPI_VERSION1
00031 
00032 /**
00033  *  The @c #GATResourceCPI_Instance structure holds all data items supplied 
00034  *  by the client during the construction of the corresponding GAT object.
00035  */
00036 typedef struct 
00037 {
00038   GATContext context;   /* the GAT context to use for all GATFile operations */
00039   GATType type;           /* the actual type of this object */
00040   GATBool isdirty;        /* dirty status for the whole object */
00041   GATMonitorable_Impl monitorable;  /* monitoring support */
00042   GATObject_const source; /* the object this CPI is associated with */
00043   void *instance_data;    /* eventually supplied CPI provider instance data */
00044 } GATResourceCPI_Instance;
00045 
00046 
00047 /* prototypes for the adapter callback functions */
00048 typedef void (*GATResourceCPI_Adaptor_Destroy)(void *);
00049 
00050 typedef GATResult (*GATResourceCPI_Adaptor_ServiceActions)(void *, 
00051   GATResourceCPI_Instance *, GATTimePeriod_const);
00052 
00053 /* instance specific functions */
00054 typedef void (*GATResourceCPI_Adaptor_DestroyInstance)(void *, 
00055   GATResourceCPI_Instance *);
00056 
00057 typedef GATResult (*GATResourceCPI_Adaptor_CreateInstance)(void *, 
00058   GATResourceCPI_Instance *, void *);
00059 
00060 typedef GATResult (*GATResourceCPI_Adaptor_CloneInstance)(void *, 
00061   GATResourceCPI_Instance const *, GATResourceCPI_Instance *);
00062 
00063 typedef GATResult (*GATResourceCPI_Adaptor_EqualsInstance)(void *, 
00064   GATResourceCPI_Instance const *, GATResourceCPI_Instance const *, 
00065   GATBool *);
00066 
00067 
00068 /* CPI specific API */
00069 typedef GATResult (* GATResourceCPI_Adaptor_GetResourceDescription)(void *,
00070   GATResourceCPI_Instance const *, GATResourceDescription_const *);
00071 
00072 typedef GATResult (* GATResourceCPI_Adaptor_GetReservation)(void *,
00073   GATResourceCPI_Instance const *, GATReservation_const *);
00074 
00075 
00076 /* callback function prototypes for the GATMonitorable interface support */
00077 typedef GATResult (* GATResourceCPI_Adaptor_GetMetrics)(void *, 
00078   GATResourceCPI_Instance const *, GATList_GATMetric *);
00079 
00080 typedef GATResult (* GATResourceCPI_Adaptor_GetMetricEvent)(void *, 
00081   GATResourceCPI_Instance const *, GATMetric, GATMetricEvent *); 
00082 
00083 
00084 /* Serialisation API */
00085 typedef GATResult (*GATResourceCPI_Adaptor_Serialise)(void *, 
00086   GATResourceCPI_Instance const *, GATObject, GATBool);
00087 
00088 typedef GATResult (*GATResourceCPI_Adaptor_DeSerialise)(void *, GATObject,
00089   GATResourceCPI_Instance *);
00090 
00091 
00092 /* CPI data passed from the adaptor while registering the CPI */
00093 typedef struct
00094 {
00095   /* CPI data (adaptor instance data) */
00096   void *data;
00097   GATResourceCPI_Adaptor_Destroy destroy;
00098   GATResourceCPI_Adaptor_ServiceActions service_actions;
00099   
00100   /* CPI instance data */
00101   GATResourceCPI_Adaptor_CreateInstance create_instance;
00102   GATResourceCPI_Adaptor_DestroyInstance destroy_instance;
00103   GATResourceCPI_Adaptor_CloneInstance clone_instance;
00104   GATResourceCPI_Adaptor_EqualsInstance equals_instance;
00105 
00106   /* CPI functionality */
00107   GATResourceCPI_Adaptor_GetResourceDescription get_resource_description;
00108   GATResourceCPI_Adaptor_GetReservation get_reservation;
00109   
00110   /* CPI monitoring support */
00111   GATResourceCPI_Adaptor_GetMetrics get_metrics;
00112   GATResourceCPI_Adaptor_GetMetricEvent get_metric_event;
00113 
00114   /* CPI serialisation */
00115   GATResourceCPI_Adaptor_Serialise serialise;
00116   GATResourceCPI_Adaptor_DeSerialise deserialise;
00117 } GATResourceCPI_Data;
00118 
00119 #ifdef __cplusplus
00120 extern "C" {
00121 #endif
00122 
00123 /* Adaptor API */
00124 
00125 /** GATResourceCPI_Create
00126  *  The  GATResourceCPI constructor.
00127  *  new_cpi is the constructor for GATResourceCPI objects.
00128  *  
00129  *  @param version Version of the GATResourceCPI_Data structure
00130  *  @param data Pointer to adaptor CPI instance data structure.
00131  *
00132  * @return A new GATResourceCPI
00133  */
00134 GATResourceCPI GATResourceCPI_Create(unsigned long int version,
00135   GATResourceCPI_Data *data);
00136 
00137 
00138 /* API internal to the GAT engine */
00139 
00140 /** GATResourceCPI_Destroy
00141  *  @brief The GATResourceCPI destructor.
00142  *
00143  *  This is the destructor for GATResourceCPI objects.
00144  *
00145  *  @param this An old GATResourceCPI
00146  */
00147 void GATResourceCPI_Destroy(GATResourceCPI *cpi);
00148 
00149 /* CPI instance specific functions */
00150 
00151 /** GATResourceCPI_CreateInstance
00152  *  @brief Create a new CPI object instance
00153  *
00154  *  Calls the adaptor to create a new CPI object instance.
00155  *
00156  *  @param this The CPI object.
00157  *  @param instance_data The instance data of the attached CPI object
00158  *  @param initialisation_data Additional data provided by the adaptor while 
00159  *        creating this new instance.
00160  *
00161  *  @return An error code.
00162  */
00163 GATResult GATResourceCPI_CreateInstance(GATResourceCPI cpi, 
00164   GATResourceCPI_Instance *instance_data, void *initialisation_data);
00165   
00166 /** GATResourceCPI_DestroyInstance
00167  *  @brief Create a new CPI object instance
00168  *
00169  *  Calls the adaptor to destroy a CPI object instance.
00170  *
00171  *  @param this The CPI object.
00172  *  @param instance_data The instance data of the attached CPI object
00173  */
00174 void GATResourceCPI_DestroyInstance(GATResourceCPI cpi, 
00175   GATResourceCPI_Instance *instance_data);
00176 
00177 /** GATResourceCPI_CloneInstance
00178  *  @brief Clones a CPI object instance.
00179  *
00180  *  Calls the adaptor to clone a CPI object instance.
00181  *
00182  *  @param this The CPI object.
00183  *  @param instance_data The instance data of the CPI object to clone.
00184  *  @param new_instance_data The new instance data is to be returned here.
00185  *
00186  *  @return An error code.
00187  */
00188 GATResult GATResourceCPI_CloneInstance(GATResourceCPI cpi, 
00189   GATResourceCPI_Instance const *instance_data,
00190   GATResourceCPI_Instance *new_instance_data);
00191 
00192 /** GATResourceCPI_EqualsInstance
00193  *  @brief Compares two CPI object instances.
00194  *
00195  *  Calls the adaptor to compare two CPI object instances.
00196  *
00197  *  @param this The CPI object.
00198  *  @param lhs The instance data of the left CPI object
00199  *  @param rhs The instance data of the right CPI object
00200  *  @param isequal The pointer to the variable, where the result is to be 
00201  *        returned to.
00202  *
00203  *  @return An error code.
00204  */
00205 GATResult GATResourceCPI_EqualsInstance(GATResourceCPI cpi, 
00206   GATResourceCPI_Instance const *lhs, GATResourceCPI_Instance const *rhs, 
00207   GATBool *isequal);
00208 
00209 /* CPI specific API */
00210 
00211 /** GATResourceCPI_GetResourceDescription
00212  *  @brief Returns the associated resource description.
00213  *
00214  *  The function GATResourceCPI_GetResourceDescription calls the adaptor to 
00215  *  get the resource description associated with this GATResource.
00216  *
00217  *  @param this The CPI object.
00218  *  @param instance_data The instance data of the CPI object.
00219  *  @param description The pointer to the variable, which receives the 
00220  *        resulting resource description.
00221  *
00222  *  @return An error code.
00223  */
00224 GATResult GATResourceCPI_GetResourceDescription(GATResourceCPI cpi, 
00225   GATResourceCPI_Instance const *instance_data, 
00226   GATResourceDescription_const *description);
00227   
00228 /** GATResourceCPI_GetReservation
00229  *  @brief Returns the associated reservation.
00230  *  
00231  *  The function GATResourceCPI_GetReservation calls the adaptor to get the
00232  *  reservation associated with this GATResource.
00233  *
00234  *  @param this The CPI object.
00235  *  @param instance_data The instance data of the CPI object.
00236  *  @param reservation The pointer to a variable, which receives the resulting
00237  *        reservation.
00238  *
00239  *  @return An error code.
00240  */
00241 GATResult GATResourceCPI_GetReservation(GATResourceCPI cpi, 
00242   GATResourceCPI_Instance const *instance_data, 
00243   GATReservation_const *reservation);
00244   
00245 /* GATMonitorable */
00246 
00247 /** GATResourceCPI_GetMetrics
00248  *
00249  *  The function GATResourceCPI_GetMetrics returns the list of metrics supported
00250  *  by this adaptor.
00251  *
00252  *  @param cpi The CPI object.
00253  *  @param instance_data The instance data of the attached CPI object
00254  *  @param The pointer to the variable, which receives the resulting list of
00255  *        metrics.
00256  *
00257  *  @return An error code.
00258  */
00259 GATResult GATResourceCPI_GetMetrics(GATResourceCPI cpi, 
00260   GATResourceCPI_Instance const *data, GATList_GATMetric *metrics);
00261   
00262 /** GATResourceCPI_GetMetricEvent
00263  *
00264  *  The function GATResourceCPI_GetMetricEvent returns the metric event, which is 
00265  *  associated with the given metric.
00266  *
00267  *  @param cpi The CPI object.
00268  *  @param instance_data The instance data of the attached CPI object
00269  *  @param metric The continuous metric, for which the metric event is to be 
00270  *        returned. 
00271  *  @param event The pointer to the variable, which receives the resulting
00272  *        metric event.
00273  *
00274  *  @return An error code.
00275  */
00276 GATResult GATResourceCPI_GetMetricEvent(GATResourceCPI cpi, 
00277   GATResourceCPI_Instance const *data, GATMetric metric, 
00278   GATMetricEvent *event);
00279 
00280 
00281 /* Serialisation API */
00282 
00283 /** GATResourceCPI_Serialise
00284  *  @brief Serialise the instance data.
00285  *
00286  *  Calls the adaptor to serialise the instance data.
00287  *
00288  *  @param this The CPI object.
00289  *  @param instance_data The instance data of the attached CPI object
00290  *  @param stream The stream to use be used for serialisation.
00291  *
00292  *  @return An error code.
00293  */
00294 GATResult GATResourceCPI_Serialise(GATResourceCPI cpi, 
00295   GATResourceCPI_Instance const *data, GATObject stream, GATBool clear_dirty);
00296   
00297 /** GATResourceCPI_DeSerialise
00298  *  @brief De-serialise the instance data
00299  *
00300  *  Call the adaptor to de-serialise the instance data.
00301  *
00302  *  @param context The GAT context to be used for object construction.
00303  *  @param stream The stream interface to use for the serialisation.
00304  *  @param instance_data The pointer to a variable, which contains the client 
00305  *        data of the new object. The member instance data of this object 
00306  *        may receive the pointer to the new instance data of the CPI object.
00307  *
00308  *  @return An error code.
00309  */
00310 GATResult GATResourceCPI_DeSerialise(GATResourceCPI cpi, GATObject stream, 
00311   GATResourceCPI_Instance *data);
00312   
00313 #ifdef __cplusplus
00314 } /* extern "C" */
00315 #endif
00316 
00317 #endif /* !defined(_GATRESOURCECPI_H_) */