MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RTOp_obj_index_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 
44 #include "RTOp_obj_index_vtbl.h"
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  *num_values = 0;
60  *num_indexes = 1;
61  *num_chars = 0;
62  return 0;
63 }
64 
65 static int obj_create( const struct RTOp_obj_type_vtbl_t* vtbl, const void* instance_data, void** obj )
66 {
67  const int mem_size = sizeof(RTOp_index_type);
68  *obj = malloc( mem_size );
69  *((RTOp_index_type*)*obj) = 0;
70  return 0;
71 }
72 
73 static int obj_reinit( const struct RTOp_obj_type_vtbl_t* vtbl, const void* instance_data, void* obj )
74 {
75  *((RTOp_index_type*)obj) = 0;
76  return 0;
77 }
78 
79 static int extract_state(
80  const struct RTOp_obj_type_vtbl_t* vtbl
81  ,const void * instance_data
82  ,void * obj
83  ,int num_values
84  ,RTOp_value_type value_data[]
85  ,int num_indexes
86  ,RTOp_index_type index_data[]
87  ,int num_chars
88  ,RTOp_char_type char_data[]
89  )
90 {
91  assert(obj);
92  assert( num_values == 0 );
93  assert( num_indexes == 1 );
94  assert( num_chars == 0 );
95  index_data[0] = *((RTOp_index_type*)obj);
96  return 0;
97 }
98 
99 static int load_state(
100  const struct RTOp_obj_type_vtbl_t* vtbl
101  ,const void * instance_data
102  ,int num_values
103  ,const RTOp_value_type value_data[]
104  ,int num_indexes
105  ,const RTOp_index_type index_data[]
106  ,int num_chars
107  ,const RTOp_char_type char_data[]
108  ,void ** obj
109  )
110 {
111  assert(obj);
112  assert( num_values == 0 );
113  assert( num_indexes == 1 );
114  assert( num_chars == 0 );
115  if(*obj == NULL)
116  obj_create(NULL,NULL,obj);
117  *((RTOp_index_type*)*obj) = index_data[0];
118  return 0;
119 }
120 
122 {
124  ,obj_create
125  ,obj_reinit
128  ,load_state
129 };
double RTOp_value_type
Definition: RTOp.h:69
char RTOp_char_type
Definition: RTOp.h:70
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)
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)
const struct RTOp_obj_type_vtbl_t RTOp_obj_index_vtbl
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)
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[])
Teuchos_Ordinal RTOp_index_type
Definition: RTOp.h:68