MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RTOp_obj_value_value_vtbl.c
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
6 // Copyright (2003) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
45 #include "RTOp_obj_free_free.h"
46 
47 #include <stdlib.h>
48 
49 /* Local function definitions */
50 
52  const struct RTOp_obj_type_vtbl_t* vtbl
53  ,const void* instance_data
54  ,int* num_values
55  ,int* num_indexes
56  ,int* num_chars
57  )
58 {
59 #ifdef RTOp_DEBUG
60  assert(num_values);
61  assert(num_indexes);
62  assert(num_chars);
63 #endif
64  *num_values = 2;
65  *num_indexes = 0;
66  *num_chars = 0;
67  return 0;
68 }
69 
70 static int obj_create( const struct RTOp_obj_type_vtbl_t* vtbl, const void* instance_data, void** obj )
71 {
72  struct RTOp_value_value_type* vi_obj;
73  const int mem_size = sizeof(struct RTOp_value_value_type);
74 #ifdef RTOp_DEBUG
75  assert(obj);
76 #endif
77  *obj = malloc( mem_size );
78  vi_obj = (struct RTOp_value_value_type*)*obj;
79  vi_obj->value1 = 0.0;
80  vi_obj->value2 = 0.0;
81  return 0;
82 }
83 
84 static int obj_reinit( const struct RTOp_obj_type_vtbl_t* vtbl, const void* instance_data, void* obj )
85 {
86  struct RTOp_value_value_type* vi_obj;
87 #ifdef RTOp_DEBUG
88  assert(obj);
89 #endif
90  vi_obj = (struct RTOp_value_value_type*)obj;
91  vi_obj->value1 = 0.0;
92  vi_obj->value2 = 0.0;
93  return 0;
94 }
95 
96 static int extract_state(
97  const struct RTOp_obj_type_vtbl_t* vtbl
98  ,const void * instance_data
99  ,void * obj
100  ,int num_values
101  ,RTOp_value_type value_data[]
102  ,int num_indexes
103  ,RTOp_index_type index_data[]
104  ,int num_chars
105  ,RTOp_char_type char_data[]
106  )
107 {
108  struct RTOp_value_value_type* vi_obj;
109 #ifdef RTOp_DEBUG
110  assert( obj );
111  assert( num_values == 2 );
112  assert( num_indexes == 0 );
113  assert( num_chars == 0 );
114 #endif
115  vi_obj = (struct RTOp_value_value_type*)obj;
116  value_data[0] = vi_obj->value1;
117  value_data[1] = vi_obj->value2;
118  return 0;
119 }
120 
121 static int load_state(
122  const struct RTOp_obj_type_vtbl_t* vtbl
123  ,const void * instance_data
124  ,int num_values
125  ,const RTOp_value_type value_data[]
126  ,int num_indexes
127  ,const RTOp_index_type index_data[]
128  ,int num_chars
129  ,const RTOp_char_type char_data[]
130  ,void ** obj
131  )
132 {
133  struct RTOp_value_value_type* vi_obj;
134 #ifdef RTOp_DEBUG
135  assert( obj );
136  assert( num_values == 2 );
137  assert( num_indexes == 0 );
138  assert( num_chars == 0 );
139 #endif
140  if(*obj == NULL)
141  obj_create(vtbl,instance_data,obj);
142  vi_obj = (struct RTOp_value_value_type*)*obj;
143  vi_obj->value1 = value_data[0];
144  vi_obj->value2 = value_data[1];
145  return 0;
146 }
147 
149 {
151  ,obj_create
152  ,obj_reinit
155  ,load_state
156 };
static int extract_state(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void *obj, int num_values, RTOp_value_type value_data[], int num_indexes, RTOp_index_type index_data[], int num_chars, RTOp_char_type char_data[])
double RTOp_value_type
Definition: RTOp.h:69
const struct RTOp_obj_type_vtbl_t RTOp_obj_value_value_vtbl
char RTOp_char_type
Definition: RTOp.h:70
static int load_state(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, int num_values, const RTOp_value_type value_data[], int num_indexes, const RTOp_index_type index_data[], int num_chars, const RTOp_char_type char_data[], void **obj)
static int obj_create(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void **obj)
static int get_obj_type_num_entries(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, int *num_values, int *num_indexes, int *num_chars)
int RTOp_obj_free_free(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void **obj)
static int obj_reinit(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void *obj)
Teuchos_Ordinal RTOp_index_type
Definition: RTOp.h:68