libzypp  10.5.0
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 #include "zypp/KeyContext.h"
00022 
00024 namespace zypp
00025 { 
00026 
00027   class PublicKey;
00028 
00036   typedef function<void ( const Pathname &file )> FileChecker;
00037 
00038   class FileCheckException : public Exception
00039   {
00040   public:
00041     FileCheckException(const std::string &msg)
00042       : Exception(msg)
00043     {}
00044   };
00045 
00046   class CheckSumCheckException : public FileCheckException
00047   {
00048     //TODO
00049   };
00050 
00051   class SignatureCheckException : public FileCheckException
00052   {
00053     //TODO
00054   };
00055 
00063    class ChecksumFileChecker
00064    {
00065    public:
00070      ChecksumFileChecker( const CheckSum &checksum );
00077      void operator()( const Pathname &file ) const;
00078    private:
00079      CheckSum _checksum;
00080    };
00081 
00085    class SignatureFileChecker
00086    {
00087      public:
00092       SignatureFileChecker( const Pathname &signature );
00093 
00100       SignatureFileChecker();
00101 
00109       void setKeyContext(const KeyContext & keycontext);
00110 
00114       void addPublicKey( const PublicKey & publickey, const KeyContext & keycontext = KeyContext());
00116       void addPublicKey( const Pathname & publickey, const KeyContext & keycontext = KeyContext());
00117 
00124       void operator()( const Pathname &file ) const;
00125 
00126      protected:
00127       Pathname _signature;
00128       KeyContext _context;
00129    };
00130 
00135    class NullFileChecker
00136    {
00137    public:
00138      void operator()( const Pathname &file )  const;
00139    };
00140 
00155    class CompositeFileChecker
00156    {
00157    public:
00158      void add( const FileChecker &checker );
00162      void operator()( const Pathname &file ) const;
00163 
00164      int checkersSize() const { return _checkers.size(); }
00165    private:
00166      std::list<FileChecker> _checkers;
00167    };
00168 
00170   std::ostream & operator<<( std::ostream & str, const FileChecker & obj );
00171 
00173 } // namespace zypp
00175 #endif // ZYPP_FILECHECKER_H