syncevolution/src/syncevo/MultiplexConfigNode.h
Patrick Ohly c16f1b0756 sync: avoid maintaining suspend/resume meta data during ephemeral sync
Both maintaining the map items inside the Synthesis engine and storing
them in .ini hash config nodes inside SyncEvolution are fairly heavy
operations which are not needed at all during an ephemeral sync (= no
meta data stored, done by the PIM Manager when triggering a pure PBAP
sync).

Using the new Synthesis CA_ResumeSupported DB capability it is
possible to suppress these operations without having to fiddle with
the Synthesis DB API that SyncEvolution provides. To make it possible
at the DB layer to detect that the meta data is not needed, the
ConfigNode passed to it must be marked as volatile.

This change sped up a sync with 10000 unmodified, known items from 38s
to 23s.
2013-07-12 11:44:39 +02:00

109 lines
4.2 KiB
C++

/*
* Copyright (C) 2009 Intel Corporation
*
* 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) version 3.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef INCL_SYNCEVO_MULTIPLEX_CONFIG_NODE
# define INCL_SYNCEVO_MULTIPLEX_CONFIG_NODE
#include <syncevo/declarations.h>
#include <syncevo/ConfigNode.h>
#include <syncevo/SyncConfig.h>
SE_BEGIN_CXX
/**
* Joins properties from the different nodes that might be used by a
* SyncConfig or SyncSourceConfig (global/shared/not shared,
* hidden/user-visible) and presents them as one node. Reading takes
* the union of all set properties. Writing is directed to the
* node for which the property was registered.
*/
class MultiplexConfigNode : public FilterConfigNode
{
const std::string m_name;
boost::shared_ptr<FilterConfigNode> m_nodes[2][3];
const ConfigPropertyRegistry &m_registry;
bool m_havePeerNodes;
int m_hiddenLower, m_hiddenUpper;
FilterConfigNode *getNode(const std::string &property,
const ConfigProperty **prop = NULL) const;
public:
/** join both hidden and user-visible properties */
MultiplexConfigNode(const std::string &name,
const ConfigPropertyRegistry &registry) :
FilterConfigNode(boost::shared_ptr<ConfigNode>()),
m_name(name),
m_registry(registry),
m_havePeerNodes(true),
m_hiddenLower(0), m_hiddenUpper(1) {}
/** only join hidden or user-visible properties */
MultiplexConfigNode(const std::string &name,
const ConfigPropertyRegistry &registry,
bool hidden) :
FilterConfigNode(boost::shared_ptr<ConfigNode>()),
m_name(name),
m_registry(registry),
m_havePeerNodes(true),
m_hiddenLower(hidden), m_hiddenUpper(hidden) {}
/** true when peer nodes are used (default), false when they are dummy nodes */
bool getHavePeerNodes() const { return m_havePeerNodes; }
void setHavePeerNodes(bool havePeerNodes) { m_havePeerNodes = havePeerNodes; }
/** configure the nodes to use */
void setNode(bool hidden, ConfigProperty::Sharing sharing,
const boost::shared_ptr<FilterConfigNode> &node) {
m_nodes[hidden][sharing] = node;
}
void setNode(bool hidden, ConfigProperty::Sharing sharing,
const boost::shared_ptr<ConfigNode> &node) {
m_nodes[hidden][sharing].reset(new FilterConfigNode(node));
}
virtual void addFilter(const std::string &property,
const InitStateString &value);
virtual void setFilter(const ConfigFilter &filter);
virtual std::string getName() const { return m_name; }
virtual bool isVolatile() const { return false; } // it is safe to pretend that it is not volatile, even if some or even all of its sub-nodes are
virtual void flush();
virtual InitStateString readProperty(const std::string &property) const;
virtual void writeProperty(const std::string &property,
const InitStateString &value,
const std::string &comment = std::string(""));
virtual void readProperties(PropsType &props) const;
/*
* removing or clearing something is not implemented because it is
* not certain what should be deleted: only properties which are
* not shared?!
*/
virtual void removeProperty(const std::string &property);
virtual void clear();
/**
* true if any of the nodes exists
*/
virtual bool exists() const;
};
SE_END_CXX
#endif // INCL_SYNCEVO_MULTIPLEX_CONFIG_NODE