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  void load(const std::string& pathname);
64 
65 public:
66  typedef tagcoll::coll::Fast<std::string, std::string> coll_type;
67  typedef std::pair< std::string, std::set<std::string> > value_type;
68 
70  Debtags();
72  Debtags(const std::string& pathname);
73  ~Debtags() {}
74 
76  time_t timestamp() const { return m_timestamp; }
77 
79  bool hasData() const { return m_timestamp != 0; }
80 
81  coll_type& tagdb() { return *this; }
82  const coll_type& tagdb() const { return *this; }
83 
90  static std::string pathname();
91 };
92 
93 
94 }
95 }
96 
97 // vim:set ts=4 sw=4:
98 #endif
tagcoll::coll::Fast< std::string, std::string > coll_type
Definition: debtags.h:66
static std::string pathname()
Return the default pathname for the debtags tags.
Definition: debtags.cc:79
std::pair< std::string, std::set< std::string > > value_type
Definition: debtags.h:67
Definition: apt.cc:42
Access the on-disk Debtags tag database.
Definition: debtags.h:54
Debtags()
Create a Debtags object, reading the system database.
Definition: debtags.cc:52
time_t m_timestamp
Definition: debtags.h:61
~Debtags()
Definition: debtags.h:73
std::string rcdir
Definition: debtags.h:58
bool hasData() const
Return true if this data source has data, false if it's empty.
Definition: debtags.h:79
const coll_type & tagdb() const
Definition: debtags.h:82
void load(const std::string &pathname)
Definition: debtags.cc:67
coll_type & tagdb()
Definition: debtags.h:81
time_t timestamp() const
Get the timestamp of when the index was last updated.
Definition: debtags.h:76