libzypp  12.16.5
HistoryLogData.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
9 
13 #ifndef ZYPP_HISTORYLOGDATA_H_
14 #define ZYPP_HISTORYLOGDATA_H_
15 
16 #include <iosfwd>
17 
18 #include "zypp/APIConfig.h"
19 #include "zypp/Date.h"
20 #include "zypp/Edition.h"
21 #include "zypp/Arch.h"
22 #include "zypp/CheckSum.h"
23 #include "zypp/Url.h"
24 
25 #define HISTORY_LOG_DATE_FORMAT "%Y-%m-%d %H:%M:%S"
26 
28 namespace zypp
29 {
37  {
38  static const HistoryActionID NONE;
39 
40  static const HistoryActionID INSTALL;
41  static const HistoryActionID REMOVE;
42  static const HistoryActionID REPO_ADD;
46 
47  enum ID
48  {
50 
57  };
58 
60 
61  HistoryActionID(ID id) : _id(id) {}
62 
63  explicit HistoryActionID(const std::string & strval_r);
64 
65  ID toEnum() const { return _id; }
66 
67  static HistoryActionID::ID parse(const std::string & strval_r);
68 
69  const std::string & asString(bool pad = false) const;
70 
71  private:
73  };
74 
76  inline bool operator==( const HistoryActionID & lhs, const HistoryActionID & rhs )
77  { return lhs.toEnum() == rhs.toEnum(); }
78 
80  inline bool operator!=( const HistoryActionID & lhs, const HistoryActionID & rhs )
81  { return lhs.toEnum() != rhs.toEnum(); }
82 
84  std::ostream & operator << (std::ostream & str, const HistoryActionID & id);
86 
101  {
102  public:
103  typedef shared_ptr<HistoryLogData> Ptr;
104  typedef shared_ptr<const HistoryLogData> constPtr;
105 
106  typedef std::vector<std::string> FieldVector;
108  typedef FieldVector::const_iterator const_iterator;
109 
110  public:
115  explicit HistoryLogData( FieldVector & fields_r, size_type expect_r = 2 );
116 
121  HistoryLogData( FieldVector & fields_r, HistoryActionID action_r, size_type expect_r = 2 );
122 
124  virtual ~HistoryLogData();
125 
136  static Ptr create( FieldVector & fields_r );
137 
138  public:
140  bool empty() const;
141 
143  size_type size() const;
144 
146  const_iterator begin() const;
147 
149  const_iterator end() const;
150 
155  const std::string & optionalAt( size_type idx_r ) const;
157  const std::string & operator[]( size_type idx_r ) const
158  { return optionalAt( idx_r ); }
159 
164  const std::string & at( size_type idx_r ) const;
165 
166  public:
167  enum Index
168  {
171  };
172 
173  public:
174  Date date() const;
175  HistoryActionID action() const;
176 
177  public:
178  class Impl;
179  private:
181  protected:
183  };
184 
186  std::ostream & operator<<( std::ostream & str, const HistoryLogData & obj );
188 
195  {
196  public:
197  typedef shared_ptr<HistoryLogDataInstall> Ptr;
198  typedef shared_ptr<const HistoryLogDataInstall> constPtr;
202  HistoryLogDataInstall( FieldVector & fields_r );
203 
204  public:
205  enum Index
206  {
216  };
217 
218  public:
219  std::string name() const;
220  Edition edition() const;
221  Arch arch() const;
222  std::string reqby() const;
223  std::string repoAlias() const;
224  CheckSum checksum() const;
225  std::string userdata() const;
226  };
227 
234  {
235  public:
236  typedef shared_ptr<HistoryLogDataRemove> Ptr;
237  typedef shared_ptr<const HistoryLogDataRemove> constPtr;
241  HistoryLogDataRemove( FieldVector & fields_r );
242 
243  public:
244  enum Index
245  {
253  };
254 
255  public:
256  std::string name() const;
257  Edition edition() const;
258  Arch arch() const;
259  std::string reqby() const;
260  std::string userdata() const;
261  };
262 
269  {
270  public:
271  typedef shared_ptr<HistoryLogDataRepoAdd> Ptr;
272  typedef shared_ptr<const HistoryLogDataRepoAdd> constPtr;
276  HistoryLogDataRepoAdd( FieldVector & fields_r );
277 
278  public:
279  enum Index
280  {
286  };
287 
288  public:
289  std::string alias() const;
290  Url url() const;
291  std::string userdata() const;
292  };
293 
300  {
301  public:
302  typedef shared_ptr<HistoryLogDataRepoRemove> Ptr;
303  typedef shared_ptr<const HistoryLogDataRepoRemove> constPtr;
308 
309  public:
310  enum Index
311  {
316  };
317 
318  public:
319  std::string alias() const;
320  std::string userdata() const;
321  };
322 
329  {
330  public:
331  typedef shared_ptr<HistoryLogDataRepoAliasChange> Ptr;
332  typedef shared_ptr<const HistoryLogDataRepoAliasChange> constPtr;
337 
338  public:
339  enum Index
340  {
346  };
347 
348  public:
349  std::string oldAlias() const;
350  std::string newAlias() const;
351  std::string userdata() const;
352  };
353 
360  {
361  public:
362  typedef shared_ptr<HistoryLogDataRepoUrlChange> Ptr;
363  typedef shared_ptr<const HistoryLogDataRepoUrlChange> constPtr;
368 
369  public:
370  enum Index
371  {
377  };
378 
379  public:
380  std::string alias() const;
381  Url newUrl() const;
382  std::string userdata() const;
383  };
384 
385 
386 #if defined(WITH_DEPRECATED_HISTORYITEM_API)
387 
388 
389 
390 
391 
392 
393  class HistoryItem
394  {
395  public:
396  typedef shared_ptr<HistoryItem> Ptr;
397  typedef std::vector<std::string> FieldVector;
398 
399  public:
400  HistoryItem(FieldVector & fields);
401  virtual ~HistoryItem()
402  {}
403 
404  virtual void dumpTo(std::ostream & str) const;
405 
406  public:
407  Date date;
408  HistoryActionID action;
409  };
411 
412 
414  //
415  // CLASS NAME: HistoryItemInstall
416  //
418  class ZYPP_DEPRECATED HistoryItemInstall : public HistoryItem
419  {
420  public:
421  typedef shared_ptr<HistoryItemInstall> Ptr;
422 
423  HistoryItemInstall(FieldVector & fields);
424  virtual ~HistoryItemInstall()
425  {}
426 
427  virtual void dumpTo(std::ostream & str) const;
428 
429  public:
430  std::string name;
431  Edition edition;
432  Arch arch;
433  std::string reqby; // TODO make this a class ReqBy
434  std::string repoalias;
435  CheckSum checksum;
436  };
438 
439 
441  //
442  // CLASS NAME: HistoryItemRemove
443  //
445  class ZYPP_DEPRECATED HistoryItemRemove : public HistoryItem
446  {
447  public:
448  typedef shared_ptr<HistoryItemRemove> Ptr;
449 
450  HistoryItemRemove(FieldVector & fields);
451  virtual ~HistoryItemRemove()
452  {}
453 
454  virtual void dumpTo(std::ostream & str) const;
455 
456  public:
457  std::string name;
458  Edition edition;
459  Arch arch;
460  std::string reqby;
461  };
463 
464 
466  //
467  // CLASS NAME: HistoryItemRepoAdd
468  //
470  class ZYPP_DEPRECATED HistoryItemRepoAdd : public HistoryItem
471  {
472  public:
473  typedef shared_ptr<HistoryItemRepoAdd> Ptr;
474 
475  HistoryItemRepoAdd(FieldVector & fields);
476  virtual ~HistoryItemRepoAdd()
477  {}
478 
479  virtual void dumpTo(std::ostream & str) const;
480 
481  public:
482  std::string alias;
483  Url url;
484  };
486 
487 
489  //
490  // CLASS NAME: HistoryItemRepoRemove
491  //
493  class ZYPP_DEPRECATED HistoryItemRepoRemove : public HistoryItem
494  {
495  public:
497 
498  HistoryItemRepoRemove(FieldVector & fields);
499  virtual ~HistoryItemRepoRemove()
500  {}
501 
502  virtual void dumpTo(std::ostream & str) const;
503 
504  public:
505  std::string alias;
506  };
508 
509 
511  //
512  // CLASS NAME: HistoryItemRepoAliasChange
513  //
515  class ZYPP_DEPRECATED HistoryItemRepoAliasChange : public HistoryItem
516  {
517  public:
519 
520  HistoryItemRepoAliasChange(FieldVector & fields);
521  virtual ~HistoryItemRepoAliasChange()
522  {}
523 
524  virtual void dumpTo(std::ostream & str) const;
525 
526  public:
527  std::string oldalias;
528  std::string newalias;
529  };
531 
532 
534  //
535  // CLASS NAME: HistoryItemRepoUrlChange
536  //
538  class ZYPP_DEPRECATED HistoryItemRepoUrlChange : public HistoryItem
539  {
540  public:
542 
543  HistoryItemRepoUrlChange(FieldVector & fields);
544  virtual ~HistoryItemRepoUrlChange()
545  {}
546 
547  virtual void dumpTo(std::ostream & str) const;
548 
549  public:
550  std::string alias;
551  Url newurl;
552  };
554 
555  std::ostream & operator<<(std::ostream & str, const HistoryItem & obj);
556 #endif // WITH_DEPRECATED_HISTORYITEM_API
557 
558 } // namespace zypp
560 #endif /* ZYPP_HISTORYLOGDATA_H_ */