libzypp  10.5.0
HistoryLogData.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00009 
00013 #ifndef ZYPP_HISTORYLOGDATA_H_
00014 #define ZYPP_HISTORYLOGDATA_H_
00015 
00016 #include <iosfwd>
00017 
00018 #include "zypp/Date.h"
00019 #include "zypp/Edition.h"
00020 #include "zypp/Arch.h"
00021 #include "zypp/CheckSum.h"
00022 #include "zypp/Url.h"
00023 
00024 #define HISTORY_LOG_DATE_FORMAT "%Y-%m-%d %H:%M:%S"
00025 
00026 namespace zypp
00027 {
00028 
00029 
00031   //
00032   //  CLASS NAME : HistoryActionID
00033   //
00039   struct HistoryActionID
00040   {
00041     static const HistoryActionID NONE;
00042 
00043     static const HistoryActionID INSTALL;
00044     static const HistoryActionID REMOVE;
00045     static const HistoryActionID REPO_ADD;
00046     static const HistoryActionID REPO_REMOVE;
00047     static const HistoryActionID REPO_CHANGE_ALIAS;
00048     static const HistoryActionID REPO_CHANGE_URL;
00049 
00050     enum ID
00051     {
00052       NONE_e,
00053 
00054       INSTALL_e,
00055       REMOVE_e,
00056       REPO_ADD_e,
00057       REPO_REMOVE_e,
00058       REPO_CHANGE_ALIAS_e,
00059       REPO_CHANGE_URL_e
00060     };
00061 
00062     HistoryActionID() : _id(NONE_e) {}
00063 
00064     HistoryActionID(ID id) : _id(id) {}
00065 
00066     explicit HistoryActionID(const std::string & strval_r);
00067 
00068     ID toEnum() const { return _id; }
00069 
00070     static HistoryActionID::ID parse(const std::string & strval_r);
00071 
00072     const std::string & asString(bool pad = false) const;
00073 
00074     private:
00075     ID _id;
00076   };
00077 
00079   std::ostream & operator << (std::ostream & str, const HistoryActionID & id);
00081 
00082 
00084   //
00085   // CLASS NAME: HistoryItem
00086   //
00087   class HistoryItem
00088   {
00089   public:
00090     typedef shared_ptr<HistoryItem> Ptr;
00091     typedef std::vector<std::string> FieldVector;
00092 
00093   public:
00094     HistoryItem(FieldVector & fields);
00095     virtual ~HistoryItem()
00096     {}
00097 
00098     virtual void dumpTo(std::ostream & str) const;
00099 
00100   public:
00101     Date date;
00102     HistoryActionID action;
00103   };
00105 
00106 
00108   //
00109   // CLASS NAME: HistoryItemInstall
00110   //
00111   class HistoryItemInstall : public HistoryItem
00112   {
00113   public:
00114     typedef shared_ptr<HistoryItemInstall> Ptr;
00115 
00116     HistoryItemInstall(FieldVector & fields);
00117     virtual ~HistoryItemInstall()
00118     {}
00119 
00120     virtual void dumpTo(std::ostream & str) const;
00121 
00122   public:
00123     std::string   name;
00124     Edition       edition;
00125     Arch          arch;
00126     std::string   reqby; // TODO make this a class ReqBy
00127     std::string   repoalias;
00128     CheckSum      checksum;
00129   };
00131 
00132 
00134   //
00135   // CLASS NAME: HistoryItemRemove
00136   //
00137   class HistoryItemRemove : public HistoryItem
00138   {
00139   public:
00140     typedef shared_ptr<HistoryItemRemove> Ptr;
00141 
00142     HistoryItemRemove(FieldVector & fields);
00143     virtual ~HistoryItemRemove()
00144     {}
00145 
00146     virtual void dumpTo(std::ostream & str)  const;
00147 
00148   public:
00149     std::string name;
00150     Edition     edition;
00151     Arch        arch;
00152     std::string reqby;
00153   };
00155 
00156 
00158   //
00159   // CLASS NAME: HistoryItemRepoAdd
00160   //
00161   class HistoryItemRepoAdd : public HistoryItem
00162   {
00163   public:
00164     typedef shared_ptr<HistoryItemRepoAdd> Ptr;
00165 
00166     HistoryItemRepoAdd(FieldVector & fields);
00167     virtual ~HistoryItemRepoAdd()
00168     {}
00169 
00170     virtual void dumpTo(std::ostream & str) const;
00171 
00172   public:
00173     std::string alias;
00174     Url         url;
00175   };
00177 
00178 
00180   //
00181   // CLASS NAME: HistoryItemRepoRemove
00182   //
00183   class HistoryItemRepoRemove : public HistoryItem
00184   {
00185   public:
00186     typedef shared_ptr<HistoryItemRepoRemove> Ptr;
00187 
00188     HistoryItemRepoRemove(FieldVector & fields);
00189     virtual ~HistoryItemRepoRemove()
00190     {}
00191 
00192     virtual void dumpTo(std::ostream & str) const;
00193 
00194   public:
00195     std::string alias;
00196   };
00198 
00199 
00201   //
00202   // CLASS NAME: HistoryItemRepoAliasChange
00203   //
00204   class HistoryItemRepoAliasChange : public HistoryItem
00205   {
00206   public:
00207     typedef shared_ptr<HistoryItemRepoAliasChange> Ptr;
00208 
00209     HistoryItemRepoAliasChange(FieldVector & fields);
00210     virtual ~HistoryItemRepoAliasChange()
00211     {}
00212 
00213     virtual void dumpTo(std::ostream & str) const;
00214 
00215   public:
00216     std::string oldalias;
00217     std::string newalias;
00218   };
00220 
00221 
00223   //
00224   // CLASS NAME: HistoryItemRepoUrlChange
00225   //
00226   class HistoryItemRepoUrlChange : public HistoryItem
00227   {
00228   public:
00229     typedef shared_ptr<HistoryItemRepoUrlChange> Ptr;
00230 
00231     HistoryItemRepoUrlChange(FieldVector & fields);
00232     virtual ~HistoryItemRepoUrlChange()
00233     {}
00234 
00235     virtual void dumpTo(std::ostream & str) const;
00236 
00237   public:
00238     std::string alias;
00239     Url newurl;
00240   };
00242 
00243   std::ostream & operator<<(std::ostream & str, const HistoryItem & obj);
00244 
00245 }
00246 
00247 #endif /* ZYPP_HISTORYLOGDATA_H_ */