Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / compressor / compressor_plugin_example.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph distributed storage system
5  *
6  * Copyright (C) 2015 Mirantis, Inc.
7  *
8  * Author: Alyona Kiseleva <akiselyova@mirantis.com>
9  *
10  *  This library is free software; you can redistribute it and/or
11  *  modify it under the terms of the GNU Lesser General Public
12  *  License as published by the Free Software Foundation; either
13  *  version 2.1 of the License, or (at your option) any later version.
14  * 
15  */
16
17 #include <unistd.h>
18
19 #include "ceph_ver.h"
20 #include "compressor/CompressionPlugin.h"
21 #include "compressor_example.h"
22
23 class CompressorPluginExample : public CompressionPlugin {
24 public:
25
26   explicit CompressorPluginExample(CephContext* cct) : CompressionPlugin(cct)
27   {}
28
29   int factory(CompressorRef *cs,
30                       ostream *ss) override
31   {
32     if (compressor == 0) {
33       CompressorExample *interface = new CompressorExample();
34       compressor = CompressorRef(interface);
35     }
36     *cs = compressor;
37     return 0;
38   }
39 };
40
41 // -----------------------------------------------------------------------------
42
43 const char *__ceph_plugin_version()
44 {
45   return CEPH_GIT_NICE_VER;
46 }
47
48 // -----------------------------------------------------------------------------
49
50 int __ceph_plugin_init(CephContext *cct,
51                        const std::string& type,
52                        const std::string& name)
53 {
54   PluginRegistry *instance = cct->get_plugin_registry();
55
56   return instance->add(type, name, new CompressorPluginExample(cct));
57 }