]> git.proxmox.com Git - ceph.git/blob - ceph/src/erasure-code/ErasureCodePlugin.h
update sources to v12.1.0
[ceph.git] / ceph / src / erasure-code / ErasureCodePlugin.h
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) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
7 * Copyright (C) 2014 Red Hat <contact@redhat.com>
8 *
9 * Author: Loic Dachary <loic@dachary.org>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 */
17
18 #ifndef CEPH_ERASURE_CODE_PLUGIN_H
19 #define CEPH_ERASURE_CODE_PLUGIN_H
20
21 #include "common/Mutex.h"
22 #include "ErasureCodeInterface.h"
23
24 extern "C" {
25 const char *__erasure_code_version();
26 int __erasure_code_init(char *plugin_name, char *directory);
27 }
28
29 namespace ceph {
30
31 class ErasureCodePlugin {
32 public:
33 void *library;
34
35 ErasureCodePlugin() :
36 library(0) {}
37 virtual ~ErasureCodePlugin() {}
38
39 virtual int factory(const std::string &directory,
40 ErasureCodeProfile &profile,
41 ErasureCodeInterfaceRef *erasure_code,
42 std::ostream *ss) = 0;
43 };
44
45 class ErasureCodePluginRegistry {
46 public:
47 Mutex lock;
48 bool loading;
49 bool disable_dlclose;
50 std::map<std::string,ErasureCodePlugin*> plugins;
51
52 static ErasureCodePluginRegistry singleton;
53
54 ErasureCodePluginRegistry();
55 ~ErasureCodePluginRegistry();
56
57 static ErasureCodePluginRegistry &instance() {
58 return singleton;
59 }
60
61 int factory(const std::string &plugin,
62 const std::string &directory,
63 ErasureCodeProfile &profile,
64 ErasureCodeInterfaceRef *erasure_code,
65 std::ostream *ss);
66
67 int add(const std::string &name, ErasureCodePlugin *plugin);
68 int remove(const std::string &name);
69 ErasureCodePlugin *get(const std::string &name);
70
71 int load(const std::string &plugin_name,
72 const std::string &directory,
73 ErasureCodePlugin **plugin,
74 std::ostream *ss);
75
76 int preload(const std::string &plugins,
77 const std::string &directory,
78 std::ostream *ss);
79 };
80 }
81
82 #endif