libept
|
00001 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t -*- 00002 /* @file 00003 * @author Enrico Zini (enrico) <enrico@enricozini.org> 00004 */ 00005 00006 /* 00007 * libpkg Debtags data provider 00008 * 00009 * Copyright (C) 2003-2007 Enrico Zini <enrico@debian.org> 00010 * 00011 * This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 */ 00025 00026 #ifndef EPT_DEBTAGS_DEBTAGS_H 00027 #define EPT_DEBTAGS_DEBTAGS_H 00028 00029 #include <tagcoll/coll/base.h> 00030 #include <tagcoll/coll/fast.h> 00031 #include <string> 00032 00033 namespace ept { 00034 namespace debtags { 00035 class Debtags; 00036 } 00037 } 00038 00039 namespace ept { 00040 namespace debtags { 00041 00054 class Debtags : public tagcoll::coll::Fast<std::string, std::string> 00055 { 00056 protected: 00057 // User rc directory to store patches 00058 std::string rcdir; 00059 00060 // Last modification timestamp of the index 00061 time_t m_timestamp; 00062 00063 public: 00064 typedef tagcoll::coll::Fast<std::string, std::string> coll_type; 00065 typedef std::pair< std::string, std::set<std::string> > value_type; 00066 00075 Debtags(bool editable = false); 00076 ~Debtags() {} 00077 00079 time_t timestamp() const { return m_timestamp; } 00080 00082 bool hasData() const { return m_timestamp != 0; } 00083 00084 coll_type& tagdb() { return *this; } 00085 const coll_type& tagdb() const { return *this; } 00086 tagcoll::PatchList<std::string, std::string> changes() const; 00087 00088 #if 0 00089 00092 const Patches& changes() const { return m_changes; } 00093 00097 void resetChanges() { m_changes.clear(); } 00098 00102 void setChanges(const Patches& changes); 00103 00107 void addChanges(const Patches& changes); 00108 #endif 00109 00110 #if 0 00111 ItemSet getTaggedItems() const; 00112 #endif 00113 00118 //static bool hasTagDatabase(); 00119 00120 00125 void savePatch(); 00126 00131 void savePatch(const tagcoll::PatchList<std::string, std::string>& patch); 00132 00137 void sendPatch(); 00138 00142 void sendPatch(const tagcoll::PatchList<std::string, std::string>& patch); 00143 00149 template<typename OUT> 00150 void outputSystem(const OUT& cons); 00151 00157 template<typename OUT> 00158 void outputSystem(const std::string& filename, const OUT& out); 00159 00166 template<typename OUT> 00167 void outputPatched(const OUT& cons); 00168 00175 template<typename OUT> 00176 void outputPatched(const std::string& filename, const OUT& out); 00177 }; 00178 00179 00180 } 00181 } 00182 00183 // vim:set ts=4 sw=4: 00184 #endif