00001 /* 00002 * Copyright (C) 2008 Patrick Ohly 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 */ 00018 00019 #ifndef INCL_EVOLUTION_FILE_CONFIG_TREE 00020 # define INCL_EVOLUTION_FILE_CONFIG_TREE 00021 00022 #include <ConfigTree.h> 00023 00024 #include <string> 00025 #include <map> 00026 using namespace std; 00027 00028 /** 00029 * This implementation maps nodes to plain .ini style files below an 00030 * absolute directory of the filesystem. The caller is responsible for 00031 * choosing that directory and how hidden and user-visible files are 00032 * to be named. 00033 */ 00034 class FileConfigTree : public ConfigTree { 00035 public: 00036 /** 00037 * @param root absolute filesystem path 00038 * @param oldLayout use file names as in SyncEvolution <= 0.7 00039 */ 00040 FileConfigTree(const string &root, 00041 bool oldLayout); 00042 00043 /* ConfigTree API */ 00044 virtual string getRootPath() const; 00045 virtual void flush(); 00046 virtual void reset(); 00047 virtual boost::shared_ptr<ConfigNode> open(const string &path, 00048 PropertyType type, 00049 const string &otherId = string("")); 00050 list<string> getChildren(const string &path); 00051 00052 private: 00053 const string m_root; 00054 const bool m_oldLayout; 00055 00056 typedef map< string, boost::shared_ptr<ConfigNode> > NodeCache_t; 00057 /** cache of all nodes ever accessed */ 00058 NodeCache_t m_nodes; 00059 }; 00060 00061 #endif