CUBRID Engine  latest
object_accessor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * object_accessor.h - Definitions for the object manager
22  *
23  */
24 
25 #ifndef _OBJECT_ACCESSOR_H_
26 #define _OBJECT_ACCESSOR_H_
27 
28 #ident "$Id$"
29 
30 #if defined (SERVER_MODE)
31 #error Does not belong to server module
32 #endif /* defined (SERVER_MODE) */
33 
34 #include <stdarg.h>
35 
36 #include "area_alloc.h"
37 #include "class_object.h"
38 #include "object_fetch.h"
39 #include "object_template.h"
40 #include "work_space.h"
41 
42 /*
43  *
44  * OBJECT HEADER FIELDS
45  *
46  *
47  */
48 
49 /*
50  * These are the header fields that are present in every object.
51  * Note that the first field in the header must be able to be overlayed
52  * by the WS_OBJECT_HEADER structure. This is so the workspace manager
53  * can get to the CHN without knowing anything about the details of the
54  * object structure.
55  */
56 
57 #define OBJ_HEADER_CHN_OFFSET 0
58 #define OBJ_HEADER_BOUND_BITS_OFFSET 4
59 
60 #define OBJ_HEADER_FIXED_SIZE 4
61 
62 #define OBJ_HEADER_SIZE(nvars) \
63  OBJ_HEADER_FIXED_SIZE + OR_BOUND_BIT_BYTES(nvars)
64 
65 /*
66  * Try to define these in terms of the OR bound bit macros if possible.
67  * When the time comes where we have to support heterogeneous networks,
68  * this may no longer be an option. We're lucky now in that the
69  * disk representation for these is exactly the same as the memory
70  * representation.
71  *
72  */
73 
74 #define OBJ_BOUND_BIT_WORDS OR_BOUND_BIT_WORDS
75 #define OBJ_BOUND_BIT_BYTES OR_BOUND_BIT_BYTES
76 
77 #define OBJ_GET_BOUND_BITS(obj) \
78  ((char *)(obj) + OBJ_HEADER_BOUND_BITS_OFFSET)
79 
80 #define OBJ_GET_BOUND_BIT(obj, element) \
81  OR_GET_BOUND_BIT(OBJ_GET_BOUND_BITS(obj), element)
82 
83 #define OBJ_SET_BOUND_BIT(obj, element) \
84  OR_ENABLE_BOUND_BIT(OBJ_GET_BOUND_BITS(obj), element)
85 
86 #define OBJ_CLEAR_BOUND_BIT(obj, element) \
87  OR_CLEAR_BOUND_BIT(OBJ_GET_BOUND_BITS(obj), element)
88 
89 /*
90  *
91  * OBJECT ACCESS FUNCTIONS
92  *
93  *
94  */
95 
96 /* Creation and deletion */
97 extern MOP obj_create (MOP classop);
98 extern MOP obj_create_by_name (const char *name);
99 extern MOP obj_copy (MOP op);
100 extern int obj_delete (MOP op);
101 
102 /* Attribute access functions */
103 
104 extern int obj_get (MOP op, const char *name, DB_VALUE * value);
105 
106 extern int obj_get_att (MOP op, SM_CLASS * class_, SM_ATTRIBUTE * att, DB_VALUE * value);
107 
108 extern int obj_get_shared (MOP op, const char *name, DB_VALUE * value);
109 extern int obj_get_path (DB_OBJECT * object, const char *attpath, DB_VALUE * value);
110 extern int obj_set (MOP op, const char *name, DB_VALUE * value);
111 
112 extern int obj_set_shared (MOP op, const char *name, DB_VALUE * value);
113 extern int obj_assign_value (MOP op, SM_ATTRIBUTE * att, char *mem, DB_VALUE * value);
114 
115 /* Attribute descriptor interface */
116 extern int obj_desc_set (MOP op, SM_DESCRIPTOR * desc, DB_VALUE * value);
117 extern int obj_desc_get (MOP op, SM_DESCRIPTOR * desc, DB_VALUE * value);
118 
119 /* Method invocation */
120 extern int obj_send_va (MOP obj, const char *name, DB_VALUE * returnval, va_list args);
121 
122 extern int obj_send_list (MOP obj, const char *name, DB_VALUE * returnval, DB_VALUE_LIST * arglist);
123 extern int obj_send_array (MOP obj, const char *name, DB_VALUE * returnval, DB_VALUE ** argarray);
124 /* Method descriptor interface */
125 
126 extern int obj_desc_send_va (MOP obj, SM_DESCRIPTOR * desc, DB_VALUE * returnval, va_list args);
127 extern int obj_desc_send_list (MOP obj, SM_DESCRIPTOR * desc, DB_VALUE * returnval, DB_VALUE_LIST * arglist);
128 extern int obj_desc_send_array (MOP obj, SM_DESCRIPTOR * desc, DB_VALUE * returnval, DB_VALUE ** argarray);
129 extern int obj_desc_send_array_quick (MOP obj, SM_DESCRIPTOR * desc, DB_VALUE * returnval, int nargs,
130  DB_VALUE ** argarray);
131 #if defined(ENABLE_UNUSED_FUNCTION)
132 extern int obj_send_stack (MOP obj, const char *name, DB_VALUE * returnval, ...);
133 extern int obj_desc_send_stack (MOP obj, SM_DESCRIPTOR * desc, DB_VALUE * returnval, ...);
134 /* backward compatibility, should use obj_send_list() */
135 extern int obj_send (MOP obj, const char *name, DB_VALUE * returnval, DB_VALUE_LIST * arglist);
136 extern int obj_isclass (MOP obj);
137 #endif
138 
139 /* Tests */
140 
141 extern int obj_isinstance (MOP obj);
142 extern int obj_is_instance_of (MOP obj, MOP class_mop);
143 
144 /* Misc operations */
145 extern int obj_lock (MOP op, int for_write);
146 extern int obj_class_lock (MOP op, int for_write);
147 extern int obj_inst_lock (MOP op, int for_write);
148 extern MOP obj_find_unique (MOP op, const char *attname, DB_VALUE * value, AU_FETCHMODE fetchmode);
149 extern MOP obj_find_object_by_pkey (MOP classop, DB_VALUE * key, AU_FETCHMODE fetchmode);
150 extern MOP obj_repl_find_object_by_pkey (MOP classop, DB_VALUE * key, AU_FETCHMODE fetchmode);
151 
152 extern MOP obj_desc_find_unique (MOP op, SM_DESCRIPTOR * desc, DB_VALUE * value, AU_FETCHMODE fetchmode);
153 
154 /* Internal support for specific modules */
155 
156 /* called by Workspace */
157 extern void obj_free_memory (SM_CLASS * class_, MOBJ obj);
158 
159 /* attribute locator for set handler */
160 extern int obj_locate_attribute (MOP op, int attid, int for_write, char **memp, SM_ATTRIBUTE ** attp);
161 extern char *obj_alloc (SM_CLASS * class_, int bound_bit_status);
162 
163 
164 extern MOP obj_find_primary_key (MOP op, const DB_VALUE ** values, int size, AU_FETCHMODE fetchmode);
165 /*
166  * extern MOP obj_find_object_by_pkey(MOP op, SM_CLASS_CONSTRAINT *pk, const DB_VALUE *key);
167  *
168  */
169 
170 extern MOP obj_find_multi_attr (MOP op, int size, const char *attr_names[], const DB_VALUE * values[],
171  AU_FETCHMODE fetchmode);
172 extern MOP obj_find_multi_desc (MOP op, int size, const SM_DESCRIPTOR * desc[], const DB_VALUE * values[],
173  AU_FETCHMODE fetchmode);
174 
175 extern int obj_get_value (MOP op, SM_ATTRIBUTE * att, void *mem, DB_VALUE * source, DB_VALUE * dest);
176 #if defined(ENABLE_UNUSED_FUNCTION)
177 extern int obj_find_unique_id (MOP op, const char *att_name, BTID * id_array, int id_array_size, int *total_ids);
178 #endif
179 
180 #endif /* _OBJECT_ACCESSOR_H_ */
MOP obj_find_multi_attr(MOP op, int size, const char *attr_names[], const DB_VALUE *values[], AU_FETCHMODE fetchmode)
MOP obj_find_object_by_pkey(MOP classop, DB_VALUE *key, AU_FETCHMODE fetchmode)
enum au_fetchmode AU_FETCHMODE
char * MOBJ
Definition: work_space.h:174
MOP obj_find_primary_key(MOP op, const DB_VALUE **values, int size, AU_FETCHMODE fetchmode)
MOP obj_create(MOP classop)
int obj_send_va(MOP obj, const char *name, DB_VALUE *returnval, va_list args)
int obj_inst_lock(MOP op, int for_write)
MOP obj_desc_find_unique(MOP op, SM_DESCRIPTOR *desc, DB_VALUE *value, AU_FETCHMODE fetchmode)
int obj_set_shared(MOP op, const char *name, DB_VALUE *value)
int obj_delete(MOP op)
int obj_class_lock(MOP op, int for_write)
int obj_assign_value(MOP op, SM_ATTRIBUTE *att, char *mem, DB_VALUE *value)
int obj_desc_send_list(MOP obj, SM_DESCRIPTOR *desc, DB_VALUE *returnval, DB_VALUE_LIST *arglist)
MOP obj_find_unique(MOP op, const char *attname, DB_VALUE *value, AU_FETCHMODE fetchmode)
int obj_send_array(MOP obj, const char *name, DB_VALUE *returnval, DB_VALUE **argarray)
MOP obj_create_by_name(const char *name)
int obj_set(MOP op, const char *name, DB_VALUE *value)
int obj_is_instance_of(MOP obj, MOP class_mop)
int obj_get(MOP op, const char *name, DB_VALUE *value)
char * obj_alloc(SM_CLASS *class_, int bound_bit_status)
void obj_free_memory(SM_CLASS *class_, MOBJ obj)
int obj_get_att(MOP op, SM_CLASS *class_, SM_ATTRIBUTE *att, DB_VALUE *value)
int obj_get_value(MOP op, SM_ATTRIBUTE *att, void *mem, DB_VALUE *source, DB_VALUE *dest)
int obj_send_list(MOP obj, const char *name, DB_VALUE *returnval, DB_VALUE_LIST *arglist)
int obj_desc_get(MOP op, SM_DESCRIPTOR *desc, DB_VALUE *value)
MOP obj_repl_find_object_by_pkey(MOP classop, DB_VALUE *key, AU_FETCHMODE fetchmode)
int obj_desc_set(MOP op, SM_DESCRIPTOR *desc, DB_VALUE *value)
int obj_get_path(DB_OBJECT *object, const char *attpath, DB_VALUE *value)
int obj_desc_send_array_quick(MOP obj, SM_DESCRIPTOR *desc, DB_VALUE *returnval, int nargs, DB_VALUE **argarray)
int obj_lock(MOP op, int for_write)
int obj_locate_attribute(MOP op, int attid, int for_write, char **memp, SM_ATTRIBUTE **attp)
MOP obj_copy(MOP op)
int obj_desc_send_array(MOP obj, SM_DESCRIPTOR *desc, DB_VALUE *returnval, DB_VALUE **argarray)
int obj_desc_send_va(MOP obj, SM_DESCRIPTOR *desc, DB_VALUE *returnval, va_list args)
int obj_isinstance(MOP obj)
int obj_get_shared(MOP op, const char *name, DB_VALUE *value)
MOP obj_find_multi_desc(MOP op, int size, const SM_DESCRIPTOR *desc[], const DB_VALUE *values[], AU_FETCHMODE fetchmode)