1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_OBJCLASS_OBJCLASS_PUBLIC_H
5 #define CEPH_OBJCLASS_OBJCLASS_PUBLIC_H
14 #ifndef BUILDING_FOR_EMBEDDED
15 #define CLS_VER(maj,min) \
16 int __cls_ver__## maj ## _ ##min = 0; \
17 int __cls_ver_maj = maj; \
18 int __cls_ver_min = min;
20 #define CLS_NAME(name) \
21 int __cls_name__## name = 0; \
22 const char *__cls_name = #name;
23 #define CLS_INIT(name) \
24 void CEPH_CLS_API __cls_init()
26 #define CLS_VER(maj,min)
27 #define CLS_NAME(name)
28 #define CLS_INIT(name) \
29 void CEPH_CLS_API name##_cls_init()
32 #define CLS_METHOD_RD 0x1 /// method executes read operations
33 #define CLS_METHOD_WR 0x2 /// method executes write operations
34 #define CLS_METHOD_PROMOTE 0x8 /// method cannot be proxied to base tier
36 #define CLS_LOG(level, fmt, ...) \
37 cls_log(level, "<cls> %s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
38 #define CLS_ERR(fmt, ...) CLS_LOG(0, fmt, ##__VA_ARGS__)
46 * @typdef cls_handle_t
48 * A handle for interacting with the object class.
50 typedef void *cls_handle_t;
53 * @typedef cls_method_handle_t
55 * A handle for interacting with the method of the object class.
57 typedef void *cls_method_handle_t;
60 * @typedef cls_method_context_t
62 * A context for the method of the object class.
64 typedef void* cls_method_context_t;
67 extern int cls_log(int level, const char *format, ...)
68 __attribute__((__format__(printf, 2, 3)));
70 /* class registration api */
71 extern int cls_register(const char *name, cls_handle_t *handle);
77 * @typedef cls_method_cxx_call_t
80 typedef int (*cls_method_cxx_call_t)(cls_method_context_t ctx,
81 class ceph::buffer::list *inbl, class ceph::buffer::list *outbl);
92 extern int cls_register_cxx_method(cls_handle_t hclass, const char *method, int flags,
93 cls_method_cxx_call_t class_call, cls_method_handle_t *handle);
101 extern int cls_cxx_create(cls_method_context_t hctx, bool exclusive);
108 extern int cls_cxx_remove(cls_method_context_t hctx);
111 * Check on the status of an object.
117 extern int cls_cxx_stat(cls_method_context_t hctx, uint64_t *size, time_t *mtime);
120 * Read contents of an object.
127 extern int cls_cxx_read(cls_method_context_t hctx, int ofs, int len, ceph::bufferlist *bl);
130 * Write to the object.
137 extern int cls_cxx_write(cls_method_context_t hctx, int ofs, int len, ceph::bufferlist *bl);
140 * Get xattr of the object.
146 extern int cls_cxx_getxattr(cls_method_context_t hctx, const char *name,
147 ceph::bufferlist *outbl);
150 * Set xattr of the object.
156 extern int cls_cxx_setxattr(cls_method_context_t hctx, const char *name,
157 ceph::bufferlist *inbl);
160 * Get value corresponding to a key from the map.
166 extern int cls_cxx_map_get_val(cls_method_context_t hctx,
167 const std::string &key, ceph::bufferlist *outbl);
170 * Set value corresponding to a key in the map.
176 extern int cls_cxx_map_set_val(cls_method_context_t hctx,
177 const std::string &key, ceph::bufferlist *inbl);