X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=zypp%2FRepoStatus.h;h=1eaa2da2a3355a86deb95aef4812c07db5812080;hb=HEAD;hp=fa41dd7d937de07bcd789f90da73b061f9d83538;hpb=73479f609f24117900a08d0d593cb23b32f47ab5;p=platform%2Fupstream%2Flibzypp.git diff --git a/zypp/RepoStatus.h b/zypp/RepoStatus.h index fa41dd7..41e0152 100644 --- a/zypp/RepoStatus.h +++ b/zypp/RepoStatus.h @@ -13,105 +13,91 @@ #define ZYPP2_REPOSTATUS_H #include -#include "zypp/base/PtrTypes.h" -#include "zypp/CheckSum.h" -#include "zypp/Date.h" +#include +#include +#include /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : RepoStatus - // - /** - * \short Local facts about a repository - * This class represents the status of a - * repository on the system. - * - * Anything that is not provided on the metadata - * files, like the timestamp of the downloaded - * metadata, and its checksum. - */ + /// \class RepoStatus + /// \brief Track changing files or directories. + /// + /// Compute timestamp and checksum for individual files or + /// directories (recursively) to track changing content. + /// + /// The timestamp most probably denotes the time the data were + /// changed the last time, that's why it is exposed. + /// + /// The checksum however is an implementation detail and of no + /// use outside this class. \ref operator== tells if the checksums + /// of two rRepoStatus are the same. + /////////////////////////////////////////////////////////////////// class RepoStatus { friend std::ostream & operator<<( std::ostream & str, const RepoStatus & obj ); + friend RepoStatus operator&&( const RepoStatus & lhs, const RepoStatus & rhs ); + friend bool operator==( const RepoStatus & lhs, const RepoStatus & rhs ); public: - - /** - * Checksum of the repository. - * Usually the checksum of the index, but any - * checksum that changes when the repository changes - * in any way is sufficient. - */ - std::string checksum() const; - - /** - * timestamp of the repository. If the repository - * changes, it has to be updated as well with the - * new timestamp. - */ - Date timestamp() const; - - /** - * \short Is the status empty? + /** Default ctor */ + RepoStatus(); + + /** Compute status for single file or directory (recursively) * - * An empty status means that the status - * was not calculated. + * \note Construction from a non existing file will result + * in an empty status. */ - bool empty() const; + explicit RepoStatus( const Pathname & path_r ); - /** - * set the repository checksum \see checksum - * \param checksum - */ - RepoStatus & setChecksum( const std::string &checksum ); - - /** - * set the repository timestamp \see timestamp - * \param timestamp - */ - RepoStatus & setTimestamp( const Date ×tamp ); + /** Explicitly specify checksum string and timestamp to use. */ + RepoStatus( std::string checksum_r, Date timestamp_r ); - /** Implementation */ - class Impl; + /** Dtor */ + ~RepoStatus(); public: - /** Default ctor */ - RepoStatus(); - - /** - * \short Status from a single file - * As most repository state is represented - * by the status of the index file, you can - * construct the status from a file. - * - * \note construct from a non existing - * file will result in an empty status + /** Reads the status from a cookie file + * \returns An empty \ref RepoStatus if the file does not + * exist or is not readable. + * \see \ref saveToCookieFile */ - RepoStatus( const Pathname &file ); - - /** Dtor */ - ~RepoStatus(); + static RepoStatus fromCookieFile( const Pathname & path ); + + /** Save the status information to a cookie file + * \throws Exception if the file can't be saved + * \see \ref fromCookieFile + */ + void saveToCookieFile( const Pathname & path_r ) const; public: + /** Whether the status is empty (default constucted) */ + bool empty() const; + + /** The time the data were changed the last time */ + Date timestamp() const; + public: + struct Impl; ///< Implementation private: - /** Pointer to implementation */ - RWCOW_pointer _pimpl; + RWCOW_pointer _pimpl; ///< Pointer to implementation }; /////////////////////////////////////////////////////////////////// /** \relates RepoStatus Stream output */ std::ostream & operator<<( std::ostream & str, const RepoStatus & obj ); - /** - * combines 2 repostatus with a checksum based on both - * checksums and the newest timestamp - */ - RepoStatus operator&&( const RepoStatus &lhs, const RepoStatus &rhs ); + /** \relates RepoStatus Combine two RepoStatus (combined checksum and newest timestamp) */ + RepoStatus operator&&( const RepoStatus & lhs, const RepoStatus & rhs ); + + /** \relates RepoStatus Whether 2 RepoStatus refer to the same content checksum */ + bool operator==( const RepoStatus & lhs, const RepoStatus & rhs ); + + /** \relates RepoStatus Whether 2 RepoStatus refer to different content checksums */ + inline bool operator!=( const RepoStatus & lhs, const RepoStatus & rhs ) + { return ! ( lhs == rhs ); } ///////////////////////////////////////////////////////////////// } // namespace zypp