GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATStatus.h

Go to the documentation of this file.
00001 /** @file GATStatus.h
00002  * Header file for the GATStatus class.
00003  *
00004  * The GATStatus class provides a set of routines to maintain a flexible and
00005  * uniform way to store, retrieve and manage errors and related information,
00006  * which occured during a call to the GAT API.
00007  *
00008  * An instance of this class represents an error or an information message 
00009  * from a GAT operation or from an underlying adaptor. instances of this class 
00010  * are used to provide an audit trail which the application user can use to 
00011  * trace the sequence of events which happened in any particular GAT operation; 
00012  * this may then be used by the application, adaptor or service developers or 
00013  * providers to debug problems.
00014  * Since the GAT Engine and adaptors may do several independent operations each 
00015  * of which may have associated errors or status messages, a GATStatus instance 
00016  * forms a node in a tree of GATStatus instances, rather than the more normal 
00017  * parent-child process of a try-catch type error mechanism.
00018  *
00019  * @date Tue Sep 30 2003
00020  *
00021  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATStatus.h,v 1.19 2004/04/28 10:50:10 hartmutkaiser Exp $
00022  *
00023  *  Copyright (C) Hartmut Kaiser
00024  *  This file is part of the GAT Engine.
00025  *  Contributed by Hartmut Kaiser <hartmutkaiser [at] t-online [dot] de>.
00026  *
00027  *  Use, modification and distribution is subject to the Gridlab Software
00028  *  License. (See accompanying file GLlicense.txt or copy at
00029  *  http://www.gridlab.org/GLlicense.txt)
00030  */
00031  
00032 #if !defined(_GATSTATUS_H_)
00033 #define _GATSTATUS_H_ 1
00034 
00035 #include "GATType.h"
00036 #include "GATList.h"
00037 
00038 /* typedefs */
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 /* Declare the GATList_GATStatus list. */
00045 GATLIST_DECLARE_QUALIFIED(extern, GATStatus, GATList_GATStatus);
00046 
00047 /* Declare the converters to/from GATObject */
00048 GATOBJECT_DECLARE_CONVERTERS(GATStatus);
00049 
00050 
00051 /* Helper API for GATStatus based error diagnostics and error propagation */
00052 
00053 /** GATCreateStatus
00054  *
00055  *  The function GATCreateStatus is a helper function used for creating and
00056  *  assigning a GATStatus object to the function local GATStatus. It is used 
00057  *  for newly diagnosed errors.
00058  *  
00059  *  @param name The function name of the function, where the error/diagnostic
00060  *        occured.
00061  *  @param status The function local status object to which the newly created
00062  *        error/diagnostic should be added.
00063  *  @param code The GATResult code of the error/diagnostic to be added.
00064  *  @param context The GATContext to which the GATStatus to be propagated is 
00065  *        associated with.
00066  *  
00067  *  @return The provided GATResult code from the code parameter.
00068  */
00069 GATResult 
00070 GATCreateStatus(char const *name, GATStatus *status, GATResult result_code, 
00071   GATContext context, char const *filename, GATuint32 lineno);
00072 
00073 /** GATPropagateStatus
00074  *
00075  *  The function GATPropagateStatus is used for taking the current status from
00076  *  the given context and append it to the function local GATStatus. It is used
00077  *  for error/diagnostics propagation purposes.
00078  *
00079  *  @param name The function name of the function, where the error/diagnostic
00080  *        occured.
00081  *  @param status The function local status object to which the newly created
00082  *        error/diagnostic should be added.
00083  *  @param code The GATResult code of the error/diagnostic to be added.
00084  *  @param context The GATContext to which the GATStatus to be propagated is 
00085  *        associated with.
00086  *  
00087  *  @return The provided GATResult code from the code parameter.
00088  *
00089  *  @comment This function is depreciated and was completely replaced by the
00090  *        GATCreateStatus function. 
00091  */
00092 GATResult 
00093   GATPropagateStatus(char const *name, GATStatus *status, GATResult code, 
00094     GATContext context);
00095 
00096 
00097 /* GATObject API */
00098 
00099 /** void GATStatus_Destroy(GATStatus *status)
00100  *  @brief Delete an existing GATStatus object
00101  *
00102  *  The function GATStatus_Destroy destroys this GATStatus object and all of
00103  *  the contained data (such as the GATStatus list of children and the list
00104  *  of attached message strings).
00105  *
00106  *  @param status The GATStatus object to be destroyed. If this parameter is 0 
00107  *        (zero) the function does nothing, but returns @c #GAT_SUCCESS.
00108  */
00109 void GATStatus_Destroy(GATStatus *status);
00110 
00111 /** int GATStatus_Equals(GATStatus_const lhs, GATStatus_const rhs, GATBool *isequal)
00112  *  @brief Compare two GATStatus objects
00113  *
00114  *  The function GATStatus_Equals compares the two given GATStatus objects and 
00115  *  returns the outcome of this comparison.
00116  *
00117  *  @param lhs The first list to compare
00118  *  @param rhs The second list to compare
00119  *  @param isequal The pointer to the GATBool variable, which should receive 
00120  *        the result if the comparison
00121  *
00122  *  @return An error code.
00123  */
00124 GATResult GATStatus_Equals(GATStatus_const lhs, GATStatus_const rhs, 
00125   GATBool *isequal);
00126     
00127 /** GATType GATStatus_GetType(GATStatus_const status)
00128  *  @brief Return the type of the GATStatus
00129  *
00130  *  The function @c GATStatus_GetType always returns GATType_GATStatus. 
00131  *
00132  *  @param object The object to inspect
00133  *
00134  *  @return Returns always @c #GATType_GATStatus.
00135  */
00136 GATType GATStatus_GetType(GATStatus_const status);
00137   
00138 /** int GATStatus_Clone(GATStatus_const status, GATStatus *new_status)
00139  *  @brief Clones a GATStatus object.
00140  *
00141  *  The function GATStatus_Clone makes a exact copy of the given @c #GATStatus
00142  *  object.
00143  *
00144  *  @param status The object to clone
00145  *  @param new_Status The pointer, through which the result is to be 
00146  *        returned.
00147  *
00148  *  @return An error type.
00149  */
00150 GATResult GATStatus_Clone(GATStatus_const status, GATStatus *new_status);
00151   
00152 /** int GATStatus_GetInterface(GATStatus_const file, GATInterface iftype, void const **ifp)
00153  *  @brief Get an interface supported by a GATFile
00154  *
00155  *  The function GATStatus_GetInterface allows to get a pointer to an 
00156  *  additional interface supported by this GATFile.
00157  *
00158  *  @param object The object to be asked for the new interface.
00159  *  @param iftype The interface the object is to be asked for.
00160  *  @param ifp The pointer, through which the result is to be returned.
00161  *
00162  *  @return An error type.
00163  */
00164 GATResult GATStatus_GetInterface(GATStatus_const object, GATInterface iftype, 
00165   void const **ifp);
00166 
00167 /** GATStatus_Trace
00168  *  
00169  *  The function GATStatus_Trace prints out to stderr the content of the given
00170  *  GATStatus object.
00171  *
00172  *  @param status The object for which to print the error information.
00173  */
00174 void GATStatus_Trace(GATStatus_const status);
00175 
00176 /* GATAdvertiseable API */
00177 #define GATSTATUS_VERSION1    0x0100
00178 #define GATSTATUS_LASTVERSION GATSTATUS_VERSION1
00179 #define GATSTATUS_MINOR_MASK  0x00ff
00180 
00181 /** GATResult  GATStatus_Serialise(GATStatus file, GATObject stream, GATBool clear_dirty)
00182  *  @brief Serialise a GATStatus object
00183  *
00184  *  The function GATStatus_Serialise serialises the given GATStatus object into the
00185  *  given stream. 
00186  *
00187  *  @param object The GATStatus object to serialise.
00188  *  @param stream The stream interface to use for the serialisation.
00189  *  @param clear_dirty If the clear_dirty parameter is set to GATTrue, the 
00190  *        internal dirty flag of this object is to be reset (no used here)
00191  *
00192  *  @return An error code.
00193  */
00194 GATResult  
00195   GATStatus_Serialise(GATStatus object, GATObject stream, 
00196     GATBool clear_dirty);
00197 
00198 /** GATStatus GATStatus_DeSerialise(GATContext context, GATObject stream, GATBool clear_dirty)
00199  *  @brief De-serialise a GATStatus object
00200  *
00201  *  The function GATStatus_DeSerialise de-serialises a streamed GATStatus object  
00202  *  from the given stream  It constructs a new instance of the de-serialised 
00203  *  object.
00204  *
00205  *  @param context The GAT context to be used for object construction.
00206  *  @param stream The stream interface to use for the serialisation.
00207  *  @param result The pointer to a variable, which receives the status code of
00208  *        the operation.
00209  *
00210  *  @return The newly constructed GATStatus object.
00211  */
00212 GATStatus 
00213   GATStatus_DeSerialise(GATContext context, GATObject stream, 
00214     GATResult *result);
00215 
00216 /** GATStatus_GetIsDirty
00217  *  
00218  *  The function GATStatus_GetIsDirty retrieves the status of the dirty flag of 
00219  *  this GATStatus object.
00220  *
00221  *  @param object The GATStatus object to inspect for its dirty status.
00222  *  @param isdirty The pointer to a variable, which receives the dirty status.
00223  *
00224  *  @return An error code.
00225  */
00226 GATResult  
00227   GATStatus_GetIsDirty(GATStatus_const object, GATBool *isdirty);
00228 
00229 
00230 /* GATStatus API */
00231 
00232 /** GATStatus GATStatus_Create(char const *message)
00233  *  @brief Create a new GATStatus object
00234  *
00235  *  The function @c GATStatus_Create creates a new GATStatus object and 
00236  *  associates with it the given message. The status code stored internally is 
00237  *  initialized to @c #GAT_SUCCESS.
00238  *
00239  *  @param message The message to associate initially with the newly created 
00240  *        GATStatus.
00241  *
00242  *  @return Returns a handle to the newly created GATStatus object.
00243  *        returns 0 (zero) if an error occurs.
00244  */
00245 GATStatus 
00246   GATStatus_Create(char const *message, char const *filename, GATuint32 lineno);
00247 
00248 /** GATStatus GATStatus_Create_Code(GATResult code)
00249  *  @brief Create a new GATStatus object
00250  *
00251  *  The function @c GATStatus_Create_Code creates a new GATStatus object and 
00252  *  associates with it the given status code. 
00253  *
00254  *  @param code The status code to associate initially with the newly created 
00255  *        GATStatus.
00256  *
00257  *  @return Returns a handle to the newly created GATStatus object.
00258  *        returns 0 (zero) if an error occurs.
00259  */
00260 GATStatus 
00261   GATStatus_Create_Code(GATResult code, char const *filename, GATuint32 lineno);
00262 
00263 /** int GATStatus_SetStatusCode(GATStatus status, int code)
00264  *  @brief Set the status code to be associated with the GATStatus object
00265  *
00266  *  The function GATStatus_SetStatusCode associates a new status code with
00267  *  the GATStatus object under inspection.
00268  *
00269  *  @param status The GATStatus object, which associated status code
00270  *        should be set.
00271  *  @param code The new status code to be associated with the GATStatus
00272  *        object.
00273  *
00274  *  @return Returns @c #GAT_SUCCESS if the given status parameter is a
00275  *        valid GATStatus object. If the given parameter was
00276  *        not a valid GATStatus object, then @c #GAT_INVALID_HANDLE
00277  *        is returned.
00278  */
00279 GATResult GATStatus_SetStatusCode(GATStatus status, int code);
00280 
00281 /** int GATStatus_GetStatusCode(GATStatus status)
00282  *  @brief Get the status code associated with the GATStatus object
00283  *
00284  *  The function GATStatus_GetStatusCode returns the status code, which
00285  *  was associated with the GATSTatus object with a call of the
00286  *  @c #GATStatus_SetStatusCode function.
00287  *
00288  *  @param status The GATStatus object, which associated status code
00289  *        should be returned.
00290  *
00291  *  @return The status code associated with the GATStatus object. If the
00292  *        GATStatus under inspection was not a valid GATStatus (but not
00293  *        equal zero), then @c #GAT_INVALID_HANDLE is returned.
00294  */
00295 GATResult GATStatus_GetStatusCode(GATStatus_const status);
00296 
00297 /** int GATStatus_AddChild(GATStatus status, GATStatus child)
00298  *  @brief Adds a child to the list of children
00299  *
00300  *  The function GATStatus_AddChild adds a GATStatus to the list of
00301  *  children of this status object. Please note, that there is no test
00302  *  to avoid cyclic hierarchies, so you will have to ensure, that a GATStatus
00303  *  object is @b not inserted into a GATStatus hierarchy twice.
00304  *
00305  *  @param status The GATStatus object, which should get the child added.
00306  *  @param child The GATStatus object to be added as the child.
00307  *
00308  *  @returns The function returns @c #GAT_SUCCESS, if the child was
00309  *        successfully added to the list of children. If the status
00310  *        parameter wasn't a valid GATStatus object, then the value
00311  *        @c #GAT_INVALID_HANDLE is returned.
00312  */
00313 GATResult GATStatus_AddChild(GATStatus status, GATStatus child);
00314 
00315 /** GATList_GATStatus_const GATStatus_GetChildren(GATStatus status)
00316  *  @brief Get the list of associated children
00317  *
00318  *  The function GATStatus_GetChildren returns the list of children
00319  *  associated with the given GATStatus.
00320  *
00321  *  @param status The GATStatus object, for which the list of children is to
00322  *        be returned.
00323  *
00324  *  @return The function returns the handle of a GATList_GATStatus object,
00325  *        which holds the GATStatus objects associated as children. If the
00326  *        status parameter does not represent a valid GATStatus object or if
00327  *        there aren't any associated children, then 0 (zero) is returned.
00328  */
00329 GATList_GATStatus_const GATStatus_GetChildren(GATStatus_const status);
00330 
00331 /** int GATStatus_AddMessage(GATStatus status, char const *message)
00332  *  @brief Add a message to the GATStatus object
00333  *
00334  *  The function GATStatus_AddMessage adds a message to the list of
00335  *  messages associated with this GATStatus object.
00336  *
00337  *  @param status The GATStatus object the message has to be
00338  *        associated with.
00339  *  @param message The character string to be associated with the
00340  *        GATStatus object. Note, that actually a copy of this string
00341  *        is stored inside the GATStatus object.
00342  *
00343  *  @return If the message was added successfully to the list of associated 
00344  *        messages of this GATSTatus, the function will return @c #GAT_SUCCESS.
00345  *        If the status parameter does not represent a valid GATStatus object
00346  *        the function returns @c #GAT_INVALID_HANDLE.
00347  */
00348 GATResult GATStatus_AddMessage(GATStatus status, char const *message);
00349 
00350 /** GATList_String_const GATStatus_GetMessages(GATStatus status)
00351  *  @brief get the list of associated messages
00352  *
00353  *  The function GATStatus_GetMessages returns the list of associated messages.
00354  *
00355  *  @param status The GATStatus object, for which the list of messages is to
00356  *        be returned.
00357  *
00358  *  @return The function returns the handle of a GATList_String object,
00359  *        which holds the messages associated with this object. If the
00360  *        status parameter does not represent a valid GATStatus object, 
00361  *        then 0 (zero) is returned.
00362  */
00363 GATList_String_const GATStatus_GetMessages(GATStatus_const status);
00364 
00365 /** GATStatus GATStatus_GetParent(GATStatus status)
00366  *  @brief Get the parent status of this GATStatus object
00367  *  
00368  *  The function GATStatus_GetParent returns the GATStatus object, which is the 
00369  *  direct parent of this status object. This is meaningful especially because,
00370  *  different GATStatus objects may be organized in a hierarchical way.
00371  *
00372  *  @param status The GATStatus object, for which the direct parent is to be 
00373  *        returned
00374  *
00375  *  @return The function returns the GATStatus, which is stored as the direct 
00376  *        parent of this status object. If the status parameter does not 
00377  *        represent a valid GATStatus object, then 0 (zero) is returned.
00378  */
00379 GATStatus_const GATStatus_GetParent(GATStatus_const status);
00380 
00381 #ifdef __cplusplus
00382 } /* extern "C" */
00383 #endif
00384 
00385 #endif /* defined(_GATSTATUS_H_) */