Remove obsolete ResStatus bits.
[platform/upstream/libzypp.git] / zypp / HistoryLog.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/HistoryLog.h
10  *
11  */
12 #ifndef ZYPP_TARGET_COMMITLOG_H
13 #define ZYPP_TARGET_COMMITLOG_H
14
15 #include <iosfwd>
16
17 #include "zypp/Pathname.h"
18
19 namespace zypp
20 {
21   class PoolItem;
22   class RepoInfo;
23
24   ///////////////////////////////////////////////////////////////////
25   //
26   //    CLASS NAME : HistoryLog
27   /**
28    * Simple wrapper for progress log. Refcnt, filename and corresponding
29    * ofstream are static members. Logfile constructor raises, destructor
30    * lowers refcounter. On refcounter changing from 0->1, file is opened.
31    * Changing from 1->0 the file is closed. Thus Logfile objects should be
32    * local to those functions, writing the log, and must not be stored
33    * permanently.
34    *
35    * Usage:
36    * <code>
37    *  some method ()
38    *  {
39    *    PoolItem pi;
40    *    ...
41    *    HistoryLog().install(pi);
42    *    ...
43    *    HistoryLog().comment(someMessage);
44    *  }
45    * </code>
46    *
47    * \note Take care to set proper target root dir if needed. Either pass
48    *       it via the constructor, or set it via setRoot(Pathname) method.
49    *       The default location of the file is determined by
50    *       \ref ZConfig::historyLogPath() which defaults to
51    *       /var/log/zypp/history.
52    *
53    * \see http://en.opensuse.org/Libzypp/Package_History
54    *
55    * \todo The implementation as pseudo signleton is questionable.
56    * Use shared_ptr instead of handcrafted ref/unref. Manage multiple
57    * logs at different locations.
58    */
59   class HistoryLog
60   {
61     HistoryLog( const HistoryLog & );
62     HistoryLog & operator=( const HistoryLog & );
63   public:
64     /**
65      * Constructor with an optional root directory.
66      *
67      * \param rootdir actual target root directory
68      */
69     HistoryLog( const Pathname & rootdir = Pathname() );
70     ~HistoryLog();
71
72     /**
73      * Set new root directory to the default history log file path.
74      *
75      * This path will be prepended to the default log file path. This should
76      * be done where there is a potential that the target root has changed.
77      *
78      * \param root new root directory.
79      */
80     static void setRoot( const Pathname & root );
81
82     /**
83      * Get the current log file path.
84      */
85     static const Pathname & fname();
86
87     /**
88      * Log a comment (even multiline).
89      *
90      * \param comment the comment
91      * \param timestamp whether to include a timestamp at the start of the comment
92      */
93     void comment( const std::string & comment, bool timestamp = false );
94
95     /**
96      * Log installation (or update) of a package.
97      */
98     void install( const PoolItem & pi );
99
100     /**
101      * Log removal of a package
102      */
103     void remove( const PoolItem & pi );
104
105     /**
106      * Log a newly added repository.
107      *
108      * \param repo info about the added repository
109      */
110     void addRepository( const RepoInfo & repo );
111
112     /**
113      * Log recently removed repository.
114      *
115      * \param repo info about the removed repository
116      */
117     void removeRepository( const RepoInfo & repo );
118
119     /**
120      * Log certain modifications to a repository.
121      *
122      * \param oldrepo info about the old repository
123      * \param newrepo info about the new repository
124      */
125     void modifyRepository( const RepoInfo & oldrepo, const RepoInfo & newrepo );
126   };
127   ///////////////////////////////////////////////////////////////////
128
129 } // namespace zypp
130
131 #endif // ZYPP_TARGET_COMMITLOG_H