GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATContext.h

Go to the documentation of this file.
00001 /** @file GATContext.h
00002  * Header file for the GATContext class.
00003  * 
00004  * The GATContext is the primary GAT object, and is used to maintain
00005  * state.  There may be multiple contexts.  Creation of the first GATContext
00006  * initialises the GATEngine, and destruction of the last one shuts down the
00007  * GATEngine.
00008  * 
00009  * @date Tue Sep 2 2003
00010  * 
00011  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATContext.h,v 1.23 2004/04/19 12:52:15 hartmutkaiser Exp $
00012  *
00013  *  Copyright (C) Tom Goodale
00014  *  This file is part of the GAT Engine.
00015  *  Contributed by Tom Goodale <goodale@aei.mpg.de>.
00016  *
00017  *  Use, modification and distribution is subject to the Gridlab Software
00018  *  License. (See accompanying file GLlicense.txt or copy at
00019  *  http://www.gridlab.org/GLlicense.txt)
00020  */
00021 
00022 #ifndef _GATCONTEXT_H_
00023 #define _GATCONTEXT_H_ 1
00024 
00025 #include "GATType.h"
00026 #include "GATInternal.h"
00027 #include "GATSecurityContext.h"
00028 
00029 #ifdef __cplusplus
00030 extern "C" 
00031 {
00032 #endif
00033 
00034 /* Declare the converters to/from GATObject */
00035 GATOBJECT_DECLARE_CONVERTERS(GATContext);
00036 
00037 /** GATContext_Create
00038  *  The  GATContext constructor.
00039  *  This is the constuctor for the GATContext.  If there is a GATSelf it uses
00040  *  that for initialisation, otherwise it creates it.
00041  *
00042  * @return A new GATContext
00043  */
00044 GATContext GATContext_Create(void);
00045 
00046 /** GATContext_Destroy
00047  *  The GATContext destructor.
00048  *  This is the destructor for the GATContext.
00049  *
00050  * @param context An old GATContext
00051  */
00052 void GATContext_Destroy(GATContext *ctx);
00053 
00054 /**
00055  * This fucntion returns the type, a #GATType of the passed #GATContext_const.
00056  * This function will always return #GATType_GATContext.
00057  *
00058  * @param this The #GATContext_const to query
00059  * @return The #GATType of the passed @c context
00060  */
00061 GATType 
00062   GATContext_GetType(GATContext_const ctx);
00063 
00064 /** GATContext_AddPreferences
00065  * The given GATPreferences are used as default preferences if for GATObjects 
00066  * created with this GATContext.
00067  *
00068  * @param context The GATContext to modify
00069  * @param preferences Default GATPreferences for GATObjects created with this
00070  *                    GATContext.
00071  * @return An error code
00072  */
00073 GATResult 
00074   GATContext_AddPreferences(GATContext context, GATPreferences_const preferences);
00075 
00076 /** GATContext_RemovePreferences
00077  * Remove the GATPreferences used as default preferences if for
00078  * GATObjects created with this GATContext.
00079  *
00080  * @param context The context to modify
00081  * @return An error code
00082  */
00083 GATResult 
00084   GATContext_RemovePreferences(GATContext context);
00085 
00086 /** GATContext_GetPreferences
00087  * Return the GATPreferences that are used as default preferences if for
00088  * GATObjects created with this GATContext.
00089  *
00090  * @param context The GATContext to query
00091  * @return The GATPreferences of the passed GATContext
00092  */
00093 GATPreferences_const 
00094   GATContext_GetPreferences(GATContext_const context);
00095 
00096 /** GATContext_Clone
00097  * Clone is used to clone a specified context, copying all
00098  * state and security information.  The new GATContext is
00099  * completely independent from the original one, which may 
00100  * be destroyed with no effect on the new one.
00101  *
00102  * @param this The GATContext to clone
00103  * @param thisClone The cloned GATContext
00104  * @return An error code
00105  */
00106 GATResult 
00107   GATContext_Clone(GATContext_const ctx, GATContext *thisClone);
00108 
00109 /**
00110  * Tests this GATContext for equality with 
00111  * the passed GATContext instance
00112  *
00113  * If the passed GATContext points to the same location
00114  * in memory, then it is deemed equal to the passed 
00115  * GATContext instance.
00116  *
00117  * @param this The first GATContext to compare
00118  * @param that The second GATContext to compare
00119  * @param isequal Result of comparrison
00120  * @return An error code
00121  */
00122 GATResult 
00123   GATContext_Equals(GATContext_const lhs, GATContext_const rhs, GATBool *isequal);
00124 
00125 /** GATContext_GetInterface
00126  *  This function gets an interface supported by this GATContext
00127  *
00128  *  The function GATContext_GetInterface allows to get a pointer to an 
00129  *  additional interface supported by this GATContext.
00130  *
00131  *  @param object The object to be asked for the new interface.
00132  *  @param iftype The interface the object is to be asked for.
00133  *  @param ifp The pointer, through which the result is to be returned.
00134  *  @return An error type.
00135  */
00136 GATResult 
00137   GATContext_GetInterface(GATContext_const object, GATInterface iftype, 
00138     void const **ifp);
00139 
00140 /** GATContext_GetCurrentStatus
00141  *
00142  *  The function GATContext_GetCurrentStatus returns the GATStatus object, 
00143  *  which is currently associated with the given GATContext.
00144  *
00145  *  Note, that the ownership of the GATStatus is transfered to the caller of
00146  *  this function. The caller has to destroy the returned GATStatus 
00147  *  explicitely.
00148  *
00149  *  @param context The GATContext, which associated status is to be returned.
00150  *  @param status The pointer to the variable, which receives the returned 
00151  *        status.
00152  *
00153  *  @return An error code.
00154  */
00155 GATResult 
00156   GATContext_GetCurrentStatus(GATContext context, GATStatus_const *status);
00157 
00158 /** GATContext_SetCurrentStatus
00159  *
00160  *  The function GATContext_SetCurrentStatus associates the given GATStatus
00161  *  object with this instance of GATContext.
00162  *
00163  *  Note, that the ownership of the GATStatus is transfered to the GATContext
00164  *  object, so don't destroy the GATStatus directly after calling this 
00165  *  function.
00166  *
00167  *  @param context The GATContext the new status is to be associated with.
00168  *  @param status The GATStatus object to associate with this context 
00169  *        (the ownership is transferred to the context!).
00170  *
00171  *  @return An error code.
00172  */
00173 GATResult  
00174   GATContext_SetCurrentStatus(GATContext context, GATStatus *status);
00175 
00176 /*  GATContext_ServiceActions
00177  *
00178  *  The ServiceActions call is used to allow the GAT Engine to service 
00179  *  asynchronous actions, such as GATRequests and GATMetricEvents. In a 
00180  *  single-threaded application it is likely that a timeout would be supplied, 
00181  *  in a multi-threaded application one thread may be used for the GAT by using 
00182  *  this call and no timeout. 
00183  *
00184  *  @param timeout This may be a 0 timeout to indicate no timeout at all, or
00185  *        a specific time length.
00186  *
00187  *  @return An error code.
00188  */
00189 GATResult 
00190   GATContext_ServiceActions(GATContext context, GATTimePeriod_const timeout);
00191 
00192 /** GATContext_AddSecurityContext
00193  * Adds the passed GATSecurityContext.
00194  *
00195  * @param context The #GATContext to modify
00196  * @param securityContext The #GATSecurityContext to add
00197  * @return An error code
00198  */
00199 GATResult 
00200   GATContext_AddSecurityContext(GATContext context, 
00201     GATSecurityContext securityContext);
00202 
00203 /** GATContext_RemoveSecurityContext
00204  * Removes the passed GATSecurityContext. Upon completion a #GATSecurityContext equivalent
00205  * to the passed #GATSecurityContext is removed from the passed #GATContext, if such exists
00206  * in the passed #GATContext, or an error is returned.
00207  *
00208  * @param The context #GATContext to modify
00209  * @param The #GATSecurityContext to remove
00210  * @return  An error code
00211  */
00212 GATResult 
00213   GATContext_RemoveSecurityContext(GATContext context, 
00214     GATSecurityContext securityContext);
00215 
00216 /** GATContext_GetSecurityContexts
00217  * Gets a list of GATSecurityContexts associated with this GATContext. The returned
00218  * list must be freed by the caller.
00219  *
00220  *  @param context The #GATContext to modify
00221  *  @param A pointer to a GATList_GATSecurityContext receiving this 
00222  *        #GATSecurityContext instances or NULL in an error occurs.
00223  *
00224  *  @return An error code.
00225  */
00226 GATResult 
00227   GATContext_GetSecurityContexts(GATContext_const context, 
00228     GATList_GATSecurityContext *list);
00229 
00230 /** GATContext_GetSecurityContextsByType
00231  *  Gets a List of GATSecurityContexts of the specified type associated with 
00232  *  this GATContext.
00233  *  The returned list must be freed by the caller.
00234  *
00235  *  @param context The #GATContext to query
00236  *  @param type The type of the #GATSecurityContext to return
00237  *  @param The pointer to a GATList_GATSecurityContext which receives the 
00238  *      #GATSecurityContext instances of the the specified type or (NULL or 
00239  *      empty list) on error.
00240  *
00241  *  @return An error code.
00242  */
00243 GATResult
00244   GATContext_GetSecurityContextsByType(GATContext_const context, 
00245     GATSecurityContextType type, GATList_GATSecurityContext *list);
00246   
00247 #ifdef __cplusplus
00248 }
00249 #endif
00250 
00251 #endif /* _GATCONTEXT_H_ */