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 #include <time.h>
33 
34 namespace ept {
35 namespace debtags {
36 class Debtags;
37 }
38 }
39 
40 namespace ept {
41 namespace debtags {
42 
55 class Debtags : public tagcoll::coll::Fast<std::string, std::string>
56 {
57 protected:
58  // User rc directory to store patches
59  std::string rcdir;
60 
61  // Last modification timestamp of the index
62  time_t m_timestamp;
63 
64 public:
65  typedef tagcoll::coll::Fast<std::string, std::string> coll_type;
66  typedef std::pair< std::string, std::set<std::string> > value_type;
67 
76  Debtags(bool editable = false);
77  ~Debtags() {}
78 
80  time_t timestamp() const { return m_timestamp; }
81 
83  bool hasData() const { return m_timestamp != 0; }
84 
85  coll_type& tagdb() { return *this; }
86  const coll_type& tagdb() const { return *this; }
87  tagcoll::PatchList<std::string, std::string> changes() const;
88 
89 #if 0
90 
93  const Patches& changes() const { return m_changes; }
94 
98  void resetChanges() { m_changes.clear(); }
99 
103  void setChanges(const Patches& changes);
104 
108  void addChanges(const Patches& changes);
109 #endif
110 
111 #if 0
112  ItemSet getTaggedItems() const;
113 #endif
114 
119  //static bool hasTagDatabase();
120 
121 
126  void savePatch();
127 
132  void savePatch(const tagcoll::PatchList<std::string, std::string>& patch);
133 
138  void sendPatch();
139 
143  void sendPatch(const tagcoll::PatchList<std::string, std::string>& patch);
144 
150  template<typename OUT>
151  void outputSystem(const OUT& cons);
152 
158  template<typename OUT>
159  void outputSystem(const std::string& filename, const OUT& out);
160 
167  template<typename OUT>
168  void outputPatched(const OUT& cons);
169 
176  template<typename OUT>
177  void outputPatched(const std::string& filename, const OUT& out);
178 };
179 
180 
181 }
182 }
183 
184 // vim:set ts=4 sw=4:
185 #endif
void outputSystem(const OUT &cons)
Output the current Debian tags database to a consumer of ...
tagcoll::coll::Fast< std::string, std::string > coll_type
Definition: debtags.h:65
std::pair< std::string, std::set< std::string > > value_type
Definition: debtags.h:66
Definition: apt.cc:42
Access the on-disk Debtags tag database.
Definition: debtags.h:55
time_t m_timestamp
Definition: debtags.h:62
~Debtags()
Definition: debtags.h:77
std::string rcdir
Definition: debtags.h:59
void outputPatched(const OUT &cons)
Output the current Debian tags database, patched with local patch, to a Consumer of
bool hasData() const
Return true if this data source has data, false if it's empty.
Definition: debtags.h:83
void sendPatch()
Send to the central archive a patch that can be used to turn the system database into the collection ...
Definition: debtags.cc:156
tagcoll::PatchList< std::string, std::string > changes() const
Definition: debtags.cc:80
const coll_type & tagdb() const
Definition: debtags.h:86
void savePatch()
Check if the tag database has been created (i.e.
Definition: debtags.cc:123
Debtags(bool editable=false)
Create a new accessor for the on-disk Debtags database.
Definition: debtags.cc:54
coll_type & tagdb()
Definition: debtags.h:85
time_t timestamp() const
Get the timestamp of when the index was last updated.
Definition: debtags.h:80