Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / librados_test_stub / TestClassHandler.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_TEST_CLASS_HANDLER_H
5 #define CEPH_TEST_CLASS_HANDLER_H
6
7 #include "objclass/objclass.h"
8 #include "common/snap_types.h"
9 #include <boost/shared_ptr.hpp>
10 #include <list>
11 #include <map>
12 #include <string>
13
14 namespace librados
15 {
16
17 class TestIoCtxImpl;
18
19 class TestClassHandler {
20 public:
21
22   TestClassHandler();
23   ~TestClassHandler();
24
25   struct MethodContext {
26     ~MethodContext();
27
28     TestIoCtxImpl *io_ctx_impl;
29     std::string oid;
30     SnapContext snapc;
31   };
32   typedef boost::shared_ptr<MethodContext> SharedMethodContext;
33
34   struct Method {
35     cls_method_cxx_call_t class_call;
36   };
37   typedef boost::shared_ptr<Method> SharedMethod;
38   typedef std::map<std::string, SharedMethod> Methods;
39   typedef std::map<std::string, cls_cxx_filter_factory_t> Filters;
40
41   struct Class {
42     Methods methods;
43     Filters filters;
44   };
45   typedef boost::shared_ptr<Class> SharedClass;
46
47   void open_all_classes();
48
49   int create(const std::string &name, cls_handle_t *handle);
50   int create_method(cls_handle_t hclass, const char *method,
51                     cls_method_cxx_call_t class_call,
52                     cls_method_handle_t *handle);
53   cls_method_cxx_call_t get_method(const std::string &cls,
54                                    const std::string &method);
55   SharedMethodContext get_method_context(TestIoCtxImpl *io_ctx_impl,
56                                          const std::string &oid,
57                                          const SnapContext &snapc);
58
59   int create_filter(cls_handle_t hclass, const std::string& filter_name,
60                     cls_cxx_filter_factory_t fn);
61
62 private:
63
64   typedef std::map<std::string, SharedClass> Classes;
65   typedef std::list<void*> ClassHandles;
66
67   Classes m_classes;
68   ClassHandles m_class_handles;
69   Filters m_filters;
70
71   void open_class(const std::string& name, const std::string& path);
72
73 };
74
75 } // namespace librados
76
77 #endif // CEPH_TEST_CLASS_HANDLER_H