]> git.proxmox.com Git - ceph.git/blob - ceph/src/common/config_obs.h
update ceph source to reef 18.2.0
[ceph.git] / ceph / src / common / config_obs.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 - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #ifndef CEPH_CONFIG_OBS_H
16 #define CEPH_CONFIG_OBS_H
17
18 #include <set>
19 #include <string>
20
21 #include "common/config_fwd.h"
22
23 namespace ceph {
24 /** @brief Base class for configuration observers.
25 * Use this as a base class for your object if it has to respond to configuration changes,
26 * for example by updating some values or modifying its behavior.
27 * Subscribe for configuration changes by calling the md_config_t::add_observer() method
28 * and unsubscribe using md_config_t::remove_observer().
29 */
30 template<class ConfigProxy>
31 class md_config_obs_impl {
32 public:
33 virtual ~md_config_obs_impl() {}
34 /** @brief Get a table of strings specifying the configuration keys in which the object is interested.
35 * This is called when the object is subscribed to configuration changes with add_observer().
36 * The returned table should not be freed until the observer is removed with remove_observer().
37 * Note that it is not possible to change the set of tracked keys without re-subscribing. */
38 virtual const char** get_tracked_conf_keys() const = 0;
39 /// React to a configuration change.
40 virtual void handle_conf_change(const ConfigProxy& conf,
41 const std::set <std::string> &changed) = 0;
42 /// Unused for now
43 virtual void handle_subsys_change(const ConfigProxy& conf,
44 const std::set<int>& changed) { }
45 };
46 }
47
48 using md_config_obs_t = ceph::md_config_obs_impl<ConfigProxy>;
49
50 #endif