All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
target/Linux-x86_64/include/aerospike/as_aerospike.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2008-2013 by Aerospike.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20  * IN THE SOFTWARE.
21  *****************************************************************************/
22 #pragma once
23 
24 #include <aerospike/as_util.h>
25 #include <aerospike/as_types.h>
26 #include <citrusleaf/cf_clock.h>
27 
28 /******************************************************************************
29  * TYPES
30  ******************************************************************************/
31 
32 typedef struct as_aerospike_s as_aerospike;
33 typedef struct as_aerospike_hooks_s as_aerospike_hooks;
34 
35 struct as_aerospike_s {
36  bool is_rcalloc;
37  void * source;
38  const as_aerospike_hooks * hooks;
39 };
40 
41 struct as_aerospike_hooks_s {
42  void (* destroy)(as_aerospike *);
43 
44  int (* rec_create)(const as_aerospike *, const as_rec *);
45  int (* rec_update)(const as_aerospike *, const as_rec *);
46  int (* rec_remove)(const as_aerospike *, const as_rec *);
47  int (* rec_exists)(const as_aerospike *, const as_rec *);
48 
49  int (*log)(const as_aerospike *, const char *, const int, const int, const char *);
50  cf_clock (* get_current_time)( const as_aerospike * );
51 
52  as_rec *(* create_subrec)(const as_aerospike *, const as_rec *);
53  as_rec *(* open_subrec)(const as_aerospike *, const as_rec *, const char *);
54  int (* update_subrec)(const as_aerospike *, const as_rec *);
55  int (* remove_subrec)(const as_aerospike *, const as_rec *);
56  int (* close_subrec)(const as_aerospike *, const as_rec *);
57 };
58 
59 /******************************************************************************
60  * FUNCTIONS
61  ******************************************************************************/
62 
63 as_aerospike * as_aerospike_init(as_aerospike *a, void *source, const as_aerospike_hooks *hooks);
64 
65 as_aerospike * as_aerospike_new(void *source, const as_aerospike_hooks *hooks);
66 
67 void as_aerospike_destroy(as_aerospike *);
68 
69 /******************************************************************************
70  * INLINE FUNCTIONS
71  ******************************************************************************/
72 
73 static inline int as_aerospike_rec_create(const as_aerospike * a, const as_rec * r)
74 {
75  return as_util_hook(rec_create, 1, a, r);
76 }
77 
78 static inline int as_aerospike_rec_update(const as_aerospike * a, const as_rec * r)
79 {
80  return as_util_hook(rec_update, 1, a, r);
81 }
82 
83 static inline int as_aerospike_rec_exists(const as_aerospike * a, const as_rec * r)
84 {
85  return as_util_hook(rec_exists, 1, a, r);
86 }
87 
88 static inline int as_aerospike_rec_remove(const as_aerospike * a, const as_rec * r)
89 {
90  return as_util_hook(rec_remove, 1, a, r);
91 }
92 
93 static inline int as_aerospike_log(const as_aerospike * a, const char * name, const int line, const int lvl, const char * msg)
94 {
95  return as_util_hook(log, 1, a, name, line, lvl, msg);
96 }
97 
98 static inline cf_clock as_aerospike_get_current_time(const as_aerospike * a )
99 {
100  return as_util_hook(get_current_time, 0, a);
101 }
102 
103 static inline as_rec * as_aerospike_crec_create(const as_aerospike * a, const as_rec * r) {
104  return as_util_hook(create_subrec, NULL, a, r);
105 }
106 
107 static inline int as_aerospike_crec_update(const as_aerospike * a, const as_rec * cr)
108 {
109  return as_util_hook(update_subrec, 1, a, cr);
110 }
111 
112 static inline int as_aerospike_crec_remove(const as_aerospike * a, const as_rec * cr)
113 {
114  return as_util_hook(remove_subrec, 1, a, cr);
115 }
116 
117 static inline as_rec * as_aerospike_crec_open(const as_aerospike * a, const as_rec * r, const char * dig)
118 {
119  return as_util_hook(open_subrec, NULL, a, r, dig);
120 }
121 
122 static inline int as_aerospike_crec_close(const as_aerospike * a, const as_rec * cr)
123 {
124  return as_util_hook(close_subrec, 1, a, cr);
125 }
static int as_aerospike_log(const as_aerospike *a, const char *name, const int line, const int lvl, const char *msg)
int(* remove_subrec)(const as_aerospike *, const as_rec *)
static int as_aerospike_rec_remove(const as_aerospike *a, const as_rec *r)
static as_rec * as_aerospike_crec_open(const as_aerospike *a, const as_rec *r, const char *dig)
const as_aerospike_hooks * hooks
static int as_aerospike_crec_remove(const as_aerospike *a, const as_rec *cr)
static int as_aerospike_rec_exists(const as_aerospike *a, const as_rec *r)
static cf_clock as_aerospike_get_current_time(const as_aerospike *a)
int(* rec_exists)(const as_aerospike *, const as_rec *)
as_aerospike * as_aerospike_new(void *source, const as_aerospike_hooks *hooks)
int(* rec_update)(const as_aerospike *, const as_rec *)
static int as_aerospike_rec_update(const as_aerospike *a, const as_rec *r)
static int as_aerospike_crec_update(const as_aerospike *a, const as_rec *cr)
static int as_aerospike_rec_create(const as_aerospike *a, const as_rec *r)
void as_aerospike_destroy(as_aerospike *)
int(* update_subrec)(const as_aerospike *, const as_rec *)
int(* close_subrec)(const as_aerospike *, const as_rec *)
static int as_aerospike_crec_close(const as_aerospike *a, const as_rec *cr)
static as_rec * as_aerospike_crec_create(const as_aerospike *a, const as_rec *r)
cf_clock(* get_current_time)(const as_aerospike *)
int(* rec_remove)(const as_aerospike *, const as_rec *)
int(* rec_create)(const as_aerospike *, const as_rec *)
int(* log)(const as_aerospike *, const char *, const int, const int, const char *)
as_aerospike * as_aerospike_init(as_aerospike *a, void *source, const as_aerospike_hooks *hooks)
#define as_util_hook(hook, default, object, args...)