GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATFileStream.h

Go to the documentation of this file.
00001 /** @file GATFileStream.h
00002  * Header file for the GATFileStream class.
00003  * 
00004  * An GATFileStream represents a connection to another process.
00005  * 
00006  * @date $Date: 2004/03/24 19:30:58 $
00007  * 
00008  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATFileStream.h,v 1.5 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 _GATFILESTREAM_H_
00020 #define _GATFILESTREAM_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(GATFileStream);
00031 
00032 /* GATObject API */
00033 
00034 /** GATFileStream_Destroy
00035  *  The GATFileStream destructor.
00036  *  This is the destructor for GATFileStream objects.
00037  *
00038  * @param this An old GATFileStream
00039  */
00040 void GATFileStream_Destroy(GATFileStream *strm);
00041 
00042 /** int GATFileStream_GetType(GATFileStream_const fileStream)
00043  *  @brief Return the type of the GATFileStream
00044  *
00045  *  The function @c GATFileStream_GetType always returns GATType_GATFileStream. 
00046  *
00047  *  @param object The object to inspect
00048  *
00049  *  @return returns always @c #GATType_GATFileStream.
00050  */
00051 GATType GATFileStream_GetType(GATFileStream_const fileStream);
00052 
00053 /** int GATFileStream_Clone(GATFileStream_const fileStream, GATFileStream *new_fileStream)
00054  *  @brief Clone the given GATFileStream
00055  *
00056  *  The function @c GATFileStream_Clone generates a (deep) copy of the given
00057  *  GATFileStream. 
00058  *
00059  *  @param fileStream The object to clone
00060  *  @param new_fileStream The pointer, through which the result is to be 
00061  *        returned.
00062  *
00063  *  @return An error type.
00064  */
00065 GATResult GATFileStream_Clone(GATFileStream_const fileStream, GATFileStream *new_fileStream);
00066 
00067 /** int GATFileStream_Equals(GATFileStream_const lhs, GATFileStream_const rhs, GATBool *isequal)
00068  *  @brief Compares two GATFileStream objects
00069  *
00070  *  The function @c GATFileStream_Equals compares two fileStream objects of type 
00071  *  @c #GATFileStream.
00072  *
00073  *  @param lhs The first fileStream object to compare
00074  *  @param rhs The second fileStream 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 GATFileStream_Equals(GATFileStream_const lhs, GATFileStream_const rhs, GATBool *isequal);
00081 
00082 /** int GATFileStream_GetInterface(GATFileStream_const fileStream, GATInterface iftype, void const **ifp)
00083  *  @brief Get an interface supported by a GATFileStream
00084  *
00085  *  The function GATFileStream_GetInterface allows to get a pointer to an 
00086  *  additional interface supported by this GATFileStream.
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   GATFileStream_GetInterface(GATFileStream_const fileStream, GATInterface iftype, 
00096     void const **ifp);
00097 
00098 
00099 /* GATFileStream API */
00100 
00101 /**
00102  *  Constructs an instance of this class.
00103  *
00104  * @param context Used to broker resources.
00105  * @param preferences User preferences for this instance.
00106  * @param location The location of the file to open
00107  * @param mode The mode in which to open the file (GATLogicalFileMode_Read, 
00108  * GATLogicalFileMode_Write, GATLogicalFileMode_Append, or GATLogicalFileMode_ReadWrite).
00109  */
00110 GATFileStream 
00111   GATFileStream_Create(GATContext context, GATPreferences_const preferences, 
00112     GATLocation location, GATFileStreamMode mode);
00113 
00114 /* GATMonitorable API */
00115 
00116 /** GATFileStream_AddMetricListener
00117  *
00118  *  The function GATFileStream_AddMetricListener adds the passed instance of a 
00119  *  GATMetricListener to the list of GATMetricListeners which are notified of 
00120  *  fired GATMetricEvents of the type described by the provided GATMetric 
00121  *  instance.
00122  *
00123  *  @param fileStream The GATFileStream instance to add the GATMetricListener to.
00124  *  @param listener The GTAMetricListener to call, when the corresponding 
00125  *        GATMetricEvent is fired.
00126  *  @param listener_data The client supplied data, which will be passed through
00127  *        to the GATMetricListener.
00128  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00129  *        to the GATMetricListener.
00130  *  @param cookie The returned value should be used to remove the 
00131  *        GATMetricListener from this GATMonitorable.
00132  *
00133  *  @return An error code.
00134  */ 
00135 GATResult GATFileStream_AddMetricListener(GATFileStream fileStream, GATMetricListener listener,
00136   void *listener_data, GATMetric metric, GATuint32 *cookie);
00137 
00138 /** GATFileStream_RegisterPolling
00139  *
00140  *  The function GATFileStream_RegisterPolling registers a continuous 
00141  *  metric with the given GATFileStream instance.
00142  *
00143  *  @param fileStream The GATFileStream instance to register the metric with.
00144  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00145  *        to the GATMetricListener. This metric instance must be of type
00146  *        GATMeasurementType_Continuous, otherwise an error is returned.
00147  *  @param event The pointer to a variable, which should receive the resulting
00148  *        GATMetricEvent. The GATMetricEvent instance should be freed by the 
00149  *        caller when it isn't used anymore.
00150  *  @param cookie The returned value should be used to remove the 
00151  *        GATMetricListener from this GATFileStream.
00152  *
00153  *  @return An error code.
00154  */ 
00155 GATResult 
00156   GATFileStream_RegisterPolling(GATFileStream fileStream, GATMetric metric, 
00157     GATMetricEvent *event, GATuint32 *cookie);
00158 
00159 /** GATFileStream_RemoveRegisteredMetric
00160  *
00161  *  The function GATFileStream_RemoveRegisteredMetric removes a GATMetricListener, 
00162  *  which was previously registered with GATFileStream_AddMetricListener.
00163  *
00164  *  @param fileStream The GATFileStream instance to remove the GATMetricListener from.
00165  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00166  *        to the GATMetricListener.
00167  *  @param cookie This value identifies the GATMetricListener to remove, it 
00168  *        was returned from the corresponding GATMonitorable_AddMetricListener 
00169  *        or GATMonitorable_MetricRegisterPolling functions.
00170  *  
00171  *  @return An error code.
00172  */
00173 GATResult GATFileStream_RemoveRegisteredMetric(GATFileStream fileStream, GATMetric metric, 
00174   GATuint32 cookie);
00175 
00176 /** GATFileStream_GetMetrics
00177  *
00178  *  The function GATFileStream_GetMetrics returns a list of metrics supported by this
00179  *  GATFileStream.
00180  *
00181  *  @param fileStream The GATFileStream instance, for which the supported metrics should be 
00182  *        returned.
00183  *  @param metrics The pointer to the variable, which receives the resulting 
00184  *        list of metrics.
00185  *
00186  *  @return An error code.
00187  */
00188 GATResult GATFileStream_GetMetrics(GATFileStream_const fileStream, GATList_GATMetric *metrics);
00189 
00190 
00191 /* IStreamable implementation */
00192 
00193 /* Reads from this GATStreamable into the given buffer */
00194 GATResult GATFileStream_Read(GATFileStream object, void *buffer, GATuint32 size, GATuint32 *read_bytes);
00195 
00196 /* Writes data from the given Buffer through the GATStreamable */
00197 GATResult GATFileStream_Write(GATFileStream object, void const *buffer, GATuint32 size, GATuint32 *written_bytes);
00198 
00199 /* Reposition the internal stream position */
00200 GATResult GATFileStream_Seek(GATFileStream object, GATOrigin origin, GATint32 offset, GATuint32 *new_position);
00201     
00202 /* Closes this GATStreamable instance. */
00203 GATResult GATFileStream_Close(GATFileStream object);
00204 
00205 
00206 #ifdef __cplusplus
00207 }
00208 #endif
00209 
00210 #endif /* _GATFILESTREAM_H_ */
00211