From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/common/PluginRegistry.h | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/common/PluginRegistry.h (limited to 'src/common/PluginRegistry.h') diff --git a/src/common/PluginRegistry.h b/src/common/PluginRegistry.h new file mode 100644 index 000000000..938fb6e16 --- /dev/null +++ b/src/common/PluginRegistry.h @@ -0,0 +1,68 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph distributed storage system + * + * Copyright (C) 2013,2014 Cloudwatt + * Copyright (C) 2014 Red Hat + * + * Author: Loic Dachary + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + */ + +#ifndef CEPH_COMMON_PLUGINREGISTRY_H +#define CEPH_COMMON_PLUGINREGISTRY_H + +#include +#include +#include "common/ceph_mutex.h" +#include "include/common_fwd.h" + +extern "C" { + const char *__ceph_plugin_version(); + int __ceph_plugin_init(CephContext *cct, + const std::string& type, + const std::string& name); +} + +namespace ceph { + + class Plugin { + public: + void *library; + CephContext *cct; + + explicit Plugin(CephContext *cct) : library(NULL), cct(cct) {} + virtual ~Plugin() {} + }; + + class PluginRegistry { + public: + CephContext *cct; + ceph::mutex lock = ceph::make_mutex("PluginRegistery::lock"); + bool loading; + bool disable_dlclose; + std::map > plugins; + + explicit PluginRegistry(CephContext *cct); + ~PluginRegistry(); + + int add(const std::string& type, const std::string& name, + Plugin *factory); + int remove(const std::string& type, const std::string& name); + Plugin *get(const std::string& type, const std::string& name); + Plugin *get_with_load(const std::string& type, const std::string& name); + + int load(const std::string& type, + const std::string& name); + int preload(); + int preload(const std::string& type); + }; +} + +#endif -- cgit v1.2.3