libept  0.5.25
popcon/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 #ifndef EPT_POPCON_PATH_H
25 #define EPT_POPCON_PATH_H
26 
27 #include <string>
28 
29 struct stat;
30 
31 namespace ept {
32 namespace popcon {
33 
37 class Path
38 {
39 public:
40  static std::string scores();
41  static std::string scoresIndex();
42  static std::string userScores();
43  static std::string userScoresIndex();
44 
45  static std::string popconSourceDir();
46  static std::string popconIndexDir();
47  static std::string popconUserSourceDir();
48  static std::string popconUserIndexDir();
49 
50  // Directory where Popcon source data is found
51  static void setPopconSourceDir( const std::string &s );
52 
53  // Directory where Popcon indexes are kept
54  static void setPopconIndexDir( const std::string &s );
55 
56  // User-specific directory for Popcon source data
57  static void setPopconUserSourceDir( const std::string &s );
58 
59  // User-specific directory for Popcon index data
60  static void setPopconUserIndexDir( const std::string &s );
61 
62  static int access( const std::string &, int );
63  static time_t timestamp( const std::string& );
64 
65  // RAII-style classes to temporarily override directories
67  {
68  std::string old;
69  public:
70  OverridePopconSourceDir(const std::string& path) : old(Path::popconSourceDir())
71  {
73  }
75  };
77  {
78  std::string old;
79  public:
80  OverridePopconIndexDir(const std::string& path) : old(Path::popconIndexDir())
81  {
83  }
85  };
87  {
88  std::string old;
89  public:
90  OverridePopconUserSourceDir(const std::string& path) : old(Path::popconUserSourceDir())
91  {
93  }
95  };
97  {
98  std::string old;
99  public:
100  OverridePopconUserIndexDir(const std::string& path) : old(Path::popconUserIndexDir())
101  {
103  }
105  };
106 protected:
107  static Path *s_instance;
108  static Path &instance();
109 
110  // Directory where Popcon source data is found
111  std::string m_popconSourceDir;
112 
113  // Directory where Popcon indexes are kept
114  std::string m_popconIndexDir;
115 
116  // User-specific directory for Popcon source data
118 
119  // User-specific directory for Popcon index data
120  std::string m_popconUserIndexDir;
121 };
122 
123 }
124 }
125 
126 // vim:set ts=4 sw=4:
127 #endif
OverridePopconSourceDir(const std::string &path)
Definition: popcon/maint/path.h:70
static std::string popconUserIndexDir()
Definition: popcon/maint/path.cc:92
Definition: popcon/maint/path.h:66
Singleton class to configure and access the various Popcon paths.
Definition: popcon/maint/path.h:37
Definition: popcon/maint/path.h:96
static std::string popconUserSourceDir()
Definition: popcon/maint/path.cc:91
static void setPopconIndexDir(const std::string &s)
Definition: popcon/maint/path.cc:76
OverridePopconUserSourceDir(const std::string &path)
Definition: popcon/maint/path.h:90
static int access(const std::string &, int)
Definition: popcon/maint/path.cc:63
static Path & instance()
Definition: popcon/maint/path.cc:52
static std::string scoresIndex()
Definition: popcon/maint/path.cc:98
std::string m_popconSourceDir
Definition: popcon/maint/path.h:111
std::string m_popconUserIndexDir
Definition: popcon/maint/path.h:120
Definition: popcon/maint/path.h:86
~OverridePopconIndexDir()
Definition: popcon/maint/path.h:84
static std::string scores()
Definition: popcon/maint/path.cc:94
std::string m_popconUserSourceDir
Definition: popcon/maint/path.h:117
OverridePopconIndexDir(const std::string &path)
Definition: popcon/maint/path.h:80
static std::string popconSourceDir()
Definition: popcon/maint/path.cc:89
~OverridePopconSourceDir()
Definition: popcon/maint/path.h:74
Definition: popcon/maint/path.h:76
OverridePopconUserIndexDir(const std::string &path)
Definition: popcon/maint/path.h:100
static std::string userScoresIndex()
Definition: popcon/maint/path.cc:106
~OverridePopconUserIndexDir()
Definition: popcon/maint/path.h:104
std::string m_popconIndexDir
Definition: popcon/maint/path.h:114
static Path * s_instance
Definition: popcon/maint/path.h:107
static void setPopconUserSourceDir(const std::string &s)
Definition: popcon/maint/path.cc:80
~OverridePopconUserSourceDir()
Definition: popcon/maint/path.h:94
static std::string userScores()
Definition: popcon/maint/path.cc:102
static void setPopconSourceDir(const std::string &s)
Definition: popcon/maint/path.cc:72
static time_t timestamp(const std::string &)
Definition: popcon/maint/path.cc:67
static std::string popconIndexDir()
Definition: popcon/maint/path.cc:90
static void setPopconUserIndexDir(const std::string &s)
Definition: popcon/maint/path.cc:84