GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

GATInterfaceMap.c

Go to the documentation of this file.
00001 /** @file GATInterfaceMap.c
00002  *  Source file for the GATInterfaceMap class.
00003  *
00004  *  @date Wed Oct 29 2003
00005  *
00006  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATInterfaceMap.c,v 1.16 2004/04/02 12:31:57 hartmutkaiser 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 static const char *rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATInterfaceMap.c,v 1.16 2004/04/02 12:31:57 hartmutkaiser Exp $";
00018 
00019 /* System Header Files */
00020 #include <assert.h>
00021 
00022 /* GAT Header Files */
00023 #include "GAT.h"
00024 #include "GATInterfaceMap.h" 
00025 
00026 /* Macros */
00027 
00028 /* Structures, unions and enums */
00029 typedef struct GATInterfaceMap_S {
00030   GATType type;
00031   struct GATObject_ISerialisable_vtable_S *vtable;
00032 } GATInterfaceMap;
00033 
00034 /* Static function prototypes */
00035 
00036 /* File scope variables */
00037 static GATInterfaceMap interface_map[] = {
00038   { GATType_GATStatus, 0 },
00039   { GATType_GATList, 0 },
00040   { GATType_GATTable, 0 },
00041   { GATType_GATSoftwareResourceDescription, 0 },
00042   { GATType_GATHardwareResourceDescription, 0 },
00043   { GATType_GATFile, 0 },
00044   { GATType_GATLogicalFile, 0 },
00045   { GATType_GATLocation, 0 },
00046   { GATType_GATTime, 0 },
00047   { GATType_GATTimePeriod, 0 },
00048   { GATType_GATSoftwareDescription, 0 },
00049   { GATType_GATPreferences, 0 },
00050   { GATType_GATString, 0 },
00051   { GATType_GATSoftwareResource, 0 },
00052   { GATType_GATHardwareResource, 0 },
00053   { GATType_GATResourceBroker, 0 },
00054   { GATType_GATReservation, 0 },
00055   { GATType_GATJob, 0 },
00056   { GATType_GATJobDescription, 0 },
00057   { GATType_GATEndpoint, 0 },
00058   
00059 /* TODO: Add the entries for the other GATObject's here too */
00060 
00061   { GATType_NoType, 0 }                 /* this should be the last entry */
00062 };
00063 
00064 /* External functions */
00065 /* The function which registers all serialisation vtables */
00066 GATResult
00067 GATObject_Register_GATSerialisables(void)
00068 {
00069   GATTable_Register_GATSerialisable(); 
00070   GATResourceDescription_Register_GATSerialisable(); 
00071   GATEndpoint_Register_GATSerialisable();
00072   GATFile_Register_GATSerialisable();
00073   GATList_Register_GATSerialisable();
00074   GATLogicalFile_Register_GATSerialisable(); 
00075   GATLocation_Register_GATSerialisable(); 
00076   GATSoftwareDescription_Register_GATSerialisable(); 
00077 /*  GATPrefernces_Register_GATSerialisable(); */
00078   GATString_Register_GATSerialisable(); 
00079   GATResource_Register_GATSerialisable();
00080 /*  GATResourceBroker_Register_GATSerialisable(); */
00081 /*  GATReservation_Register_GATSerialisable(); */
00082   GATJob_Register_GATSerialisable(); 
00083   GATJobDescription_Register_GATSerialisable();
00084   GATStatus_Register_GATSerialisable();
00085   GATTime_Register_GATSerialisable();
00086   GATTimePeriod_Register_GATSerialisable(); 
00087   
00088 /* TODO: add the registration functions for the other GATObject's here */
00089   
00090   return GAT_SUCCESS;
00091 }
00092 
00093 GATResult
00094 GATObject_Unregister_GATSerialisables(void)
00095 {
00096   return GAT_SUCCESS;   /* nothing to do for now */
00097 }
00098 
00099 GATResult
00100 GATObject_Register_GATSerialisable(GATType type, void *vtable)
00101 {
00102   GATResult retval = GAT_INVALID_PARAMETER;
00103   GATInterfaceMap *map = interface_map;
00104   for (/**/; GATType_NoType != map->type; ++map)
00105   {
00106     if (type == map->type)
00107     {
00108       map->vtable = (struct GATObject_ISerialisable_vtable_S *) vtable;
00109       retval = GAT_SUCCESS;
00110       break;
00111     }
00112   }
00113   assert(GAT_SUCCESS == retval);
00114   return retval;
00115 }
00116 
00117 GATResult 
00118 GATObject_Get_GATSerialisable(GATType type, 
00119   struct GATObject_ISerialisable_vtable_S **vtable)
00120 {
00121   GATResult retval = GAT_NO_INTERFACE;
00122   GATInterfaceMap *map = interface_map;
00123   for (/**/; GATType_NoType != map->type; ++map)
00124   {
00125     if (type == map->type)
00126     {
00127       if (NULL != vtable)
00128       {
00129         if (NULL != map->vtable)
00130         {
00131           *vtable = map->vtable;
00132           retval = GAT_SUCCESS;
00133         }
00134       }
00135       else
00136       {
00137         retval = GAT_INVALID_PARAMETER;
00138       }
00139       break;
00140     }
00141   }
00142   assert(GAT_SUCCESS == retval);
00143   return retval;
00144 }
00145 
00146 /* Local functions */
00147