fixup Fix to build with libxml 2.12.x (fixes #505)
[platform/upstream/libzypp.git] / zypp / RepoStatus.h
index 211f17f..41e0152 100644 (file)
 #define ZYPP2_REPOSTATUS_H
 
 #include <iosfwd>
-#include "zypp/base/PtrTypes.h"
-#include "zypp/CheckSum.h"
-#include "zypp/Date.h"
+#include <zypp/base/PtrTypes.h>
+#include <zypp/CheckSum.h>
+#include <zypp/Date.h>
 
 ///////////////////////////////////////////////////////////////////
 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:
-    
-    /**
-     * reads the status from a file which contains the
-     * checksum and timestamp in each line.
-     *
-     * \throws Exception If the file is not valid or accessible
-     */
-    static RepoStatus fromCookieFile( const Pathname &path );
-  
-    /**
-     * 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 &timestamp );
+    /** 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<Impl> _pimpl;
+    RWCOW_pointer<Impl> _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