HistoryLogReader added
[platform/upstream/libzypp.git] / zypp / HistoryLogData.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9
10 /** \file zypp/HistoryLogData.h
11  *
12  */
13 #ifndef ZYPP_HISTORYLOGDATA_H_
14 #define ZYPP_HISTORYLOGDATA_H_
15
16 #include "zypp/Date.h"
17 #include "zypp/Edition.h"
18 #include "zypp/Arch.h"
19 #include "zypp/CheckSum.h"
20 #include "zypp/Url.h"
21
22 #define HISTORY_LOG_DATE_FORMAT "%Y-%m-%d %H:%M:%S"
23
24 namespace zypp
25 {
26
27
28   ///////////////////////////////////////////////////////////////////
29   //
30   //  CLASS NAME : HistoryActionID
31   //
32   /**
33    * Enumeration of known history actions.
34    *
35    * \ingroup g_EnumerationClass
36    */
37   struct HistoryActionID
38   {
39     static const HistoryActionID NONE;
40
41     static const HistoryActionID INSTALL;
42     static const HistoryActionID REMOVE;
43     static const HistoryActionID REPO_ADD;
44     static const HistoryActionID REPO_REMOVE;
45     static const HistoryActionID REPO_CHANGE_ALIAS;
46     static const HistoryActionID REPO_CHANGE_URL;
47
48     enum ID
49     {
50       NONE_e,
51
52       INSTALL_e,
53       REMOVE_e,
54       REPO_ADD_e,
55       REPO_REMOVE_e,
56       REPO_CHANGE_ALIAS_e,
57       REPO_CHANGE_URL_e
58     };
59
60     HistoryActionID() : _id(NONE_e) {}
61
62     HistoryActionID(ID id) : _id(id) {}
63
64     explicit HistoryActionID(const std::string & strval_r);
65
66     ID toEnum() const { return _id; }
67
68     static HistoryActionID::ID parse(const std::string & strval_r);
69
70     const std::string & asString(bool pad = false) const;
71
72     private:
73     ID _id;
74   };
75
76   /** \relates HistoryActionID */
77   std::ostream & operator << (std::ostream & str, const HistoryActionID & id);
78   ///////////////////////////////////////////////////////////////////
79
80
81   /////////////////////////////////////////////////////////////////////
82   //
83   // CLASS NAME: HistoryItem
84   //
85   class HistoryItem
86   {
87   public:
88     typedef shared_ptr<HistoryItem> Ptr;
89     typedef std::vector<std::string> FieldVector;
90
91   public:
92     HistoryItem(FieldVector & fields);
93     virtual ~HistoryItem()
94     {}
95
96   public:
97     Date date;
98     HistoryActionID action;
99   };
100   /////////////////////////////////////////////////////////////////////
101
102
103   /////////////////////////////////////////////////////////////////////
104   //
105   // CLASS NAME: HistoryItemInstall
106   //
107   class HistoryItemInstall : public HistoryItem
108   {
109   public:
110     typedef shared_ptr<HistoryItemInstall> Ptr;
111
112     HistoryItemInstall(FieldVector & fields);
113     virtual ~HistoryItemInstall()
114     {}
115
116     virtual const std::string asString() const;
117
118   public:
119     std::string   name;
120     Edition       edition;
121     Arch          arch;
122     std::string   reqby; // TODO make this a class ReqBy
123     std::string   repoalias;
124     CheckSum      checksum;
125   };
126   /////////////////////////////////////////////////////////////////////
127
128
129   /////////////////////////////////////////////////////////////////////
130   //
131   // CLASS NAME: HistoryItemRemove
132   //
133   class HistoryItemRemove : public HistoryItem
134   {
135   public:
136     typedef shared_ptr<HistoryItemRemove> Ptr;
137
138     HistoryItemRemove(FieldVector & fields);
139     virtual ~HistoryItemRemove()
140     {}
141
142   public:
143     std::string name;
144     Edition     edition;
145     Arch        arch;
146     std::string reqby;
147   };
148   /////////////////////////////////////////////////////////////////////
149
150
151   /////////////////////////////////////////////////////////////////////
152   //
153   // CLASS NAME: HistoryItemRepoAdd
154   //
155   class HistoryItemRepoAdd : public HistoryItem
156   {
157   public:
158     typedef shared_ptr<HistoryItemRepoAdd> Ptr;
159
160     HistoryItemRepoAdd(FieldVector & fields);
161     virtual ~HistoryItemRepoAdd()
162     {}
163
164   public:
165     std::string alias;
166     Url         url;
167   };
168   /////////////////////////////////////////////////////////////////////
169
170
171   /////////////////////////////////////////////////////////////////////
172   //
173   // CLASS NAME: HistoryItemRepoRemove
174   //
175   class HistoryItemRepoRemove : public HistoryItem
176   {
177   public:
178     typedef shared_ptr<HistoryItemRepoRemove> Ptr;
179
180     HistoryItemRepoRemove(FieldVector & fields);
181     virtual ~HistoryItemRepoRemove()
182     {}
183
184   public:
185     std::string alias;
186   };
187   /////////////////////////////////////////////////////////////////////
188
189
190   /////////////////////////////////////////////////////////////////////
191   //
192   // CLASS NAME: HistoryItemRepoAliasChange
193   //
194   class HistoryItemRepoAliasChange : public HistoryItem
195   {
196   public:
197     typedef shared_ptr<HistoryItemRepoAliasChange> Ptr;
198
199     HistoryItemRepoAliasChange(FieldVector & fields);
200     virtual ~HistoryItemRepoAliasChange()
201     {}
202
203   public:
204     std::string oldalias;
205     std::string newalias;
206   };
207   /////////////////////////////////////////////////////////////////////
208
209
210   /////////////////////////////////////////////////////////////////////
211   //
212   // CLASS NAME: HistoryItemRepoUrlChange
213   //
214   class HistoryItemRepoUrlChange : public HistoryItem
215   {
216   public:
217     typedef shared_ptr<HistoryItemRepoUrlChange> Ptr;
218
219     HistoryItemRepoUrlChange(FieldVector & fields);
220     virtual ~HistoryItemRepoUrlChange()
221     {}
222
223   public:
224     std::string alias;
225     Url newurl;
226   };
227   /////////////////////////////////////////////////////////////////////
228
229
230 }
231
232 #endif /* ZYPP_HISTORYLOGDATA_H_ */