00001 /** @file GATRequestCPIInstanceData.h
00002 *
00003 * @date Thu Apr 01 2004
00004 *
00005 * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/adaptors/resourcebroker/GATRequestCPIInstanceData.c,v 1.2 2004/04/02 12:31:57 hartmutkaiser Exp $
00006 *
00007 * Copyright (C) Hartmut Kaiser
00008 * This file is part of the GAT Engine.
00009 * Contributed by Hartmut Kaiser <hartmutkaiser [at] t-online [dot] de>.
00010 *
00011 * Use, modification and distribution is subject to the Gridlab Software
00012 * License. (See accompanying file GLlicense.txt or copy at
00013 * http://www.gridlab.org/GLlicense.txt)
00014 */
00015
00016 #include <string.h>
00017
00018 #include "GATCPI.h"
00019 #include "GATRequestCPIInstanceData.h"
00020
00021 /* instance data */
00022
00023 /** GATRequestCPIInstance_Data_Create
00024 *
00025 * The function GATRequestCPIInstance_Data_Create creates a new
00026 * instance of the internal CPI instance data.
00027 *
00028 * @return The pointer to the newly created and initialised data structure.
00029 */
00030 GATRequestCPIInstance_Data *
00031GATRequestCPIInstance_Data_Create(void)
00032 {
00033 GATRequestCPIInstance_Data *retval =
00034 (GATRequestCPIInstance_Data *)malloc(sizeof(structGATRequestCPIInstance_Data));
00035
00036 if (NULL != retval)
00037 {
00038 memset(retval, 0, sizeof(structGATRequestCPIInstance_Data));
00039 }
00040 return retval;
00041 }
00042
00043 /** GATRequestCPIInstance_Data_Destroy
00044 *
00045 * The function GATRequestCPIInstance_Data_Destroy is called to
00046 * free all the memory associated with the given instance data item.
00047 *
00048 * @param instance_data The pointer to a variable holding the old instance
00049 * data item, this is set to zero on exit.
00050 */
00051 void00052GATRequestCPIInstance_Data_Destroy(
00053 GATRequestCPIInstance_Data **instance_data)
00054 {
00055 if (NULL != instance_data && NULL != *instance_data)
00056 {
00057 free(*instance_data);
00058 instance_data = NULL;
00059 }
00060 }
00061
00062 /** GATRequestCPIInstance_Data_Clone
00063 *
00064 * The function GATRequestCPIInstance_Data_Clone is called to make
00065 * a copy of the given instance data item.
00066 *
00067 * @param instance_data The instance data item to copy.
00068 * @param new_instance_Data The pointer to a variable, which receives the
00069 * newly created copy of the instance data item.
00070 *
00071 * @return An error code.
00072 */
00073 GATResult00074GATRequestCPIInstance_Data_Clone(
00075 GATRequestCPIInstance_Dataconst *instance_data,
00076 GATRequestCPIInstance_Data **new_instance_data)
00077 {
00078 GATResult retval = GAT_INVALID_PARAMETER;
00079 if (NULL != new_instance_data)
00080 {
00081 GATRequestCPIInstance_Data *new_data =
00082 (GATRequestCPIInstance_Data *)malloc(sizeof(structGATRequestCPIInstance_Data));
00083
00084 if (NULL != new_data)
00085 {
00086 new_data->start_time = instance_data->start_time;
00087 *new_instance_data = new_data;
00088 retval = GAT_SUCCESS;
00089 }
00090 else
00091 {
00092 retval = GAT_MEMORYFAILURE;
00093 }
00094 }
00095 return retval;
00096 }
00097
00098 /** GATRequestCPIInstance_Data_Equals
00099 *
00100 * The function GATRequestCPIInstance_Data_Equals is called,
00101 * whenever the engine needs to compare for equality two different instance
00102 * data items.
00103 *
00104 * @param lhs The first instance data item to compare.
00105 * @param rhs The second instance data item to compare.
00106 * @param isequal The pointer to a variable, which receives the result of the
00107 * compare operation.
00108 *
00109 * @result An error code.
00110 */
00111 GATResult00112GATRequestCPIInstance_Data_Equals(
00113 GATRequestCPIInstance_Dataconst *lhs,
00114 GATRequestCPIInstance_Dataconst *rhs, GATBool *isequal)
00115 {
00116 *isequal = (lhs->start_time == rhs->start_time) ? GATTrue : GATFalse;
00117 returnGAT_SUCCESS;
00118 }
00119