GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATEndpoint.h

Go to the documentation of this file.
00001 /** @file GATEndpoint.h
00002  * Header file for the GATEndpoint class.
00003  * 
00004  * An GATEndpoint represents an end of a byte stream.
00005  * 
00006  * @date $Date: 2004/03/24 19:30:58 $
00007  * 
00008  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATEndpoint.h,v 1.9 2004/03/24 19:30:58 hartmutkaiser Exp $
00009  *
00010  *  Copyright (C) Kelly Davis
00011  *  This file is part of the GAT Engine.
00012  *  Contributed by Kelly Davis <kdavis@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 _GATENDPOINT_H_
00020 #define _GATENDPOINT_H_ 1
00021 
00022 #include "GATType.h"
00023 #include "GATObject.h"
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 /* Declare the converters to/from GATObject */
00030 GATOBJECT_DECLARE_CONVERTERS(GATEndpoint);
00031 
00032 /* GATObject API */
00033 
00034 /** GATEndpoint_Destroy
00035  *  The GATEndpoint destructor.
00036  *  This is the destructor for GATEndpoint objects.
00037  *
00038  * @param this An old GATEndpoint
00039  */
00040 void GATEndpoint_Destroy(GATEndpoint *endpoint);
00041 
00042 /** int GATEndpoint_GetType(GATEndpoint_const endpoint)
00043  *  @brief Return the type of the GATEndpoint
00044  *
00045  *  The function @c GATEndpoint_GetType always returns GATType_GATEndpoint. 
00046  *
00047  *  @param object The object to inspect
00048  *
00049  *  @return returns always @c #GATType_GATEndpoint.
00050  */
00051 GATType GATEndpoint_GetType(GATEndpoint_const endpoint);
00052 
00053 /** int GATEndpoint_Clone(GATEndpoint_const endpoint, GATEndpoint *new_endpoint)
00054  *  @brief Clone the given GATEndpoint
00055  *
00056  *  The function @c GATEndpoint_Clone generates a (deep) copy of the given
00057  *  GATEndpoint. 
00058  *
00059  *  @param endpoint The object to clone
00060  *  @param new_endpoint The pointer, through which the result is to be 
00061  *        returned.
00062  *
00063  *  @return An error type.
00064  */
00065 GATResult GATEndpoint_Clone(GATEndpoint_const endpoint, GATEndpoint *new_endpoint);
00066 
00067 /** int GATEndpoint_Equals(GATEndpoint_const lhs, GATEndpoint_const rhs, GATBool *isequal)
00068  *  @brief Compares two GATEndpoint objects
00069  *
00070  *  The function @c GATEndpoint_Equals compares two endpoint objects of type 
00071  *  @c #GATEndpoint.
00072  *
00073  *  @param lhs The first endpoint object to compare
00074  *  @param rhs The second endpoint object to compare
00075  *  @param isequal The pointer to the GATBool variable, which should receive 
00076  *        the result if the comparision
00077  *
00078  *  @return An error code.
00079  */
00080 GATResult GATEndpoint_Equals(GATEndpoint_const lhs, GATEndpoint_const rhs, GATBool *isequal);
00081 
00082 /** int GATEndpoint_GetInterface(GATEndpoint_const endpoint, GATInterface iftype, void const **ifp)
00083  *  @brief Get an interface supported by a GATEndpoint
00084  *
00085  *  The function GATEndpoint_GetInterface allows to get a pointer to an 
00086  *  additional interface supported by this GATEndpoint.
00087  *
00088  *  @param object The object to be asked for the new interface.
00089  *  @param iftype The interface the object is to be asked for.
00090  *  @param ifp The pointer, through which the result is to be returned.
00091  *
00092  *  @return An error type.
00093  */
00094 GATResult 
00095   GATEndpoint_GetInterface(GATEndpoint_const endpoint, GATInterface iftype, 
00096     void const **ifp);
00097 
00098 
00099 /* GATEndpoint API */
00100 
00101 /**
00102  *  Constructs a unconnected instance of this class.
00103  *
00104  * @param context Used to broker resources.
00105  * @param preferences User preferences for this instance.
00106  */
00107 GATEndpoint 
00108   GATEndpoint_Create(GATContext context, GATPreferences_const preferences);
00109 
00110 /**
00111  *  When a GATEndpoint is obtained from an Advert Directory, it can be
00112  *  used to create a GATPipe connected to the advertising application,
00113  *  by calling connect on the GATEndpoint instance.  This method takes
00114  *  no parameters.  The GATEndpoint can be destroyed at any time
00115  *  without affecting the obtained GATPipe.
00116  *
00117  * @param endpoint The GATEndpoint on which to act
00118  * @param peep A GATPipe connected to the endpoint
00119  */
00120 GATResult GATEndpoint_Connect( GATEndpoint_const endpoint, GATPipe *peep);
00121 
00122 /**
00123  * The creator of an GATEndpoint can use the GATEndpoint to create
00124  * GATPipes, which represent incoming connections.  This is done by
00125  * calling Listen on the GATEndpoint instance.  The GATEndpoint can
00126  * be destroyed at any time without affecting the obtained GATPipe.
00127  *
00128  * @param endpoint The GATEndpoint on which to act
00129  * @param peep A GATPipe connected to the endpoint
00130  */
00131 GATResult GATEndpoint_Listen( GATEndpoint_const endpoint, GATPipe *peep);
00132 
00133 /**
00134  * The creator of an GATEndpoint can use the GATEndpoint to create
00135  * GATPipes, which represent incoming connections.  This is done by
00136  * calling Listen on the GATEndpoint instance.  This call is
00137  * asynchroneous, and returns immediately.  The GATPipe creation is
00138  * performed on the passed GATPipeListener \object. The
00139  * GATEndpoint can be destroyed at any time without affecting the
00140  * obtained GATPipe.
00141  *
00142  * @param endpoint The GATEndpoint on which to act
00143  * @param peepListener GATPipeListener object which handles incoming connections
00144  * @param listenerData Call back data
00145  */
00146 GATResult GATEndpoint_AddGATPipeListener( GATEndpoint_const endpoint, GATPipeListener peepListener, void *listenerData);
00147 
00148 
00149 /* GATMonitorable API */
00150 
00151 /** GATEndpoint_AddMetricListener
00152  *
00153  *  The function GATEndpoint_AddMetricListener adds the passed instance of a 
00154  *  GATMetricListener to the list of GATMetricListeners which are notified of 
00155  *  fired GATMetricEvents of the type described by the provided GATMetric 
00156  *  instance.
00157  *
00158  *  @param endpoint The GATEndpoint instance to add the GATMetricListener to.
00159  *  @param listener The GTAMetricListener to call, when the corresponding 
00160  *        GATMetricEvent is fired.
00161  *  @param listener_data The client supplied data, which will be passed through
00162  *        to the GATMetricListener.
00163  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00164  *        to the GATMetricListener.
00165  *  @param cookie The returned value should be used to remove the 
00166  *        GATMetricListener from this GATMonitorable.
00167  *
00168  *  @return An error code.
00169  */ 
00170 GATResult GATEndpoint_AddMetricListener(GATEndpoint endpoint, GATMetricListener listener,
00171   void *listener_data, GATMetric metric, GATuint32 *cookie);
00172 
00173 /** GATEndpoint_RegisterPolling
00174  *
00175  *  The function GATEndpoint_RegisterPolling registers a continuous 
00176  *  metric with the given GATEndpoint instance.
00177  *
00178  *  @param endpoint The GATEndpoint instance to register the metric with.
00179  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00180  *        to the GATMetricListener. This metric instance must be of type
00181  *        GATMeasurementType_Continuous, otherwise an error is returned.
00182  *  @param event The pointer to a variable, which should receive the resulting
00183  *        GATMetricEvent. The GATMetricEvent instance should be freed by the 
00184  *        caller when it isn't used anymore.
00185  *  @param cookie The returned value should be used to remove the 
00186  *        GATMetricListener from this GATEndpoint.
00187  *
00188  *  @return An error code.
00189  */ 
00190 GATResult 
00191   GATEndpoint_RegisterPolling(GATEndpoint endpoint, GATMetric metric, 
00192     GATMetricEvent *event, GATuint32 *cookie);
00193 
00194 /** GATEndpoint_RemoveRegisteredMetric
00195  *
00196  *  The function GATEndpoint_RemoveRegisteredMetric removes a GATMetricListener, 
00197  *  which was previously registered with GATEndpoint_AddMetricListener.
00198  *
00199  *  @param endpoint The GATEndpoint instance to remove the GATMetricListener from.
00200  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00201  *        to the GATMetricListener.
00202  *  @param cookie This value identifies the GATMetricListener to remove, it 
00203  *        was returned from the corresponding GATMonitorable_AddMetricListener 
00204  *        or GATMonitorable_MetricRegisterPolling functions.
00205  *  
00206  *  @return An error code.
00207  */
00208 GATResult GATEndpoint_RemoveRegisteredMetric(GATEndpoint endpoint, GATMetric metric, 
00209   GATuint32 cookie);
00210 
00211 /** GATEndpoint_GetMetrics
00212  *
00213  *  The function GATEndpoint_GetMetrics returns a list of metrics supported by this
00214  *  GATEndpoint.
00215  *
00216  *  @param endpoint The GATEndpoint instance, for which the supported metrics should be 
00217  *        returned.
00218  *  @param metrics The pointer to the variable, which receives the resulting 
00219  *        list of metrics.
00220  *
00221  *  @return An error code.
00222  */
00223 GATResult GATEndpoint_GetMetrics(GATEndpoint_const endpoint, GATList_GATMetric *metrics);
00224 
00225 
00226 /* GATAdvertiseable API */
00227 #define GATENDPOINT_VERSION1    0x0100
00228 #define GATENDPOINT_LASTVERSION GATENDPOINT_VERSION1
00229 #define GATENDPOINT_MINOR_MASK  0x00ff
00230 
00231 /** int GATEndpoint_Serialise(GATEndpoint endpoint, GATObject stream, GATBool clear_dirty)
00232  *  @brief Serialise a GATEndpoint object
00233  *
00234  *  The function GATEndpoint_Serialise serialises the given GATFIle object into the
00235  *  given stream. 
00236  *
00237  *  @param endpoint The GATEndpoint object to serialise.
00238  *  @param stream The stream interface to use for the serialisation.
00239  *  @param clear_dirty If the clear_dirty parameter is set to GATTrue, the 
00240  *        internal dirty flag of this object is to be reset (no used here)
00241  *
00242  *  @return An error code.
00243  */
00244 GATResult GATEndpoint_Serialise(GATEndpoint endpoint, GATObject stream, GATBool clear_dirty);
00245 
00246 /** GATEndpoint GATEndpoint_DeSerialise(GATContext context, GATObject stream, GATBool clear_dirty)
00247  *  @brief De-serialise a GATEndpoint object
00248  *
00249  *  The function GATEndpoint_DeSerialise de-serialises a streamed GATEndpoint object  
00250  *  from the given stream  It constructs a new instance of the de-serialised 
00251  *  object.
00252  *
00253  *  @param context The GAT context to be used for object construction.
00254  *  @param stream The stream interface to use for the serialisation.
00255  *  @param result The pointer to a variable, which receives the status code of
00256  *        the operation.
00257  *
00258  *  @return The newly constructed GATEndpoint object.
00259  */
00260 GATEndpoint GATEndpoint_DeSerialise(GATContext context, GATObject stream, 
00261   GATResult *result);
00262 
00263 /** GATEndpoint_GetIsDirty
00264  *  
00265  *  The function GATEndpoint_GetIsDirty retrieves the status of the dirty flag of 
00266  *  this GATEndpoint object.
00267  *
00268  *  @param endpoint The GATEndpoint object to inspect for its dirty status.
00269  *  @param isdirty The pointer to a variable, which receives the dirty status.
00270  *
00271  *  @return An error code.
00272  */
00273 GATResult GATEndpoint_GetIsDirty(GATEndpoint_const endpoint, GATBool *isdirty);
00274 
00275 #ifdef __cplusplus
00276 }
00277 #endif
00278 
00279 #endif /* _GATENDPOINT_H_ */
00280