2 * Copyright (C) 2009 Intel Corporation
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #include <syncevo/MultiplexConfigNode.h>
21 #include <boost/algorithm/string/predicate.hpp>
26 MultiplexConfigNode::getNode(const std::string &property,
27 const ConfigProperty **found) const
29 BOOST_FOREACH(const ConfigProperty *prop, m_registry) {
31 BOOST_FOREACH(const std::string &name, prop->getNames()) {
32 if (name == property) {
42 FilterConfigNode *node =
43 m_nodes[prop->isHidden()][prop->getSharing()].get();
52 void MultiplexConfigNode::addFilter(const std::string &property,
53 const InitStateString &value)
55 FilterConfigNode::addFilter(property, value);
56 for (int i = 0; i < 2; i++) {
57 for (int e = 0; e < 3; e++) {
59 m_nodes[i][e]->addFilter(property, value);
65 void MultiplexConfigNode::setFilter(const ConfigFilter &filter)
67 FilterConfigNode::setFilter(filter);
68 for (int i = 0; i < 2; i++) {
69 for (int e = 0; e < 3; e++) {
71 m_nodes[i][e]->setFilter(filter);
77 void MultiplexConfigNode::flush()
79 for (int i = 0; i < 2; i++) {
80 for (int e = 0; e < 3; e++) {
82 m_nodes[i][e]->flush();
88 InitStateString MultiplexConfigNode::readProperty(const std::string &property) const
90 FilterConfigNode *node = getNode(property);
92 return node->readProperty(property);
94 return InitStateString();
98 void MultiplexConfigNode::writeProperty(const std::string &property,
99 const InitStateString &value,
100 const std::string &comment)
102 const ConfigProperty *prop;
103 FilterConfigNode *node = getNode(property, &prop);
105 node->writeProperty(property, value, comment);
107 SE_THROW(property + ": not supported by configuration multiplexer");
111 void MultiplexConfigNode::readProperties(PropsType &props) const
113 for (int i = 0; i < 2; i++) {
114 for (int e = 0; e < 3; e++) {
116 m_nodes[i][e]->readProperties(props);
122 void MultiplexConfigNode::removeProperty(const std::string &property)
125 SE_THROW(property + ": removing via configuration multiplexer not supported");
127 for (int i = 0; i < 2; i++) {
128 for (int e = 0; e < 3; e++) {
130 m_nodes[i][e]->removeProperty(property);
137 void MultiplexConfigNode::clear()
140 SE_THROW("configuration multiplexer cannot be cleared");
142 for (int i = 0; i < 2; i++) {
143 for (int e = 0; e < 3; e++) {
145 m_nodes[i][e]->clear();
152 bool MultiplexConfigNode::exists() const
154 for (int i = 0; i < 2; i++) {
155 for (int e = 0; e < 3; e++) {
157 m_nodes[i][e]->exists()) {