LCOV - lcov.info - ept/debtags/maint/path.h

LTP GCOV extension - code coverage report
Current view: | directory - ept/debtags/maint - path.h
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 17
Code covered: | 100.0 % |  | Executed lines: | 17

           1                 : // -*- mode: c++; indent-tabs-mode: t -*-
           2                 : /** \file
           3                 :  * debtags paths
           4                 :  */
           5                 :
           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                 : struct stat;
          27                 :
          28                 : #ifndef EPT_DEBTAGS_PATH_H
          29                 : #define EPT_DEBTAGS_PATH_H
          30                 :
          31                 : namespace ept {
          32                 : namespace debtags {
          33                 :
          34                 : /**
          35                 :  * Singleton class to configure and access the various Debtags paths
          36                 :  */
          37                 : class Path
          38               1 : {
          39                 : public:
          40                 :         static std::string vocabulary();
          41                 :         static std::string vocabularyIndex();
          42                 :         static std::string userVocabulary();
          43                 :         static std::string userVocabularyIndex();
          44                 :         static std::string tagdb();
          45                 :         static std::string tagdbIndex();
          46                 :         static std::string userTagdb();
          47                 :         static std::string userTagdbIndex();
          48                 :         static std::string pkgidx();
          49                 :         static std::string userPkgidx();
          50                 :
          51                 :         static std::string debtagsSourceDir();
          52                 :         static std::string debtagsIndexDir();
          53                 :         static std::string debtagsUserSourceDir();
          54                 :         static std::string debtagsUserIndexDir();
          55                 :
          56                 :         // Directory where Debtags source data is found
          57                 :         static void setDebtagsSourceDir( const std::string &s );
          58                 :
          59                 :         // Directory where Debtags indexes are kept
          60                 :         static void setDebtagsIndexDir( const std::string &s );
          61                 :
          62                 :         // User-specific directory for Debtags source data
          63                 :         static void setDebtagsUserSourceDir( const std::string &s );
          64                 :
          65                 :         // User-specific directory for Debtags index data
          66                 :         static void setDebtagsUserIndexDir( const std::string &s );
          67                 :
          68                 :         static int access( const std::string &, int );
          69                 :         static time_t timestamp( const std::string& );
          70                 :
          71                 :         // RAII-style classes to temporarily override directories
          72                 :         class OverrideDebtagsSourceDir
          73                 :         {
          74                 :                 std::string old;
          75                 :         public:
          76              31 :                 OverrideDebtagsSourceDir(const std::string& path) : old(Path::debtagsSourceDir())
          77                 :                 {
          78              31 :                         Path::setDebtagsSourceDir(path);
          79              31 :                 }
          80              31 :                 ~OverrideDebtagsSourceDir() { Path::setDebtagsSourceDir(old); }
          81                 :         };
          82                 :         class OverrideDebtagsIndexDir
          83                 :         {
          84                 :                 std::string old;
          85                 :         public:
          86              31 :                 OverrideDebtagsIndexDir(const std::string& path) : old(Path::debtagsIndexDir())
          87                 :                 {
          88              31 :                         Path::setDebtagsIndexDir(path);
          89              31 :                 }
          90              31 :                 ~OverrideDebtagsIndexDir() { Path::setDebtagsIndexDir(old); }
          91                 :         };
          92                 :         class OverrideDebtagsUserSourceDir
          93                 :         {
          94                 :                 std::string old;
          95                 :         public:
          96              31 :                 OverrideDebtagsUserSourceDir(const std::string& path) : old(Path::debtagsUserSourceDir())
          97                 :                 {
          98              31 :                         Path::setDebtagsUserSourceDir(path);
          99              31 :                 }
         100              31 :                 ~OverrideDebtagsUserSourceDir() { Path::setDebtagsUserSourceDir(old); }
         101                 :         };
         102                 :         class OverrideDebtagsUserIndexDir
         103                 :         {
         104                 :                 std::string old;
         105                 :         public:
         106              31 :                 OverrideDebtagsUserIndexDir(const std::string& path) : old(Path::debtagsUserIndexDir())
         107                 :                 {
         108              31 :                         Path::setDebtagsUserIndexDir(path);
         109              31 :                 }
         110              31 :                 ~OverrideDebtagsUserIndexDir() { Path::setDebtagsUserIndexDir(old); }
         111                 :         };
         112                 : protected:
         113                 :         static Path *s_instance;
         114                 :         static Path &instance();
         115                 :
         116                 :         // Directory where Debtags source data is found
         117                 :         std::string m_debtagsSourceDir;
         118                 :
         119                 :         // Directory where Debtags indexes are kept
         120                 :         std::string m_debtagsIndexDir;
         121                 :
         122                 :         // User-specific directory for Debtags source data
         123                 :         std::string m_debtagsUserSourceDir;
         124                 :
         125                 :         // User-specific directory for Debtags index data
         126                 :         std::string m_debtagsUserIndexDir;
         127                 : };
         128                 :
         129                 : }
         130                 : }
         131                 :
         132                 : // vim:set ts=4 sw=4:
         133                 : #endif

Generated by: LTP GCOV extension version 1.6