]> git.proxmox.com Git - ceph.git/blob - ceph/src/include/rados/objclass.h
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / include / rados / objclass.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_OBJCLASS_OBJCLASS_PUBLIC_H
5 #define CEPH_OBJCLASS_OBJCLASS_PUBLIC_H
6
7 #ifdef __cplusplus
8
9 #include "buffer.h"
10
11 extern "C" {
12 #endif
13
14 #define CEPH_CLS_API [[gnu::visibility("default")]]
15
16 #define CLS_VER(maj,min) \
17 int __cls_ver__## maj ## _ ##min = 0; \
18 int __cls_ver_maj = maj; \
19 int __cls_ver_min = min;
20
21 #define CLS_NAME(name) \
22 int __cls_name__## name = 0; \
23 const char *__cls_name = #name;
24
25 #define CLS_INIT(name) \
26 CEPH_CLS_API void __cls_init()
27
28 #define CLS_METHOD_RD 0x1 /// method executes read operations
29 #define CLS_METHOD_WR 0x2 /// method executes write operations
30 #define CLS_METHOD_PROMOTE 0x8 /// method cannot be proxied to base tier
31
32 #define CLS_LOG(level, fmt, ...) \
33 cls_log(level, "<cls> %s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
34 #define CLS_ERR(fmt, ...) CLS_LOG(0, fmt, ##__VA_ARGS__)
35
36 /**
37 * Initialize a class.
38 */
39 void __cls_init();
40
41 /**
42 * @typdef cls_handle_t
43 *
44 * A handle for interacting with the object class.
45 */
46 typedef void *cls_handle_t;
47
48 /**
49 * @typedef cls_method_handle_t
50 *
51 * A handle for interacting with the method of the object class.
52 */
53 typedef void *cls_method_handle_t;
54
55 /**
56 * @typedef cls_method_context_t
57 *
58 * A context for the method of the object class.
59 */
60 typedef void* cls_method_context_t;
61
62 /*class utils*/
63 extern int cls_log(int level, const char *format, ...)
64 __attribute__((__format__(printf, 2, 3)));
65
66 /* class registration api */
67 extern int cls_register(const char *name, cls_handle_t *handle);
68
69 #ifdef __cplusplus
70 }
71
72 /**
73 * @typedef cls_method_cxx_call_t
74 *
75 */
76 typedef int (*cls_method_cxx_call_t)(cls_method_context_t ctx,
77 class ceph::buffer::list *inbl, class ceph::buffer::list *outbl);
78
79 /**
80 * Register a method.
81 *
82 * @param hclass
83 * @param method
84 * @param flags
85 * @param class_call
86 * @param handle
87 */
88 extern int cls_register_cxx_method(cls_handle_t hclass, const char *method, int flags,
89 cls_method_cxx_call_t class_call, cls_method_handle_t *handle);
90
91 /**
92 * Create an object.
93 *
94 * @param hctx
95 * @param exclusive
96 */
97 extern int cls_cxx_create(cls_method_context_t hctx, bool exclusive);
98
99 /**
100 * Remove an object.
101 *
102 * @param hctx
103 */
104 extern int cls_cxx_remove(cls_method_context_t hctx);
105
106 /**
107 * Check on the status of an object.
108 *
109 * @param hctx
110 * @param size
111 * @param mtime
112 */
113 extern int cls_cxx_stat(cls_method_context_t hctx, uint64_t *size, time_t *mtime);
114
115 /**
116 * Read contents of an object.
117 *
118 * @param hctx
119 * @param ofs
120 * @param len
121 * @param bl
122 */
123 extern int cls_cxx_read(cls_method_context_t hctx, int ofs, int len, ceph::bufferlist *bl);
124
125 /**
126 * Write to the object.
127 *
128 * @param hctx
129 * @param ofs
130 * @param len
131 * @param bl
132 */
133 extern int cls_cxx_write(cls_method_context_t hctx, int ofs, int len, ceph::bufferlist *bl);
134
135 /**
136 * Get xattr of the object.
137 *
138 * @param hctx
139 * @param name
140 * @param outbl
141 */
142 extern int cls_cxx_getxattr(cls_method_context_t hctx, const char *name,
143 ceph::bufferlist *outbl);
144
145 /**
146 * Set xattr of the object.
147 *
148 * @param hctx
149 * @param name
150 * @param inbl
151 */
152 extern int cls_cxx_setxattr(cls_method_context_t hctx, const char *name,
153 ceph::bufferlist *inbl);
154
155 /**
156 * Get value corresponding to a key from the map.
157 *
158 * @param hctx
159 * @param key
160 * @param outbl
161 */
162 extern int cls_cxx_map_get_val(cls_method_context_t hctx,
163 const std::string &key, ceph::bufferlist *outbl);
164
165 /**
166 * Set value corresponding to a key in the map.
167 *
168 * @param hctx
169 * @param key
170 * @param inbl
171 */
172 extern int cls_cxx_map_set_val(cls_method_context_t hctx,
173 const std::string &key, ceph::bufferlist *inbl);
174
175 #endif
176
177 #endif