GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATFile.h

Go to the documentation of this file.
00001 /** @file GATFile.h
00002  * Header file for the GATFile class.
00003  * 
00004  * A GATFile is an abstract representation of a physical file.
00005  * 
00006  * @date Wed Sep 24 2003
00007  * 
00008  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATFile.h,v 1.28 2004/03/24 19:30:58 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 _GATFILE_H_
00020 #define _GATFILE_H_ 1
00021 
00022 #include "GATType.h"
00023 #include "GATContext.h"
00024 #include "GATPreferences.h"
00025 #include "GATLocation.h"
00026 #include "GATMetricEvent.h"
00027 #include "GATMetric.h"
00028 #include "GATMonitorable.h"
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 /* Declare the converters to/from GATObject */
00035 GATOBJECT_DECLARE_CONVERTERS(GATFile);
00036 
00037 /* GATObject API */
00038 
00039 /** GATFile_Destroy
00040  *  The GATFile destructor.
00041  *  This is the destructor for GATFile objects.
00042  *
00043  * @param this An old GATFile
00044  */
00045 void GATFile_Destroy(GATFile *file);
00046 
00047 /** int GATFile_GetType(GATFile_const file)
00048  *  @brief Return the type of the GATFile
00049  *
00050  *  The function @c GATFile_GetType always returns GATType_GATFile. 
00051  *
00052  *  @param object The object to inspect
00053  *
00054  *  @return returns always @c #GATType_GATFile.
00055  */
00056 GATType GATFile_GetType(GATFile_const file);
00057 
00058 /** int GATFile_Clone(GATFile_const filehandle, GATFile *new_file)
00059  *  @brief Clone the given GATFile
00060  *
00061  *  The function @c GATFile_Clone generates a (deep) copy of the given
00062  *  GATFile. 
00063  *
00064  *  @param filehandle The object to clone
00065  *  @param new_file The pointer, through which the result is to be 
00066  *        returned.
00067  *
00068  *  @return An error type.
00069  */
00070 GATResult GATFile_Clone(GATFile_const file, GATFile *new_file);
00071 
00072 /** int GATFile_Equals(GATFile_const lhs, GATFile_const rhs, GATBool *isequal)
00073  *  @brief Compares two GATFile objects
00074  *
00075  *  The function @c GATFile_Equals compares two file objects of type 
00076  *  @c #GATFile.
00077  *
00078  *  @param lhs The first file object to compare
00079  *  @param rhs The second file object to compare
00080  *  @param isequal The pointer to the GATBool variable, which should receive 
00081  *        the result if the comparision
00082  *
00083  *  @return An error code.
00084  */
00085 GATResult GATFile_Equals(GATFile_const lhs, GATFile_const rhs, GATBool *isequal);
00086 
00087 /** int GATFile_GetInterface(GATFile_const file, GATInterface iftype, void const **ifp)
00088  *  @brief Get an interface supported by a GATFile
00089  *
00090  *  The function GATFile_GetInterface allows to get a pointer to an 
00091  *  additional interface supported by this GATFile.
00092  *
00093  *  @param object The object to be asked for the new interface.
00094  *  @param iftype The interface the object is to be asked for.
00095  *  @param ifp The pointer, through which the result is to be returned.
00096  *
00097  *  @return An error type.
00098  */
00099 GATResult 
00100   GATFile_GetInterface(GATFile_const file, GATInterface iftype, void const **ifp);
00101 
00102 
00103 /* GATFile API */
00104 
00105 /** GATFile_Create
00106  *  The  GATFile constructor.
00107  *  This is the constructor for GATFile objects.
00108  *
00109  * @return A new GATFile
00110  */
00111 GATFile GATFile_Create(GATContext context, GATLocation_const location,
00112   GATPreferences_const preferences);
00113 
00114 /** GATFile_Create_Name
00115  *  The  GATFile constructor.
00116  *  This is the constructor for GATFile objects.
00117  *
00118  *  @return A new GATFile
00119  */
00120 GATFile GATFile_Create_Name(GATContext context, char const *name,
00121   GATPreferences preferences);
00122 
00123 /** GATFile_Copy
00124  *  @brief Copy a file from one location to another.
00125  *
00126  *  The function GATFile_Copy copies the given file to another location. For 
00127  *  this it tries to call through its CPI's all matching adapters registered 
00128  *  for the file CPI. 
00129  *
00130  *  @param this The file to be copied to the new location
00131  *  @param targetLocation The location the file has to be copied to.
00132  *
00133  *  @return An error code
00134  */
00135 GATResult GATFile_Copy(GATFile_const file, GATLocation_const targetLocation,
00136   GATFileMode mode);
00137 
00138 /** GATFile_Move
00139  *  @brief Move a file from one location to another.
00140  *
00141  *  The function GATFile_Move moves the given file to another location. For 
00142  *  this it tries to call through its CPI's all matching adapters registered 
00143  *  for the file CPI. 
00144  *
00145  *  @param this The file to be moved to the new location
00146  *  @param targetLocation The location the file has to be moved to.
00147  *
00148  *  @return An error code
00149  */
00150 GATResult GATFile_Move(GATFile_const file, GATLocation_const targetLocation,
00151   GATFileMode mode);
00152 
00153 /** GATFile_Delete
00154  *  @brief Delete a file.
00155  *
00156  *  The function GATFile_Delete deletes the given file. For 
00157  *  this it tries to call through its CPI's all matching adapters registered 
00158  *  for the file CPI. 
00159  *
00160  *  @param this The file to be moved to the new location
00161  *
00162  *  @return An error code
00163  */
00164 GATResult GATFile_Delete(GATFile_const file);
00165 
00166 /** GATFile_IsReadable
00167  *  @brief Check the file attributes for the readable flag
00168  *
00169  *  The function GATFile_IsReadable checks the file attributes of the given 
00170  *  file and returns, whether it is readable.
00171  *
00172  *  @param this The file to be inspected for its readability attribute.
00173  *
00174  *  @return If the inspected file is readable, the function returns 
00175  *        @c #GAT_SUCCESS, if it is not readable, @c #GAT_FALSE is returned.
00176  *        Otherwise the function returns any of the possible errorcodes.
00177  */
00178 GATResult GATFile_IsReadable(GATFile_const file);
00179 
00180 /** GATFile_IsWritable
00181  *  @brief Check the file attributes for the writable flag
00182  *
00183  *  The function GATFile_IsWritable checks the file attributes of the given 
00184  *  file and returns, whether it is writable.
00185  *
00186  *  @param this The file to be inspected for its writability attribute.
00187  *
00188  *  @return If the inspected file is writable, the function returns 
00189  *        @c #GAT_SUCCESS, if it is not writable, @c #GAT_FALSE is returned.
00190  *        Otherwise the function returns any of the possible errorcodes.
00191  */
00192 GATResult GATFile_IsWritable(GATFile_const file);
00193 
00194 /** GATFile_GetLength
00195  *  @brief Returns the size of the given file
00196  *
00197  *  The function GATFile_GetLength returns the file size of the given size  
00198  *  measured in bytes.
00199  *
00200  *  @param this The file to be inspected for its size.
00201  *  @param length The pointer to the variable, where the length of the file is
00202  *        to be returned to.
00203  *
00204  *  @return An error code
00205  */
00206 GATResult GATFile_GetLength(GATFile_const file, unsigned long *length);
00207 
00208 /** GATFile_LastWriteTime
00209  *  @brief Returns the time of last modification of the given file
00210  *
00211  *  The function GATFile_LastWriteTime returns the time of last modification of
00212  *  the inspected file.
00213  *
00214  *  @param this The file to be inspected for its modification time.
00215  *  @param lw_time The pointer to the variable, where the last write time is 
00216  *      to returned to.
00217  *
00218  *  @return An error code
00219  */
00220 GATResult GATFile_LastWriteTime(GATFile_const file, GATTime *lw_time);
00221 
00222 /** GATFile_GetLocation
00223  *  This method returns the Location of this File
00224  *
00225  *  @return The Location of this File
00226  */
00227 GATLocation_const GATFile_GetLocation(GATFile_const file);
00228 
00229 
00230 /* GATMonitorable API */
00231 
00232 /** GATFile_AddMetricListener
00233  *
00234  *  The function GATFile_AddMetricListener adds the passed instance of a 
00235  *  GATMetricListener to the list of GATMetricListeners which are notified of 
00236  *  fired GATMetricEvents of the type described by the provided GATMetric 
00237  *  instance.
00238  *
00239  *  @param file The GATFile instance to add the GATMetricListener to.
00240  *  @param listener The GTAMetricListener to call, when the corresponding 
00241  *        GATMetricEvent is fired.
00242  *  @param listener_data The client supplied data, which will be passed through
00243  *        to the GATMetricListener.
00244  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00245  *        to the GATMetricListener.
00246  *  @param cookie The returned value should be used to remove the 
00247  *        GATMetricListener from this GATMonitorable.
00248  *
00249  *  @return An error code.
00250  */ 
00251 GATResult GATFile_AddMetricListener(GATFile file, GATMetricListener listener,
00252   void *listener_data, GATMetric metric, GATuint32 *cookie);
00253 
00254 /** GATFile_RegisterPolling
00255  *
00256  *  The function GATFile_RegisterPolling registers a continuous 
00257  *  metric with the given GATFile instance.
00258  *
00259  *  @param file The GATFile instance to register the metric with.
00260  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00261  *        to the GATMetricListener. This metric instance must be of type
00262  *        GATMeasurementType_Continuous, otherwise an error is returned.
00263  *  @param event The pointer to a variable, which should receive the resulting
00264  *        GATMetricEvent. The GATMetricEvent instance should be freed by the 
00265  *        caller when it isn't used anymore.
00266  *  @param cookie The returned value should be used to remove the 
00267  *        GATMetricListener from this GATFile.
00268  *
00269  *  @return An error code.
00270  */ 
00271 GATResult 
00272   GATFile_RegisterPolling(GATFile file, GATMetric metric, 
00273     GATMetricEvent *event, GATuint32 *cookie);
00274 
00275 /** GATFile_RemoveRegisteredMetric
00276  *
00277  *  The function GATFile_RemoveRegisteredMetric removes a GATMetricListener, 
00278  *  which was previously registered with GATFile_AddMetricListener.
00279  *
00280  *  @param file The GATFile instance to remove the GATMetricListener from.
00281  *  @param metric The GATMetric instance describing the GATMetricEvent to pass
00282  *        to the GATMetricListener.
00283  *  @param cookie This value identifies the GATMetricListener to remove, it 
00284  *        was returned from the corresponding GATMonitorable_AddMetricListener 
00285  *        or GATMonitorable_MetricRegisterPolling functions.
00286  *  
00287  *  @return An error code.
00288  */
00289 GATResult GATFile_RemoveRegisteredMetric(GATFile file, GATMetric metric, 
00290   GATuint32 cookie);
00291 
00292 /** GATFile_GetMetrics
00293  *
00294  *  The function GATFile_GetMetrics returns a list of metrics supported by this
00295  *  GATFile.
00296  *
00297  *  @param file The GATFile instance, for which the supported metrics should be 
00298  *        returned.
00299  *  @param metrics The pointer to the variable, which receives the resulting 
00300  *        list of metrics.
00301  *
00302  *  @return An error code.
00303  */
00304 GATResult GATFile_GetMetrics(GATFile_const file, GATList_GATMetric *metrics);
00305 
00306 
00307 /* GATAdvertiseable API */
00308 #define GATFILE_VERSION1    0x0100
00309 #define GATFILE_LASTVERSION GATFILE_VERSION1
00310 #define GATFILE_MINOR_MASK  0x00ff
00311 
00312 /** int GATFile_Serialise(GATFile file, GATObject stream, GATBool clear_dirty)
00313  *  @brief Serialise a GATFile object
00314  *
00315  *  The function GATFile_Serialise serialises the given GATFIle object into the
00316  *  given stream. 
00317  *
00318  *  @param file The GATFile object to serialise.
00319  *  @param stream The stream interface to use for the serialisation.
00320  *  @param clear_dirty If the clear_dirty parameter is set to GATTrue, the 
00321  *        internal dirty flag of this object is to be reset (no used here)
00322  *
00323  *  @return An error code.
00324  */
00325 GATResult GATFile_Serialise(GATFile file, GATObject stream, GATBool clear_dirty);
00326 
00327 /** GATFile GATFile_DeSerialise(GATContext context, GATObject stream, GATBool clear_dirty)
00328  *  @brief De-serialise a GATFile object
00329  *
00330  *  The function GATFile_DeSerialise de-serialises a streamed GATFile object  
00331  *  from the given stream  It constructs a new instance of the de-serialised 
00332  *  object.
00333  *
00334  *  @param context The GAT context to be used for object construction.
00335  *  @param stream The stream interface to use for the serialisation.
00336  *  @param result The pointer to a variable, which receives the status code of
00337  *        the operation.
00338  *
00339  *  @return The newly constructed GATFile object.
00340  */
00341 GATFile GATFile_DeSerialise(GATContext context, GATObject stream, 
00342   GATResult *result);
00343 
00344 /** GATFile_GetIsDirty
00345  *  
00346  *  The function GATFile_GetIsDirty retrieves the status of the dirty flag of 
00347  *  this GATFile object.
00348  *
00349  *  @param file The GATFile object to inspect for its dirty status.
00350  *  @param isdirty The pointer to a variable, which receives the dirty status.
00351  *
00352  *  @return An error code.
00353  */
00354 GATResult GATFile_GetIsDirty(GATFile_const file, GATBool *isdirty);
00355   
00356 #ifdef __cplusplus
00357 }
00358 #endif
00359 
00360 #endif /* _GATFILE_H_ */