libept
debtags/maint/path.h
Go to the documentation of this file.
1 // -*- mode: c++; indent-tabs-mode: t -*-
6 /*
7  * Copyright (C) 2005,2006,2007 Enrico Zini <enrico@debian.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
24 #include <string>
25 
26 #ifndef EPT_DEBTAGS_PATH_H
27 #define EPT_DEBTAGS_PATH_H
28 
29 namespace ept {
30 namespace debtags {
31 
35 class Path
36 {
37 public:
38  static std::string vocabulary();
39  static std::string userVocabulary();
40  static std::string tagdb();
41  static std::string userTagdb();
42 
43  static std::string debtagsSourceDir();
44  static std::string debtagsIndexDir();
45  static std::string debtagsUserSourceDir();
46  static std::string debtagsUserIndexDir();
47 
48  // Directory where Debtags source data is found
49  static void setDebtagsSourceDir( const std::string &s );
50 
51  // Directory where Debtags indexes are kept
52  static void setDebtagsIndexDir( const std::string &s );
53 
54  // User-specific directory for Debtags source data
55  static void setDebtagsUserSourceDir( const std::string &s );
56 
57  // User-specific directory for Debtags index data
58  static void setDebtagsUserIndexDir( const std::string &s );
59 
60  static int access( const std::string &, int );
61  static time_t timestamp( const std::string& );
62 
63  // RAII-style classes to temporarily override directories
65  {
66  std::string old;
67  public:
68  OverrideDebtagsSourceDir(const std::string& path) : old(Path::debtagsSourceDir())
69  {
71  }
73  };
75  {
76  std::string old;
77  public:
78  OverrideDebtagsIndexDir(const std::string& path) : old(Path::debtagsIndexDir())
79  {
81  }
83  };
85  {
86  std::string old;
87  public:
88  OverrideDebtagsUserSourceDir(const std::string& path) : old(Path::debtagsUserSourceDir())
89  {
91  }
93  };
95  {
96  std::string old;
97  public:
98  OverrideDebtagsUserIndexDir(const std::string& path) : old(Path::debtagsUserIndexDir())
99  {
101  }
103  };
104 protected:
105  static Path *s_instance;
106  static Path &instance();
107 
108  // Directory where Debtags source data is found
109  std::string m_debtagsSourceDir;
110 
111  // Directory where Debtags indexes are kept
112  std::string m_debtagsIndexDir;
113 
114  // User-specific directory for Debtags source data
116 
117  // User-specific directory for Debtags index data
119 };
120 
121 }
122 }
123 
124 // vim:set ts=4 sw=4:
125 #endif
std::string m_debtagsUserSourceDir
Definition: debtags/maint/path.h:115
Definition: debtags/maint/path.h:74
~OverrideDebtagsIndexDir()
Definition: debtags/maint/path.h:82
static void setDebtagsUserIndexDir(const std::string &s)
Definition: debtags/maint/path.cc:82
OverrideDebtagsUserIndexDir(const std::string &path)
Definition: debtags/maint/path.h:98
OverrideDebtagsUserSourceDir(const std::string &path)
Definition: debtags/maint/path.h:88
static std::string tagdb()
Definition: debtags/maint/path.cc:100
static void setDebtagsSourceDir(const std::string &s)
Definition: debtags/maint/path.cc:70
OverrideDebtagsIndexDir(const std::string &path)
Definition: debtags/maint/path.h:78
Definition: debtags/maint/path.h:64
OverrideDebtagsSourceDir(const std::string &path)
Definition: debtags/maint/path.h:68
static Path & instance()
Definition: debtags/maint/path.cc:51
static int access(const std::string &, int)
Definition: debtags/maint/path.cc:62
static std::string debtagsUserSourceDir()
Definition: debtags/maint/path.cc:89
static std::string debtagsIndexDir()
Definition: debtags/maint/path.cc:88
std::string m_debtagsUserIndexDir
Definition: debtags/maint/path.h:118
Definition: debtags/maint/path.h:84
static Path * s_instance
Definition: debtags/maint/path.h:105
~OverrideDebtagsSourceDir()
Definition: debtags/maint/path.h:72
static std::string debtagsSourceDir()
Definition: debtags/maint/path.cc:87
~OverrideDebtagsUserIndexDir()
Definition: debtags/maint/path.h:102
static time_t timestamp(const std::string &)
Definition: debtags/maint/path.cc:66
std::string m_debtagsSourceDir
Definition: debtags/maint/path.h:109
~OverrideDebtagsUserSourceDir()
Definition: debtags/maint/path.h:92
static std::string debtagsUserIndexDir()
Definition: debtags/maint/path.cc:90
Definition: debtags/maint/path.h:94
static std::string userVocabulary()
Definition: debtags/maint/path.cc:96
static void setDebtagsUserSourceDir(const std::string &s)
Definition: debtags/maint/path.cc:78
static void setDebtagsIndexDir(const std::string &s)
Definition: debtags/maint/path.cc:74
static std::string userTagdb()
Definition: debtags/maint/path.cc:104
Singleton class to configure and access the various Debtags paths.
Definition: debtags/maint/path.h:35
std::string m_debtagsIndexDir
Definition: debtags/maint/path.h:112
static std::string vocabulary()
Definition: debtags/maint/path.cc:92