bad3296d80299fe693b9a65f596e98e1d3a89fad
[platform/upstream/libzypp.git] / zypp / ProvideFilePolicy.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9
10 #ifndef ZYPP_PROVIDEFILEPOLICY_H
11 #define ZYPP_PROVIDEFILEPOLICY_H
12
13 #include <iosfwd>
14
15 #include "zypp/base/Function.h"
16 #include "zypp/base/Functional.h"
17 #include "zypp/FileChecker.h"
18
19 ///////////////////////////////////////////////////////////////////
20 namespace zypp
21 {
22   ///////////////////////////////////////////////////////////////////
23   /// \class ProvideFilePolicy
24   /// \brief Policy for \ref provideFile and \ref RepoMediaAccess.
25   ///
26   /// Provides callback hook for progress reporting and an optional
27   /// \ref FileCecker passed down to the \ref Fetcher.
28   ///////////////////////////////////////////////////////////////////
29   class ProvideFilePolicy
30   {
31   public:
32     /** Progress callback signature. */
33     typedef function<bool ( int )> ProgressCB;
34
35     /** Set callback. */
36     ProvideFilePolicy & progressCB( ProgressCB progressCB_r )
37     { _progressCB = progressCB_r; return *this; }
38
39     /** Evaluate callback. */
40     bool progress( int value ) const;
41
42   public:
43     /** Add a \ref FileCecker passed down to the \ref Fetcher */
44     ProvideFilePolicy & fileChecker( FileChecker fileChecker_r )
45     { _fileChecker = std::move(fileChecker_r); return *this; }
46
47     /** The \ref FileCecker. */
48     const FileChecker & fileChecker() const
49     { return _fileChecker; }
50
51   private:
52     FileChecker           _fileChecker;
53     ProgressCB            _progressCB;
54   };
55
56 } // namespace zypp
57 ///////////////////////////////////////////////////////////////////
58 #endif // ZYPP_PROVIDEFILEPOLICY_H