summaryrefslogtreecommitdiff
path: root/src/objclass
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@hq.newdream.net>2009-05-15 15:18:25 -0700
committerYehuda Sadeh <yehuda@hq.newdream.net>2009-05-15 15:18:25 -0700
commit2ff889c6a81036b3d5868f9a5098b7d6457d1e3c (patch)
treef42376bdd88d0a17a20ce52de0f942ea2ca49449 /src/objclass
parent9ec43267a6a52a136b70bd8fbdc0a1160976c742 (diff)
downloadceph-2ff889c6a81036b3d5868f9a5098b7d6457d1e3c.tar.gz
class: some api implementation
Diffstat (limited to 'src/objclass')
-rw-r--r--src/objclass/class_api.cc72
-rw-r--r--src/objclass/objclass.h19
2 files changed, 85 insertions, 6 deletions
diff --git a/src/objclass/class_api.cc b/src/objclass/class_api.cc
new file mode 100644
index 00000000000..fbf8c848c30
--- /dev/null
+++ b/src/objclass/class_api.cc
@@ -0,0 +1,72 @@
+
+#include "config.h"
+
+#include "objclass/objclass.h"
+#include "osd/OSD.h"
+
+#include "common/ClassHandler.h"
+
+extern OSD *osd;
+
+void cls_initialize(OSD *_osd)
+{
+ osd = _osd;
+}
+
+void cls_finalize()
+{
+ osd = NULL;
+}
+
+
+extern "C" void *cls_alloc(size_t size)
+{
+ return malloc(size);
+}
+
+extern "C" void cls_free(void *p)
+{
+ free(p);
+}
+int cls_register(const char *name, cls_handle_t *handle)
+{
+ ClassHandler::ClassData *cd;
+
+ cd = osd->class_handler->register_class(name);
+
+ *handle = (cls_handle_t)cd;
+
+ return (cd != NULL);
+}
+int cls_unregister(cls_handle_t handle)
+{
+ ClassHandler::ClassData *cd;
+ cd = (ClassHandler::ClassData *)handle;
+
+ osd->class_handler->unregister_class(cd);
+}
+
+int cls_register_method(cls_handle_t hclass, const char *method,
+ cls_method_call_t class_call, cls_method_handle_t *handle)
+{
+ ClassHandler::ClassData *cd;
+ cls_method_handle_t hmethod;
+
+ cd = (ClassHandler::ClassData *)hclass;
+
+ hmethod = (cls_method_handle_t)cd->register_method(method, class_call);
+
+ if (handle)
+ *handle = hmethod;
+
+ return (hmethod != NULL);
+}
+
+int cls_unregister_method(cls_method_handle_t handle)
+{
+ ClassHandler::ClassMethod *method;
+ method->unregister();
+
+ return 1;
+}
+
diff --git a/src/objclass/objclass.h b/src/objclass/objclass.h
index f6f1bd4f7a9..ac4b5542153 100644
--- a/src/objclass/objclass.h
+++ b/src/objclass/objclass.h
@@ -5,18 +5,25 @@
extern "C" {
#endif
+typedef void *cls_handle_t;
typedef void *cls_method_handle_t;
-typedef int (*cls_method_call_t)(struct ceph_osd_op *op,
- char **indata, int datalen,
+typedef int (*cls_method_call_t)(char **indata, int datalen,
char **outdata, int *outdatalen);
-/* class log */
+/* class utils */
extern int cls_log(const char *format, ...);
+extern void *cls_alloc(size_t size);
+extern void cls_free(void *p);
/* class registration api */
-extern int cls_register(const char *name, const char *method,
- cls_method_call_t class_call, cls_method_handle_t handle);
-extern int cls_unregister(cls_method_handle_t handle);
+extern int cls_register(const char *name, cls_handle_t *handle);
+extern int cls_unregister(cls_handle_t);
+
+extern int cls_register_method(const char *method,
+ cls_method_call_t class_call, cls_method_handle_t *handle);
+extern int cls_unregister_method(cls_method_handle_t handle);
+
+
/* triggers */
#define OBJ_READ 0x1