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 <ept/debtags/coll/fast.h>
30 #include <string>
31 
32 namespace ept {
33 namespace debtags {
34 
47 class Debtags : public coll::Fast
48 {
49 protected:
50  // User rc directory to store patches
51  std::string rcdir;
52 
53  // Last modification timestamp of the index
54  time_t m_timestamp;
55 
56  void load(const std::string& pathname);
57 
58 public:
60  typedef std::pair< std::string, std::set<std::string> > value_type;
61 
63  Debtags();
65  Debtags(const std::string& pathname);
66  ~Debtags() {}
67 
69  time_t timestamp() const { return m_timestamp; }
70 
72  bool hasData() const { return m_timestamp != 0; }
73 
74  coll_type& tagdb() { return *this; }
75  const coll_type& tagdb() const { return *this; }
76 
83  static std::string pathname();
84 };
85 
86 }
87 }
88 
89 // vim:set ts=4 sw=4:
90 #endif
time_t timestamp() const
Get the timestamp of when the index was last updated.
Definition: debtags.h:69
static std::string pathname()
Return the default pathname for the debtags tags.
Definition: debtags.cc:77
Fast index for tag data.
std::pair< std::string, std::set< std::string > > value_type
Definition: debtags.h:60
String functions.
Definition: apt.cc:38
Access the on-disk Debtags tag database.
Definition: debtags.h:47
Debtags()
Create a Debtags object, reading the system database.
Definition: debtags.cc:42
time_t m_timestamp
Definition: debtags.h:54
~Debtags()
Definition: debtags.h:66
std::string rcdir
Definition: debtags.h:51
ept::debtags::coll::Fast coll_type
Definition: debtags.h:59
const coll_type & tagdb() const
Definition: debtags.h:75
In-memory collection with both item->tags and tag->items mappings.
Definition: fast.h:38
bool hasData() const
Return true if this data source has data, false if it&#39;s empty.
Definition: debtags.h:72
void load(const std::string &pathname)
Definition: debtags.cc:57
coll_type & tagdb()
Definition: debtags.h:74