CUBRID Engine  latest
api_handle.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  * api_handle.h -
21  */
22 
23 #ifndef _API_HANDLE_H_
24 #define _API_HANDLE_H_
25 
26 #include "config.h"
27 
28 typedef UINT64 BIND_HANDLE;
30 typedef struct bh_bind_s BH_BIND;
31 typedef void (*bh_destroyf) (BH_BIND * bind);
32 typedef int (*bh_mapf) (BH_INTERFACE * ifs, BH_BIND * bind, void *arg);
33 typedef struct bh_provider_s bh_provider;
34 
35 typedef enum
36 {
40  BH_ROOT_TYPE_EXTENDIBLE_HASH = 3, /* not implemented */
41  BH_ROOT_TYPE_RB_TREE = 4 /* not implemented */
42 } BH_ROOT_TYPE;
43 
44 /*
45  * basic bind structure corresponding a handle.
46  * user struct should extend (first member) this structure
47  */
48 struct bh_bind_s
49 {
50  bh_destroyf dtor; /* user supplied */
51  void *bptr; /* back pointer. DO NOT TOUCH THIS */
52 };
53 
54 /*
55  * abstract structure that provides functionality related with
56  * handle management.
57  */
59 {
60  int (*alloc_handle) (BH_INTERFACE * ifs, BH_BIND * bind, BIND_HANDLE * bh);
61  int (*destroy_handle) (BH_INTERFACE * ifs, BIND_HANDLE bh);
62  int (*lookup) (BH_INTERFACE * ifs, BIND_HANDLE bh, BH_BIND ** bind);
63  int (*bind_to_handle) (BH_INTERFACE * ifs, BH_BIND * bind, BIND_HANDLE * bh);
64  int (*bind_get_parent) (BH_INTERFACE * ifs, BH_BIND * bind, BH_BIND ** pbind);
65  int (*bind_prune) (BH_INTERFACE * ifs, BH_BIND * bind);
66  int (*bind_graft) (BH_INTERFACE * ifs, BH_BIND * bind, BH_BIND * on_bind);
67  int (*bind_get_first_child) (BH_INTERFACE * ifs, BH_BIND * bind, BH_BIND ** pchild);
68  int (*bind_get_next_sibling) (BH_INTERFACE * ifs, BH_BIND * bind, BH_BIND ** psibling);
69  int (*bind_map) (BH_INTERFACE * ifs, BH_BIND * bind, bh_mapf mf, void *arg);
70  void (*destroy) (BH_INTERFACE * ifs);
71 };
72 
73 
74 /*
75  * next handle value provider
76  */
78 {
79  int (*next_handle) (bh_provider * p, BIND_HANDLE * rv);
80 };
81 
82 /*
83  * Exported functions.
84  *
85  * A user first acquire root id using bh_root_acquire() and get
86  * BH_INTERFACE by calling bh_root_lock().
87  * BH_INTERFACE is MT safe until the root id is unlocked by calling
88  * bh_root_unlock()
89  */
90 extern int bh_root_acquire (int *rid, BH_ROOT_TYPE rt);
91 extern int bh_root_release (int rid);
92 extern int bh_root_lock (int rid, BH_INTERFACE ** ifs);
93 extern int bh_root_unlock (int rid);
94 extern int bh_get_rid (BIND_HANDLE bh, int *rid);
95 extern int create_handle_context (bh_provider * prov, BH_ROOT_TYPE rt, BH_INTERFACE ** ifs);
96 #endif /* _API_HANDLE_H_ */
int bh_root_release(int rid)
Definition: api_handle.c:871
void(* bh_destroyf)(BH_BIND *bind)
Definition: api_handle.h:31
int(* bh_mapf)(BH_INTERFACE *ifs, BH_BIND *bind, void *arg)
Definition: api_handle.h:32
int create_handle_context(bh_provider *prov, BH_ROOT_TYPE rt, BH_INTERFACE **ifs)
Definition: api_handle.c:967
BH_ROOT_TYPE
Definition: api_handle.h:35
bh_destroyf dtor
Definition: api_handle.h:50
int bh_root_acquire(int *rid, BH_ROOT_TYPE rt)
Definition: api_handle.c:817
static int rv
Definition: area_alloc.c:52
int bh_get_rid(BIND_HANDLE bh, int *rid)
Definition: api_handle.c:802
int bh_root_unlock(int rid)
Definition: api_handle.c:944
void * bptr
Definition: api_handle.h:51
UINT64 BIND_HANDLE
Definition: api_handle.h:28
const char ** p
Definition: dynamic_load.c:945
int bh_root_lock(int rid, BH_INTERFACE **ifs)
Definition: api_handle.c:908