]>
git.proxmox.com Git - ceph.git/blob - ceph/src/common/PluginRegistry.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph distributed storage system
6 * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
7 * Copyright (C) 2014 Red Hat <contact@redhat.com>
9 * Author: Loic Dachary <loic@dachary.org>
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.
18 #ifndef CEPH_COMMON_PLUGINREGISTRY_H
19 #define CEPH_COMMON_PLUGINREGISTRY_H
23 #include "common/ceph_mutex.h"
24 #include "include/common_fwd.h"
27 const char *__ceph_plugin_version();
28 int __ceph_plugin_init(CephContext
*cct
,
29 const std::string
& type
,
30 const std::string
& name
);
40 explicit Plugin(CephContext
*cct
) : library(NULL
), cct(cct
) {}
44 class PluginRegistry
{
47 ceph::mutex lock
= ceph::make_mutex("PluginRegistery::lock");
50 std::map
<std::string
,std::map
<std::string
,Plugin
*> > plugins
;
52 explicit PluginRegistry(CephContext
*cct
);
55 int add(const std::string
& type
, const std::string
& name
,
57 int remove(const std::string
& type
, const std::string
& name
);
58 Plugin
*get(const std::string
& type
, const std::string
& name
);
59 Plugin
*get_with_load(const std::string
& type
, const std::string
& name
);
61 int load(const std::string
& type
,
62 const std::string
& name
);
64 int preload(const std::string
& type
);