1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/RepoStatus.h
12 #ifndef ZYPP2_REPOSTATUS_H
13 #define ZYPP2_REPOSTATUS_H
16 #include <zypp/base/PtrTypes.h>
17 #include <zypp/CheckSum.h>
18 #include <zypp/Date.h>
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////
28 /// \brief Track changing files or directories.
30 /// Compute timestamp and checksum for individual files or
31 /// directories (recursively) to track changing content.
33 /// The timestamp most probably denotes the time the data were
34 /// changed the last time, that's why it is exposed.
36 /// The checksum however is an implementation detail and of no
37 /// use outside this class. \ref operator== tells if the checksums
38 /// of two rRepoStatus are the same.
39 ///////////////////////////////////////////////////////////////////
42 friend std::ostream & operator<<( std::ostream & str, const RepoStatus & obj );
43 friend RepoStatus operator&&( const RepoStatus & lhs, const RepoStatus & rhs );
44 friend bool operator==( const RepoStatus & lhs, const RepoStatus & rhs );
50 /** Compute status for single file or directory (recursively)
52 * \note Construction from a non existing file will result
55 explicit RepoStatus( const Pathname & path_r );
57 /** Compute status of a \a RepoInfo to track changes requiring a refresh. */
58 explicit RepoStatus( const RepoInfo & info_r );
60 /** Explicitly specify checksum string and timestamp to use. */
61 RepoStatus( std::string checksum_r, Date timestamp_r );
67 /** Reads the status from a cookie file
68 * \returns An empty \ref RepoStatus if the file does not
69 * exist or is not readable.
70 * \see \ref saveToCookieFile
72 static RepoStatus fromCookieFile( const Pathname & path );
74 /** Save the status information to a cookie file
75 * \throws Exception if the file can't be saved
76 * \see \ref fromCookieFile
78 void saveToCookieFile( const Pathname & path_r ) const;
81 /** Whether the status is empty (empty checksum) */
84 /** The time the data were changed the last time */
85 Date timestamp() const;
88 struct Impl; ///< Implementation
90 RWCOW_pointer<Impl> _pimpl; ///< Pointer to implementation
92 ///////////////////////////////////////////////////////////////////
94 /** \relates RepoStatus Stream output */
95 std::ostream & operator<<( std::ostream & str, const RepoStatus & obj );
97 /** \relates RepoStatus Combine two RepoStatus (combined checksum and newest timestamp) */
98 RepoStatus operator&&( const RepoStatus & lhs, const RepoStatus & rhs );
100 /** \relates RepoStatus Whether 2 RepoStatus refer to the same content checksum */
101 bool operator==( const RepoStatus & lhs, const RepoStatus & rhs );
103 /** \relates RepoStatus Whether 2 RepoStatus refer to different content checksums */
104 inline bool operator!=( const RepoStatus & lhs, const RepoStatus & rhs )
105 { return ! ( lhs == rhs ); }
107 /////////////////////////////////////////////////////////////////
109 ///////////////////////////////////////////////////////////////////
110 #endif // ZYPP2_REPOSTATUS_H