2 * Copyright (C) 2008 Patrick Ohly
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #ifndef INCL_EVOLUTION_PREFIX_CONFIG_NODE
21 # define INCL_EVOLUTION_PREFIX_CONFIG_NODE
23 #include <ConfigNode.h>
24 #include <boost/shared_ptr.hpp>
33 * This class acts as filter between a real config node and its user:
34 * a fixed prefix is added to each key when setting/getting a property.
35 * The list of properties only includes the key/value pairs with
38 * The purpose is to have multiple users accessing the same underlying
39 * node without running into namespace conflicts.
41 class PrefixConfigNode : public ConfigNode {
43 /** read-write access to underlying node */
44 PrefixConfigNode(const string prefix,
45 const boost::shared_ptr<ConfigNode> &node);
47 /** read-only access to underlying node */
48 PrefixConfigNode(const string prefix,
49 const boost::shared_ptr<const ConfigNode> &node);
51 virtual string getName() const { return m_readOnlyNode->getName(); }
55 virtual string readProperty(const string &property) const;
56 virtual void setProperty(const string &property,
58 const string &comment = "",
59 const string *defValue = NULL);
60 virtual void readProperties(map<string, string> &props) const;
61 virtual void removeProperty(const string &property);
62 virtual bool exists() const { return m_readOnlyNode->exists(); }
66 boost::shared_ptr<ConfigNode> m_node;
67 boost::shared_ptr<const ConfigNode> m_readOnlyNode;