fa41dd7d937de07bcd789f90da73b061f9d83538
[platform/upstream/libzypp.git] / zypp / RepoStatus.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/RepoStatus.h
10  *
11 */
12 #ifndef ZYPP2_REPOSTATUS_H
13 #define ZYPP2_REPOSTATUS_H
14
15 #include <iosfwd>
16 #include "zypp/base/PtrTypes.h"
17 #include "zypp/CheckSum.h"
18 #include "zypp/Date.h"
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23
24   ///////////////////////////////////////////////////////////////////
25   //
26   //    CLASS NAME : RepoStatus
27   //
28   /**
29    * \short Local facts about a repository
30    * This class represents the status of a
31    * repository on the system.
32    *
33    * Anything that is not provided on the metadata
34    * files, like the timestamp of the downloaded
35    * metadata, and its checksum.
36    */
37   class RepoStatus
38   {
39     friend std::ostream & operator<<( std::ostream & str, const RepoStatus & obj );
40
41   public:
42     
43     /**
44      * Checksum of the repository.
45      * Usually the checksum of the index, but any
46      * checksum that changes when the repository changes
47      * in any way is sufficient.
48      */
49     std::string checksum() const;
50     
51     /**
52      * timestamp of the repository. If the repository
53      * changes, it has to be updated as well with the
54      * new timestamp.
55      */
56     Date timestamp() const;
57     
58     /**
59      * \short Is the status empty?
60      *
61      * An empty status means that the status
62      * was not calculated.
63      */
64     bool empty() const;
65
66     /**
67      * set the repository checksum \see checksum
68      * \param checksum
69      */
70     RepoStatus & setChecksum( const std::string &checksum );
71     
72     /**
73      * set the repository timestamp \see timestamp
74      * \param timestamp
75      */
76     RepoStatus & setTimestamp( const Date &timestamp );
77
78     /** Implementation  */
79     class Impl;
80
81   public:
82     /** Default ctor */
83     RepoStatus();
84     
85     /**
86      * \short Status from a single file
87      * As most repository state is represented
88      * by the status of the index file, you can
89      * construct the status from a file.
90      *
91      * \note construct from a non existing
92      * file will result in an empty status
93      */
94     RepoStatus( const Pathname &file );
95     
96     /** Dtor */
97     ~RepoStatus();
98
99   public:
100
101   private:
102     /** Pointer to implementation */
103     RWCOW_pointer<Impl> _pimpl;
104   };
105   ///////////////////////////////////////////////////////////////////
106
107   /** \relates RepoStatus Stream output */
108   std::ostream & operator<<( std::ostream & str, const RepoStatus & obj );
109
110   /**
111    * combines 2 repostatus with a checksum based on both
112    * checksums and the newest timestamp
113    */
114   RepoStatus operator&&( const RepoStatus &lhs, const RepoStatus &rhs );
115
116   /////////////////////////////////////////////////////////////////
117 } // namespace zypp
118 ///////////////////////////////////////////////////////////////////
119 #endif // ZYPP2_REPOSTATUS_H