GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATXdsWrapper.h

Go to the documentation of this file.
00001 /** @file GATXds.h
00002  *  Header file for the GAT xds wrapper functions.
00003  *
00004  *  @date Thu Oct 30 2003
00005  *
00006  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATXdsWrapper.h,v 1.6 2004/04/18 15:12:49 merzky Exp $
00007  *
00008  *  Copyright (C) Hartmut Kaiser
00009  *  This file is part of the GAT Engine.
00010  *  Contributed by Hartmut Kaiser <hartmutkaiser [at] t-online [dot] de>.
00011  *
00012  *  Use, modification and distribution is subject to the Gridlab Software
00013  *  License. (See accompanying file GLlicense.txt or copy at
00014  *  http://www.gridlab.org/GLlicense.txt)
00015  */
00016  
00017 #ifndef _GATXds_H_
00018 #define _GATXds_H_ 1
00019 
00020 /* System Header Files */
00021 #include <stdarg.h>
00022 
00023 /* GAT Header Files */
00024 #include "GATType.h"
00025 #include "GATContext.h"
00026 
00027 /* Macros */
00028 
00029 /* Structures, unions and enums */
00030 typedef xds_t *GATXds;
00031 
00032 typedef enum
00033 {
00034   GATXdsType_Encode = XDS_ENCODE,
00035   GATXdsType_Decode = XDS_DECODE
00036 } GATXdsType;
00037 
00038 typedef enum
00039 {
00040   GATXdsScope_Gift = XDS_GIFT,
00041   GATXdsScope_Loan = XDS_LOAN
00042 } GATXdsScope;
00043 
00044 typedef GATResult (* GATXdsSerialiseCallback)(GATObject, GATObject, GATBool);
00045 typedef GATResult (* GATXdsDeSerialiseCallback)(GATContext, GATObject, 
00046   GATObject *, GATuint32, va_list);
00047 typedef GATBool (* GATXdsVersionCallback)(GATuint32);
00048 
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif
00052 
00053 /* External functions */
00054 
00055 /** GATXds_Init
00056  *  
00057  *  The function GATXds_Init initialises a new instance of the 
00058  *  underlying XDS engine and registers all the streaming functions to be used 
00059  *  by subsequent streaming operations via GATXds_Encode or 
00060  *  GATXds_Decode.
00061  *
00062  *  @param xds The pointer to a variable, which receives the initialised xds 
00063  *        handle.
00064  *  @param type Defines, whether the returned engine is to be used for 
00065  *        serialisation (type == GATXdsType_Encode) or de-serialisation 
00066  *        (type == GATXdsType_Decode).
00067  *  @param context The GAT context for which any GATObjects should be 
00068  *        de-serialised (optional, needed for GATXdsType_Decode only)
00069  *
00070  *  @returns An error code.
00071  */
00072 GATResult GATXds_Init   (GATXds *xds, GATXdsType type);
00073 GATResult GATXds_InitEx (GATXds *xds, GATXdsType type, GATContext context);
00074 
00075 /** GATXds_Destroy
00076  *  
00077  *  The function GATXds_Destroy frees all the memory used by the XDS 
00078  *  engine.
00079  *
00080  *  @param xds The XDS engine handle to destroy.
00081  */
00082 void GATXds_Destroy (GATXds *xds);
00083 
00084 /** GATXds_Encode
00085  *
00086  *  The function GATXds_Encode encodes the given data items accordingly 
00087  *  to the given format description and returns the streamed data through the 
00088  *  supplied buffer variable.
00089  *
00090  *  @param xds The handle of the XDS engine to use.
00091  *  @param flag This defines the ownership of the returned buffer. If 
00092  *        flag == GATXdsScope_Gift, the returned buffer is to be freed by the 
00093  *        caller, If flag == GATXdsScope_Loan, the returned buffer memory is 
00094  *        maintained by the XDS engine.
00095  *  @param buffer The pointer to a variable, where the buffer is to be 
00096  *        returned. If this parameter is zero, no buffer is returned and may
00097  *        be requested in a subsequent call to GATXds_Encode.
00098  *  @param buffer_len This receives the size of the returned buffer.
00099  *  @param fmt A format description, which defines the data format of all 
00100  *        subsequent parameters.
00101  *  @param ... An arbitrary amount of data items to stream.
00102  *
00103  *  @return An error code.
00104  */
00105 GATResult GATXds_Encode(GATXds xds, GATXdsScope flag, void **buffer, 
00106   size_t *buffer_len, const char *fmt, ...);
00107 GATResult GATXds_EncodeV(GATXds xds, GATXdsScope flag, void **buffer, 
00108   size_t *buffer_len, const char *fmt, va_list args);
00109 
00110 /** GATXds_Decode
00111  *
00112  *  The function GATXds_Decode decodes the required amount of data items
00113  *  accordingly to the given format description.
00114  *
00115  *  @param xds The handle of the XDS engine to use.
00116  *  @param flag This defines the ownership of given returned buffer. If 
00117  *        flag == GATXdsScope_Gift, the returned buffer is to be freed by the 
00118  *        XDS engine, If flag == GATXdsScope_Loan, the supplied buffer memory 
00119  *        is maintained by the caller.
00120  *  @param buffer The buffer containing the streamed data. If this parameter is
00121  *        zero, the existing buffer is reused and the decoding continues at the
00122  *        point, where a previous decode ended.
00123  *  @param buffer_len The size of the supplied buffer.
00124  *  @param fmt A format description, which defines the data format of all 
00125  *        subsequent parameters.
00126  *  @param ... An arbitrary amount of data item addresses to decode from the 
00127  *        stream.
00128  *
00129  *  @return An error code.
00130  */
00131 GATResult GATXds_Decode(GATXds xds, GATXdsScope flag, void *buffer, 
00132   size_t buffer_len, const char *fmt, ...);
00133 GATResult GATXds_DecodeV(GATXds xds, GATXdsScope flag, void *buffer, 
00134   size_t buffer_len, const char *fmt, va_list args);
00135 
00136 /** GATXds_GetBufferLen
00137  *
00138  *  The function GATXds_GetBufferLen may be used to retrieve the real
00139  *  amount of data decoded by the last call to GATXds_Decode.
00140  *
00141  *  @param xds The handle of the XDS engine to use.
00142  *
00143  *  @return The offset into the buffer, up to which the data was decoded 
00144  *        successful.
00145  */
00146 size_t GATXds_GetBufferLen(GATXds xds);
00147 
00148 /** GATXds_GetBufferLen
00149  *
00150  *  The function GATXds_GetBufferCapacity may be used to retrieve the 
00151  *  capacity of the buffer inside the XDS engine.
00152  *
00153  *  @param xds The handle of the XDS engine to use.
00154  *
00155  *  @return The buffer capacity.
00156  */
00157 size_t GATXds_GetBufferCapacity(GATXds xds);
00158 
00159 /** GATXds_GetBuffer
00160  *
00161  *  The GATXds_GetBuffer may be called to get access to the buffer stored 
00162  *  inside the XDS engine.
00163  *
00164  *  @param xds The handle of the XDS engine to use.
00165  *  @param flag This defines the ownership of given returned buffer. If 
00166  *        flag == GATXdsScope_Gift, the returned buffer is to be freed by the 
00167  *        XDS engine, If flag == GATXdsScope_Loan, the supplied buffer memory 
00168  *        is maintained by the caller.
00169  *  @param buffer The pointer to a variable, where the buffer is to be 
00170  *        returned. If this parameter is zero, no buffer is returned and may
00171  *        be requested in a subsequent call to GATXds_Encode.
00172  *  @param buffer_len This receives the size of the returned buffer.
00173  *
00174  *  @return An error code.
00175  */
00176 GATResult GATXds_GetBuffer(GATXds xds, GATXdsScope flag, void **buffer, size_t 
00177   *buffer_size);
00178 
00179 /* Helper function to serialise a GATObject with its associated CPI provider */
00180 GATResult
00181 GATXds_SerialiseObject(GATObject object, GATObject stream, GATBool clear_dirty,
00182   GATXdsSerialiseCallback callback, char const *fmt, ...);
00183 
00184 GATResult
00185 GATXds_DeSerialiseObject(GATContext context, GATObject stream, 
00186   GATXdsDeSerialiseCallback callback, GATXdsVersionCallback version_callback,
00187   GATObject *object, char const *fmt, ...);
00188 
00189 #ifdef __cplusplus
00190 }
00191 #endif
00192 
00193 #endif /* _GATXds_H_ */