libept
debtags.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t -*-
2 /* @file
3  * @author Enrico Zini (enrico) <enrico@enricozini.org>
4  */
5 
6 /*
7  * libpkg Debtags data provider
8  *
9  * Copyright (C) 2003-2007 Enrico Zini <enrico@debian.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  */
25 
26 #ifndef EPT_DEBTAGS_DEBTAGS_H
27 #define EPT_DEBTAGS_DEBTAGS_H
28 
29 #include <tagcoll/coll/base.h>
30 #include <tagcoll/coll/fast.h>
31 #include <string>
32 
33 namespace ept {
34 namespace debtags {
35 class Debtags;
36 }
37 }
38 
39 namespace ept {
40 namespace debtags {
41 
54 class Debtags : public tagcoll::coll::Fast<std::string, std::string>
55 {
56 protected:
57  // User rc directory to store patches
58  std::string rcdir;
59 
60  // Last modification timestamp of the index
61  time_t m_timestamp;
62 
63 public:
64  typedef tagcoll::coll::Fast<std::string, std::string> coll_type;
65  typedef std::pair< std::string, std::set<std::string> > value_type;
66 
75  Debtags(bool editable = false);
76  ~Debtags() {}
77 
79  time_t timestamp() const { return m_timestamp; }
80 
82  bool hasData() const { return m_timestamp != 0; }
83 
84  coll_type& tagdb() { return *this; }
85  const coll_type& tagdb() const { return *this; }
86  tagcoll::PatchList<std::string, std::string> changes() const;
87 
88 #if 0
89 
92  const Patches& changes() const { return m_changes; }
93 
97  void resetChanges() { m_changes.clear(); }
98 
102  void setChanges(const Patches& changes);
103 
107  void addChanges(const Patches& changes);
108 #endif
109 
110 #if 0
111  ItemSet getTaggedItems() const;
112 #endif
113 
118  //static bool hasTagDatabase();
119 
120 
125  void savePatch();
126 
131  void savePatch(const tagcoll::PatchList<std::string, std::string>& patch);
132 
137  void sendPatch();
138 
142  void sendPatch(const tagcoll::PatchList<std::string, std::string>& patch);
143 
149  template<typename OUT>
150  void outputSystem(const OUT& cons);
151 
157  template<typename OUT>
158  void outputSystem(const std::string& filename, const OUT& out);
159 
166  template<typename OUT>
167  void outputPatched(const OUT& cons);
168 
175  template<typename OUT>
176  void outputPatched(const std::string& filename, const OUT& out);
177 };
178 
179 
180 }
181 }
182 
183 // vim:set ts=4 sw=4:
184 #endif