FileChecker.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_FILECHECKER_H
00013 #define ZYPP_FILECHECKER_H
00014 
00015 #include <iosfwd>
00016 #include <list>
00017 #include "zypp/base/Exception.h"
00018 #include "zypp/base/Function.h"
00019 #include "zypp/PathInfo.h"
00020 #include "zypp/CheckSum.h"
00021 
00023 namespace zypp
00024 { 
00025 
00033   typedef function<void ( const Pathname &file )> FileChecker;
00034   
00035   class FileCheckException : public Exception
00036   {
00037   public:
00038     FileCheckException(const std::string &msg)
00039       : Exception(msg)
00040     {}
00041   };
00042   
00043   class CheckSumCheckException : public FileCheckException
00044   {
00045     //TODO
00046   };
00047   
00048   class SignatureCheckException : public FileCheckException
00049   {
00050     //TODO
00051   };
00052   
00060    class ChecksumFileChecker
00061    {
00062    public:
00067      ChecksumFileChecker( const CheckSum &checksum );
00074      void operator()( const Pathname &file ) const;
00075    private:
00076      CheckSum _checksum;
00077    };
00078    
00082    class SignatureFileChecker
00083    {
00084      public:
00089       SignatureFileChecker( const Pathname &signature );
00090       
00097       SignatureFileChecker();
00098       
00099       
00103       void addPublicKey( const Pathname &publickey );
00110       void operator()( const Pathname &file ) const;
00111      
00112      private:
00113       Pathname _signature;
00114    };
00115    
00120    class NullFileChecker
00121    {
00122    public:
00123      void operator()( const Pathname &file )  const;
00124    };
00125     
00140    class CompositeFileChecker
00141    {
00142    public:
00143      void add( const FileChecker &checker );
00147      void operator()( const Pathname &file ) const;
00148 
00149      int checkersSize() const { return _checkers.size(); }
00150    private:
00151      std::list<FileChecker> _checkers;
00152    };
00153 
00155   std::ostream & operator<<( std::ostream & str, const FileChecker & obj );
00156 
00158 } // namespace zypp
00160 #endif // ZYPP_FILECHECKER_H

Generated on Tue Sep 25 19:23:01 2007 for libzypp by  doxygen 1.5.3