GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATAdvertServiceCPI.h

Go to the documentation of this file.
00001 /** @file GATAdvertServiceCPI.h
00002  *  Header file for the GATAdvertServiceCPI class.
00003  *
00004  *  @date Fri Feb 13 2004
00005  *
00006  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATAdvertServiceCPI.h,v 1.6 2004/03/24 19:30:57 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(_GATADVERTSERVICECPI_H_)
00018 #define _GATADVERTSERVICECPI_H_
00019 
00020 typedef struct GATAdvertServiceCPI_S *GATAdvertServiceCPI;
00021 
00022 #include "GATContext.h"
00023 #include "GATPreferences.h"
00024 #include "GATMonitorable.h"
00025 
00026 /* Versioning constants for the GATAdvertServiceCPI_Data struct */
00027 #define GATADVERTSERVICECPI_VERSION1 1 
00028 
00029 /* the newest version we know of */
00030 #define GATADVERTSERVICECPI_VERSION  GATADVERTSERVICECPI_VERSION1
00031 
00032 /**
00033  *  The @c #GATAdvertServiceCPI_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 
00040   GATString pwd;        /* reference path for resolving relative paths */
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 } GATAdvertServiceCPI_Instance;
00045 
00046 
00047 /* prototypes for the adapter callback functions */
00048 typedef void (*GATAdvertServiceCPI_Adaptor_Destroy)(void *);
00049 
00050 typedef GATResult (*GATAdvertServiceCPI_Adaptor_ServiceActions)(void *, 
00051   GATAdvertServiceCPI_Instance *, GATTimePeriod_const);
00052 
00053 /* instance specific functions */
00054 typedef void (*GATAdvertServiceCPI_Adaptor_DestroyInstance)(void *, 
00055   GATAdvertServiceCPI_Instance *);
00056 
00057 typedef GATResult (*GATAdvertServiceCPI_Adaptor_CreateInstance)(void *, 
00058   GATAdvertServiceCPI_Instance *);
00059 
00060 typedef GATResult (*GATAdvertServiceCPI_Adaptor_CloneInstance)(void *, 
00061   GATAdvertServiceCPI_Instance const *, GATAdvertServiceCPI_Instance *);
00062 
00063 typedef GATResult (*GATAdvertServiceCPI_Adaptor_EqualsInstance)(void *, 
00064   GATAdvertServiceCPI_Instance const *, GATAdvertServiceCPI_Instance const *, 
00065   GATBool *);
00066 
00067 
00068 /* CPI specific API */
00069 typedef GATResult (*GATAdvertServiceCPI_Adaptor_Add)(void *, 
00070   GATAdvertServiceCPI_Instance *, GATObject_const, GATTable_const, 
00071   GATString_const);
00072 
00073 typedef GATResult (*GATAdvertServiceCPI_Adaptor_Delete)(void *, 
00074   GATAdvertServiceCPI_Instance *, GATString_const);
00075 
00076 typedef GATResult (*GATAdvertServiceCPI_Adaptor_GetMetaData)(void *, 
00077   GATAdvertServiceCPI_Instance const *, GATString_const, GATTable *);
00078 
00079 typedef GATResult (*GATAdvertServiceCPI_Adaptor_GetAdvertisable)(void *, 
00080   GATAdvertServiceCPI_Instance const *, GATString_const, GATObject *);
00081 
00082 typedef GATResult (*GATAdvertServiceCPI_Adaptor_Find)(void *, 
00083   GATAdvertServiceCPI_Instance const *, GATTable_const, GATList_String *);
00084 
00085 
00086 /* callback function prototypes for the GATMonitorable interface support */
00087 typedef GATResult (* GATAdvertServiceCPI_Adaptor_GetMetrics)(void *, 
00088   GATAdvertServiceCPI_Instance const *, GATList_GATMetric *);
00089 
00090 typedef GATResult (* GATAdvertServiceCPI_Adaptor_GetMetricEvent)(void *, 
00091   GATAdvertServiceCPI_Instance const *, GATMetric, GATMetricEvent *); 
00092 
00093 
00094 /* CPI data passed from the adaptor while registering the CPI */
00095 typedef struct
00096 {
00097   /* CPI data (type local data) */
00098   void *data;
00099   GATAdvertServiceCPI_Adaptor_Destroy destroy;
00100 
00101   /* CPI instance data */
00102   GATAdvertServiceCPI_Adaptor_ServiceActions service_actions;
00103   GATAdvertServiceCPI_Adaptor_CreateInstance create_instance;
00104   GATAdvertServiceCPI_Adaptor_DestroyInstance destroy_instance;
00105   GATAdvertServiceCPI_Adaptor_CloneInstance clone_instance;
00106   GATAdvertServiceCPI_Adaptor_EqualsInstance equals_instance;
00107 
00108   /* CPI functionality */
00109   GATAdvertServiceCPI_Adaptor_Add add_entry;
00110   GATAdvertServiceCPI_Adaptor_Delete delete_entry;
00111   GATAdvertServiceCPI_Adaptor_GetMetaData get_metadata;
00112   GATAdvertServiceCPI_Adaptor_GetAdvertisable get_advertisable;
00113   GATAdvertServiceCPI_Adaptor_Find find_entries;
00114   
00115   /* CPI monitoring support */
00116   GATAdvertServiceCPI_Adaptor_GetMetrics get_metrics;
00117   GATAdvertServiceCPI_Adaptor_GetMetricEvent get_metric_event;
00118 } GATAdvertServiceCPI_Data;
00119 
00120 #ifdef __cplusplus
00121 extern "C" {
00122 #endif
00123 
00124 /* Adaptor API */
00125 
00126 /** GATAdvertServiceCPI_Create
00127  *  The  GATAdvertServiceCPI constructor.
00128  *  new_cpi is the constructor for GATAdvertServiceCPI objects.
00129  *  
00130  *  @param version Version of the GATAdvertServiceCPI_Data structure
00131  *  @param data Pointer to adaptor CPI instance data structure.
00132  *
00133  * @return A new GATAdvertServiceCPI
00134  */
00135 GATAdvertServiceCPI GATAdvertServiceCPI_Create(unsigned long int version,
00136   GATAdvertServiceCPI_Data *data);
00137 
00138 
00139 /* API internal to the GAT engine */
00140 
00141 /** GATAdvertServiceCPI_Destroy
00142  *  @brief The GATAdvertServiceCPI destructor.
00143  *
00144  *  This is the destructor for GATAdvertServiceCPI objects.
00145  *
00146  *  @param this An old GATAdvertServiceCPI
00147  */
00148 void GATAdvertServiceCPI_Destroy(GATAdvertServiceCPI *cpi);
00149 
00150 /* CPI instance specific functions */
00151 
00152 /** GATAdvertServiceCPI_CreateInstance
00153  *  @brief Create a new CPI object instance
00154  *
00155  *  Calls the adaptor to create a new CPI object instance.
00156  *
00157  *  @param this The CPI object.
00158  *  @param context a GATContext
00159  *  @param instance_data The instance data of the attached CPI object
00160  *
00161  *  @return An error code.
00162  */
00163 GATResult GATAdvertServiceCPI_CreateInstance(GATAdvertServiceCPI cpi, 
00164   GATAdvertServiceCPI_Instance *instance_data);
00165   
00166 /** GATAdvertServiceCPI_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 GATAdvertServiceCPI_DestroyInstance(GATAdvertServiceCPI cpi, 
00175   GATAdvertServiceCPI_Instance *instance_data);
00176 
00177 /** GATAdvertServiceCPI_EqualsInstance
00178  *  @brief Compares two CPI object instances.
00179  *
00180  *  Calls the adaptor to compare two CPI object instances.
00181  *
00182  *  @param this The CPI object.
00183  *  @param lhs The instance data of the left CPI object
00184  *  @param rhs The instance data of the right CPI object
00185  *  @param isequal The pointer to the variable, where the result is to be 
00186  *        returned to.
00187  *
00188  *  @return An error code.
00189  */
00190 GATResult GATAdvertServiceCPI_EqualsInstance(GATAdvertServiceCPI cpi, 
00191   GATAdvertServiceCPI_Instance const *lhs, GATAdvertServiceCPI_Instance const *rhs, 
00192   GATBool *isequal);
00193 
00194 /** GATAdvertServiceCPI_CloneInstance
00195  *  @brief Clones a CPI object instance.
00196  *
00197  *  Calls the adaptor to clone a CPI object instance.
00198  *
00199  *  @param this The CPI object.
00200  *  @param instance_data The instance data of the CPI object to clone.
00201  *  @param new_instance_data The new instance data is to be returned here.
00202  *
00203  *  @return An error code.
00204  */
00205 GATResult GATAdvertServiceCPI_CloneInstance(GATAdvertServiceCPI cpi, 
00206   GATAdvertServiceCPI_Instance const *instance_data,
00207   GATAdvertServiceCPI_Instance *new_instance_data);
00208 
00209 
00210 /* CPI specific API */
00211 
00212 /** GATAdvertServiceCPI_Add
00213  *  
00214  *  Calls the adaptor to add a new entry to the advert service.
00215  *
00216  *  @param this The CPI object.
00217  *  @param instance_data The instance data of the CPI object to add the entry 
00218  *        to.
00219  *  @param advertisable The advertisable object, which should be stored in the 
00220  *        given advertservice.
00221  *  @param metadata The meta data to rassociate with the newly created entry.
00222  *  @param path The path inside the advert service, where the newly created 
00223  *        entry is to be stored.
00224  *
00225  *  @return An error code.
00226  */
00227 GATResult 
00228   GATAdvertServiceCPI_Add(GATAdvertServiceCPI cpi, 
00229     GATAdvertServiceCPI_Instance *instance_data, GATObject_const advertisable, 
00230     GATTable_const metadata, GATString_const path);
00231 
00232 /** GATAdvertServiceCPI_Delete
00233  *  
00234  *  Calls the adaptor to delete an entry from the advert service.
00235  *
00236  *  @param this The CPI object.
00237  *  @param instance_data The instance data of the CPI object to delete the entry
00238  *        from.
00239  *  @param path The path of the entry to delete from the given advert service.
00240  *
00241  *  @return An error code.
00242  */
00243 GATResult 
00244   GATAdvertServiceCPI_Delete(GATAdvertServiceCPI cpi, 
00245     GATAdvertServiceCPI_Instance *instance_data, GATString_const path);
00246 
00247 /** GATAdvertServiceCPI_GetMetaData
00248  *  
00249  *  Calls the adaptor to retrieve the meta data of a given entry in the advert 
00250  *  service.
00251  *
00252  *  @param this The CPI object.
00253  *  @param instance_data The instance data of the CPI object to get the meta 
00254  *        data for a certain entry from.
00255  *  @param path The path of the entry, for which the meta data should be 
00256  *        retrieved.
00257  *  @param The pointer to a variable, which receives the requested meta data. 
00258  *
00259  *  @return An error code.
00260  */
00261 GATResult 
00262   GATAdvertServiceCPI_GetMetaData(GATAdvertServiceCPI cpi, 
00263     GATAdvertServiceCPI_Instance const *instance_data, GATString_const path, 
00264     GATTable *metadata);
00265 
00266 /** GATAdvertServiceCPI_GetAdvertisable
00267  *  
00268  *  Calls the adaptor to retrieve the advertisable object stored in a given 
00269  *  entry in the advert service.
00270  *
00271  *  @param this The CPI object.
00272  *  @param instance_data The instance data of the CPI object to get the 
00273  *        advertised object for a certain entry from.
00274  *  @param path The path of the entry, for which the stroed advertisable should 
00275  *        be retrieved.
00276  *  @param advertisable The pointer to a variable, which should receive the 
00277  *        requested advertisable object.
00278  *
00279  *  @return An error code.
00280  */
00281 GATResult 
00282   GATAdvertServiceCPI_GetAdvertisable(GATAdvertServiceCPI cpi, 
00283     GATAdvertServiceCPI_Instance const *instance_data, GATString_const path, 
00284     GATObject *advertisable);
00285 
00286 /** GATAdvertServiceCPI_Find
00287  *  
00288  *  Calls the adaptor to find a list of matching entries in the advert service.
00289  *
00290  *  @param this The CPI object.
00291  *  @param instance_data The instance data of the CPI object, where to find the 
00292  *        matching entries.
00293  *  @param metadata The meta data search criteria to use for the query.
00294  *  @param paths The pointer to a variable, which should receive the list of
00295  *        paths pointing to matching entries inside the given advert service.
00296  *
00297  *  @return An error code.
00298  */
00299 GATResult 
00300   GATAdvertServiceCPI_Find(GATAdvertServiceCPI cpi, 
00301     GATAdvertServiceCPI_Instance const *instance_data, GATTable_const metadata,
00302     GATList_String *paths);
00303   
00304 
00305 /* GATMonitorable */
00306 
00307 /** GATAdvertServiceCPI_GetMetrics
00308  *
00309  *  The function GATAdvertServiceCPI_GetMetrics returns the list of metrics 
00310  *  supported by this adaptor.
00311  *
00312  *  @param cpi The CPI object.
00313  *  @param instance_data The instance data of the attached CPI object
00314  *  @param The pointer to the variable, which receives the resulting list of
00315  *        metrics.
00316  *
00317  *  @return An error code.
00318  */
00319 GATResult GATAdvertServiceCPI_GetMetrics(GATAdvertServiceCPI cpi, 
00320   GATAdvertServiceCPI_Instance const *data, GATList_GATMetric *metrics);
00321   
00322 /** GATAdvertServiceCPI_GetMetricEvent
00323  *
00324  *  The function GATAdvertServiceCPI_GetMetricEvent returns the metric event, which is 
00325  *  associated with the given metric.
00326  *
00327  *  @param cpi The CPI object.
00328  *  @param instance_data The instance data of the attached CPI object
00329  *  @param metric The continuous metric, for which the metric event is to be 
00330  *        returned. 
00331  *  @param event The pointer to the variable, which receives the resulting
00332  *        metric event.
00333  *
00334  *  @return An error code.
00335  */
00336 GATResult GATAdvertServiceCPI_GetMetricEvent(GATAdvertServiceCPI cpi, 
00337   GATAdvertServiceCPI_Instance const *data, GATMetric metric, 
00338   GATMetricEvent *event);
00339 
00340 #ifdef __cplusplus
00341 } /* extern "C" */
00342 #endif
00343 
00344 #endif /* !defined(_GATADVERTSERVICECPI_H_) */
00345