Loading...
Searching...
No Matches
as_aerospike.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2018 Aerospike, Inc.
3 *
4 * Portions may be licensed to Aerospike, Inc. under one or more contributor
5 * license agreements.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8 * use this file except in compliance with the License. You may obtain a copy of
9 * the License at 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, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17#pragma once
18
19#include <aerospike/as_std.h>
20#include <aerospike/as_types.h>
21#include <aerospike/as_util.h>
22#include <citrusleaf/cf_clock.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/******************************************************************************
29 * TYPES
30 ******************************************************************************/
31
32typedef struct as_aerospike_s as_aerospike;
33typedef struct as_aerospike_hooks_s as_aerospike_hooks;
34
36 void* source;
37 const as_aerospike_hooks* hooks;
39};
40
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 int (*set_context) (const as_aerospike*, const as_rec*, const uint32_t context);
52 int (*get_config) (const as_aerospike*, const as_rec*, const char*);
53};
54
55/******************************************************************************
56 * FUNCTIONS
57 ******************************************************************************/
58
59AS_EXTERN as_aerospike*
60as_aerospike_init(as_aerospike* a, void* source, const as_aerospike_hooks* hooks);
61
62AS_EXTERN as_aerospike*
63as_aerospike_new(void* source, const as_aerospike_hooks* hooks);
64
65AS_EXTERN void
66as_aerospike_destroy(as_aerospike*);
67
68/******************************************************************************
69 * INLINE FUNCTIONS
70 ******************************************************************************/
71
72static inline int
73as_aerospike_rec_create(const as_aerospike* a, const as_rec* r)
74{
75 return as_util_hook(rec_create, 1, a, r);
76}
77
78static inline int
79as_aerospike_rec_update(const as_aerospike* a, const as_rec* r)
80{
81 return as_util_hook(rec_update, 1, a, r);
82}
83
84static inline int
85as_aerospike_rec_exists(const as_aerospike* a, const as_rec* r)
86{
87 return as_util_hook(rec_exists, 1, a, r);
88}
89
90static inline int
91as_aerospike_rec_remove(const as_aerospike* a, const as_rec* r)
92{
93 return as_util_hook(rec_remove, 1, a, r);
94}
95
96static inline int
97as_aerospike_log(const as_aerospike* a, const char* name, const int line, const int lvl, const char* msg)
98{
99 return as_util_hook(log, 1, a, name, line, lvl, msg);
100}
101
102static inline cf_clock
103as_aerospike_get_current_time(const as_aerospike* a)
104{
105 return as_util_hook(get_current_time, 0, a);
106}
107
108static inline int
109as_aerospike_set_context(const as_aerospike* a, const as_rec* r, const uint32_t context)
110{
111 return as_util_hook(set_context, 2, a, r, context);
112}
113
114static inline int
115as_aerospike_get_config(const as_aerospike* a, const as_rec* r, const char* name)
116{
117 return as_util_hook(get_config, 0, a, r, name);
118}
119
120#ifdef __cplusplus
121} // end extern "C"
122#endif
AS_EXTERN as_aerospike * as_aerospike_init(as_aerospike *a, void *source, const as_aerospike_hooks *hooks)
static int as_aerospike_get_config(const as_aerospike *a, const as_rec *r, const char *name)
static int as_aerospike_rec_update(const as_aerospike *a, const as_rec *r)
static int as_aerospike_set_context(const as_aerospike *a, const as_rec *r, const uint32_t context)
static int as_aerospike_rec_exists(const as_aerospike *a, const as_rec *r)
AS_EXTERN void as_aerospike_destroy(as_aerospike *)
static int as_aerospike_log(const as_aerospike *a, const char *name, const int line, const int lvl, const char *msg)
static int as_aerospike_rec_create(const as_aerospike *a, const as_rec *r)
static cf_clock as_aerospike_get_current_time(const as_aerospike *a)
AS_EXTERN as_aerospike * as_aerospike_new(void *source, const as_aerospike_hooks *hooks)
static int as_aerospike_rec_remove(const as_aerospike *a, const as_rec *r)
#define AS_EXTERN
Definition as_std.h:25
#define as_util_hook(hook, default, object,...)
Definition as_util.h:34
int(* set_context)(const as_aerospike *, const as_rec *, const uint32_t context)
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(* get_config)(const as_aerospike *, const as_rec *, const char *)
void(* destroy)(as_aerospike *)
int(* rec_exists)(const as_aerospike *, const as_rec *)
int(* rec_update)(const as_aerospike *, const as_rec *)
int(* log)(const as_aerospike *, const char *, const int, const int, const char *)
const as_aerospike_hooks * hooks