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

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

           1                 : #ifndef EPT_DEBTAGS_VOCABULARYINDEXER_H
           2                 : #define EPT_DEBTAGS_VOCABULARYINDEXER_H
           3                 :
           4                 : /** @file
           5                 :  * @author Enrico Zini <enrico@enricozini.org>
           6                 :  * Debtags vocabulary indexer
           7                 :  */
           8                 :
           9                 : /*
          10                 :  * Copyright (C) 2003,2004,2005,2006,2007  Enrico Zini <enrico@debian.org>
          11                 :  *
          12                 :  * This program is free software; you can redistribute it and/or modify
          13                 :  * it under the terms of the GNU General Public License as published by
          14                 :  * the Free Software Foundation; either version 2 of the License, or
          15                 :  * (at your option) any later version.
          16                 :  *
          17                 :  * This program is distributed in the hope that it will be useful,
          18                 :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
          19                 :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          20                 :  * GNU General Public License for more details.
          21                 :  *
          22                 :  * You should have received a copy of the GNU General Public License
          23                 :  * along with this program; if not, write to the Free Software
          24                 :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
          25                 :  */
          26                 :
          27                 : #include <ept/debtags/maint/sourcedir.h>
          28                 : #include <string>
          29                 :
          30                 : namespace ept {
          31                 : namespace debtags {
          32                 :
          33                 : /**
          34                 :  * Infrastructure used to rebuild the vocabulary index when needed
          35                 :  */
          36                 : struct VocabularyIndexer
          37              31 : {
          38                 :         SourceDir mainSource;
          39                 :         SourceDir userSource;
          40                 :         time_t ts_main_src;
          41                 :         time_t ts_user_src;
          42                 :         time_t ts_main_voc;
          43                 :         time_t ts_main_idx;
          44                 :         time_t ts_user_voc;
          45                 :         time_t ts_user_idx;
          46                 :
          47                 :         /**
          48                 :          * Get the timestamp of the newest vocabulary data source
          49                 :          */
          50             114 :         time_t sourceTimestamp() const { return ts_main_src < ts_user_src ? ts_user_src : ts_main_src; }
          51                 :         /**
          52                 :          * Return true if the vocabulary index needs rebuilding
          53                 :          */
          54                 :         bool needsRebuild() const;
          55                 :
          56                 :         /**
          57                 :          * Rebuild the vocabulary index
          58                 :          * @param vocfname
          59                 :          *   Full pathname of the merged vocabulary to create
          60                 :          * @param idxfname
          61                 :          *   Full pathname of the vocabulary index to create
          62                 :          */
          63                 :         bool rebuild(const std::string& vocfname, const std::string& idxfname);
          64                 :
          65                 :         /**
          66                 :          * Rebuild the vocabulary if needed
          67                 :          */
          68                 :         bool rebuildIfNeeded();
          69                 :
          70                 :         /**
          71                 :          * Get the names of the merged vocabulary and vocabulary index that can be
          72                 :          * used to access Debtags vocabulary data.
          73                 :          *
          74                 :          * The system or the user index will be returned according to which one is
          75                 :          * up to date.
          76                 :          */
          77                 :         bool getUpToDateVocabulary(std::string& vocfname, std::string& idxfname);
          78                 :
          79                 :         /**
          80                 :          * Returns true if the index in the user home directory is redundant and
          81                 :          * can be deleted.
          82                 :          *
          83                 :          * The user index is redundant if the system index is up to date.
          84                 :          */
          85                 :         bool userIndexIsRedundant() const;
          86                 :
          87                 :         /**
          88                 :          * Deletes the user index if it is redundant
          89                 :          */
          90                 :         bool deleteRedundantUserIndex();
          91                 :
          92                 :         /**
          93                 :          * Rescan the various timestamps
          94                 :          */
          95                 :         void rescan();
          96                 :
          97                 :         VocabularyIndexer();
          98                 :
          99                 :         /**
         100                 :          * Get the names of the merged vocabulary and vocabulary index that can be
         101                 :          * used to access Debtags vocabulary data.
         102                 :          *
         103                 :          * The system or the user index will be returned according to which one is
         104                 :          * up to date.
         105                 :          *
         106                 :          * The files will be built or rebuilt if they are missing or outdated.
         107                 :          */
         108                 :         static bool obtainWorkingVocabulary(std::string& vocfname, std::string& idxfname);
         109                 : };
         110                 :
         111                 :
         112                 : }
         113                 : }
         114                 :
         115                 : // vim:set ts=4 sw=4:
         116                 : #endif

Generated by: LTP GCOV extension version 1.6