RTOp_obj_value_index_vtbl.c

Go to the documentation of this file.
00001 /*
00002 // @HEADER
00003 // ***********************************************************************
00004 // 
00005 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00006 //                  Copyright (2003) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 // @HEADER
00029 */
00030 
00031 #include "RTOp_obj_value_index_vtbl.h"
00032 #include "RTOp_obj_free_free.h"
00033 
00034 /* Local function definitions */
00035 
00036 static int get_obj_type_num_entries(
00037   const struct RTOp_obj_type_vtbl_t* vtbl
00038   ,const void* instance_data
00039   ,int* num_values
00040   ,int* num_indexes
00041   ,int* num_chars
00042   )
00043 {
00044 #ifdef RTOp_DEBUG
00045   assert(num_values);
00046   assert(num_indexes);
00047   assert(num_chars);
00048 #endif
00049   *num_values  = 1;
00050   *num_indexes = 1;
00051   *num_chars   = 0;
00052   return 0;
00053 }
00054 
00055 static int obj_create( const struct RTOp_obj_type_vtbl_t* vtbl, const void* instance_data, void** obj )
00056 {
00057   struct RTOp_value_index_type* vi_obj;
00058   const int mem_size = sizeof(struct RTOp_value_index_type);
00059 #ifdef RTOp_DEBUG
00060   assert(obj);
00061 #endif
00062   *obj = malloc( mem_size );
00063   vi_obj = (struct RTOp_value_index_type*)*obj;
00064   vi_obj->value = 0.0;
00065   vi_obj->index = 0;
00066   return 0;
00067 }
00068 
00069 static int obj_reinit( const struct RTOp_obj_type_vtbl_t* vtbl, const void* instance_data, void* obj )
00070 {
00071   struct RTOp_value_index_type* vi_obj;
00072 #ifdef RTOp_DEBUG
00073   assert(obj);
00074 #endif
00075   vi_obj = (struct RTOp_value_index_type*)obj;
00076   vi_obj->value = 0.0;
00077   vi_obj->index = 0;
00078   return 0;
00079 }
00080 
00081 static int extract_state(
00082   const struct RTOp_obj_type_vtbl_t* vtbl
00083   ,const void *       instance_data
00084   ,void *             obj
00085   ,int                num_values
00086   ,RTOp_value_type    value_data[]
00087   ,int                num_indexes
00088   ,RTOp_index_type    index_data[]
00089   ,int                num_chars
00090   ,RTOp_char_type     char_data[]
00091   )
00092 {
00093   struct RTOp_value_index_type* vi_obj;
00094 #ifdef RTOp_DEBUG
00095   assert( obj );
00096   assert( num_values  == 1 );
00097   assert( num_indexes == 1 );
00098   assert( num_chars   == 0 );
00099 #endif
00100   vi_obj = (struct RTOp_value_index_type*)obj;
00101   value_data[0] = vi_obj->value;
00102   index_data[0] = vi_obj->index;
00103   return 0;
00104 }
00105 
00106 static int load_state(
00107   const struct RTOp_obj_type_vtbl_t* vtbl
00108   ,const void *            instance_data
00109   ,int                     num_values
00110   ,const RTOp_value_type   value_data[]
00111   ,int                     num_indexes
00112   ,const RTOp_index_type   index_data[]
00113   ,int                     num_chars
00114   ,const RTOp_char_type    char_data[]
00115   ,void **                 obj
00116   )
00117 {
00118   struct RTOp_value_index_type* vi_obj;
00119 #ifdef RTOp_DEBUG
00120   assert( obj );
00121   assert( num_values  == 1 );
00122   assert( num_indexes == 1 );
00123   assert( num_chars   == 0 );
00124 #endif
00125   if(*obj == NULL)
00126     obj_create(vtbl,instance_data,obj);
00127   vi_obj = (struct RTOp_value_index_type*)*obj;
00128   vi_obj->value = value_data[0];
00129   vi_obj->index = index_data[0];
00130   return 0;
00131 }
00132 
00133 const struct RTOp_obj_type_vtbl_t   RTOp_obj_value_index_vtbl =
00134 {
00135    get_obj_type_num_entries
00136   ,obj_create
00137   ,obj_reinit
00138   ,RTOp_obj_free_free
00139   ,extract_state
00140   ,load_state
00141 };

Generated on Thu Sep 18 12:35:19 2008 for MOOCHO (Single Doxygen Collection) by doxygen 1.3.9.1