libzypp 9.41.1
|
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 "base/Deprecated.h" 00019 #include "zypp/Date.h" 00020 #include "zypp/Edition.h" 00021 #include "zypp/Arch.h" 00022 #include "zypp/CheckSum.h" 00023 #include "zypp/Url.h" 00024 00025 #define HISTORY_LOG_DATE_FORMAT "%Y-%m-%d %H:%M:%S" 00026 00028 namespace zypp 00029 { 00036 struct HistoryActionID 00037 { 00038 static const HistoryActionID NONE; 00039 00040 static const HistoryActionID INSTALL; 00041 static const HistoryActionID REMOVE; 00042 static const HistoryActionID REPO_ADD; 00043 static const HistoryActionID REPO_REMOVE; 00044 static const HistoryActionID REPO_CHANGE_ALIAS; 00045 static const HistoryActionID REPO_CHANGE_URL; 00046 00047 enum ID 00048 { 00049 NONE_e, 00050 00051 INSTALL_e, 00052 REMOVE_e, 00053 REPO_ADD_e, 00054 REPO_REMOVE_e, 00055 REPO_CHANGE_ALIAS_e, 00056 REPO_CHANGE_URL_e 00057 }; 00058 00059 HistoryActionID() : _id(NONE_e) {} 00060 00061 HistoryActionID(ID id) : _id(id) {} 00062 00063 explicit HistoryActionID(const std::string & strval_r); 00064 00065 ID toEnum() const { return _id; } 00066 00067 static HistoryActionID::ID parse(const std::string & strval_r); 00068 00069 const std::string & asString(bool pad = false) const; 00070 00071 private: 00072 ID _id; 00073 }; 00074 00076 inline bool operator==( const HistoryActionID & lhs, const HistoryActionID & rhs ) 00077 { return lhs.toEnum() == rhs.toEnum(); } 00078 00080 inline bool operator!=( const HistoryActionID & lhs, const HistoryActionID & rhs ) 00081 { return lhs.toEnum() != rhs.toEnum(); } 00082 00084 std::ostream & operator << (std::ostream & str, const HistoryActionID & id); 00086 00100 class HistoryLogData 00101 { 00102 public: 00103 typedef shared_ptr<HistoryLogData> Ptr; 00104 typedef shared_ptr<const HistoryLogData> constPtr; 00105 00106 typedef std::vector<std::string> FieldVector; 00107 typedef FieldVector::size_type size_type; 00108 typedef FieldVector::const_iterator const_iterator; 00109 00110 public: 00115 explicit HistoryLogData( FieldVector & fields_r, size_type expect_r = 2 ); 00116 00121 HistoryLogData( FieldVector & fields_r, HistoryActionID action_r, size_type expect_r = 2 ); 00122 00124 virtual ~HistoryLogData(); 00125 00136 static Ptr create( FieldVector & fields_r ); 00137 00138 public: 00140 bool empty() const; 00141 00143 size_type size() const; 00144 00146 const_iterator begin() const; 00147 00149 const_iterator end() const; 00150 00155 const std::string & optionalAt( size_type idx_r ) const; 00157 const std::string & operator[]( size_type idx_r ) const 00158 { return optionalAt( idx_r ); } 00159 00164 const std::string & at( size_type idx_r ) const; 00165 00166 public: 00167 enum Index 00168 { 00169 DATE_INDEX = 0, 00170 ACTION_INDEX = 1, 00171 }; 00172 00173 public: 00174 Date date() const; 00175 HistoryActionID action() const; 00176 00177 public: 00178 class Impl; 00179 private: 00180 RWCOW_pointer<Impl> _pimpl; 00181 protected: 00182 HistoryLogData & operator=( const HistoryLogData & ); 00183 }; 00184 00186 std::ostream & operator<<( std::ostream & str, const HistoryLogData & obj ); 00188 00194 class HistoryLogDataInstall : public HistoryLogData 00195 { 00196 public: 00197 typedef shared_ptr<HistoryLogDataInstall> Ptr; 00198 typedef shared_ptr<const HistoryLogDataInstall> constPtr; 00202 HistoryLogDataInstall( FieldVector & fields_r ); 00203 00204 public: 00205 enum Index 00206 { 00207 DATE_INDEX = HistoryLogData::DATE_INDEX, 00208 ACTION_INDEX = HistoryLogData::ACTION_INDEX, 00209 NAME_INDEX, 00210 EDITION_INDEX, 00211 ARCH_INDEX, 00212 REQBY_INDEX, 00213 REPOALIAS_INDEX, 00214 CHEKSUM_INDEX, 00215 USERDATA_INDEX, 00216 }; 00217 00218 public: 00219 std::string name() const; 00220 Edition edition() const; 00221 Arch arch() const; 00222 std::string reqby() const; 00223 std::string repoAlias() const; 00224 CheckSum checksum() const; 00225 std::string userdata() const; 00226 }; 00227 00233 class HistoryLogDataRemove : public HistoryLogData 00234 { 00235 public: 00236 typedef shared_ptr<HistoryLogDataRemove> Ptr; 00237 typedef shared_ptr<const HistoryLogDataRemove> constPtr; 00241 HistoryLogDataRemove( FieldVector & fields_r ); 00242 00243 public: 00244 enum Index 00245 { 00246 DATE_INDEX = HistoryLogData::DATE_INDEX, 00247 ACTION_INDEX = HistoryLogData::ACTION_INDEX, 00248 NAME_INDEX, 00249 EDITION_INDEX, 00250 ARCH_INDEX, 00251 REQBY_INDEX, 00252 USERDATA_INDEX, 00253 }; 00254 00255 public: 00256 std::string name() const; 00257 Edition edition() const; 00258 Arch arch() const; 00259 std::string reqby() const; 00260 std::string userdata() const; 00261 }; 00262 00268 class HistoryLogDataRepoAdd : public HistoryLogData 00269 { 00270 public: 00271 typedef shared_ptr<HistoryLogDataRepoAdd> Ptr; 00272 typedef shared_ptr<const HistoryLogDataRepoAdd> constPtr; 00276 HistoryLogDataRepoAdd( FieldVector & fields_r ); 00277 00278 public: 00279 enum Index 00280 { 00281 DATE_INDEX = HistoryLogData::DATE_INDEX, 00282 ACTION_INDEX = HistoryLogData::ACTION_INDEX, 00283 ALIAS_INDEX, 00284 URL_INDEX, 00285 USERDATA_INDEX, 00286 }; 00287 00288 public: 00289 std::string alias() const; 00290 Url url() const; 00291 std::string userdata() const; 00292 }; 00293 00299 class HistoryLogDataRepoRemove : public HistoryLogData 00300 { 00301 public: 00302 typedef shared_ptr<HistoryLogDataRepoRemove> Ptr; 00303 typedef shared_ptr<const HistoryLogDataRepoRemove> constPtr; 00307 HistoryLogDataRepoRemove( FieldVector & fields_r ); 00308 00309 public: 00310 enum Index 00311 { 00312 DATE_INDEX = HistoryLogData::DATE_INDEX, 00313 ACTION_INDEX = HistoryLogData::ACTION_INDEX, 00314 ALIAS_INDEX, 00315 USERDATA_INDEX, 00316 }; 00317 00318 public: 00319 std::string alias() const; 00320 std::string userdata() const; 00321 }; 00322 00328 class HistoryLogDataRepoAliasChange : public HistoryLogData 00329 { 00330 public: 00331 typedef shared_ptr<HistoryLogDataRepoAliasChange> Ptr; 00332 typedef shared_ptr<const HistoryLogDataRepoAliasChange> constPtr; 00336 HistoryLogDataRepoAliasChange( FieldVector & fields_r ); 00337 00338 public: 00339 enum Index 00340 { 00341 DATE_INDEX = HistoryLogData::DATE_INDEX, 00342 ACTION_INDEX = HistoryLogData::ACTION_INDEX, 00343 OLDALIAS_INDEX, 00344 NEWALIAS_INDEX, 00345 USERDATA_INDEX, 00346 }; 00347 00348 public: 00349 std::string oldAlias() const; 00350 std::string newAlias() const; 00351 std::string userdata() const; 00352 }; 00353 00359 class HistoryLogDataRepoUrlChange : public HistoryLogData 00360 { 00361 public: 00362 typedef shared_ptr<HistoryLogDataRepoUrlChange> Ptr; 00363 typedef shared_ptr<const HistoryLogDataRepoUrlChange> constPtr; 00367 HistoryLogDataRepoUrlChange( FieldVector & fields_r ); 00368 00369 public: 00370 enum Index 00371 { 00372 DATE_INDEX = HistoryLogData::DATE_INDEX, 00373 ACTION_INDEX = HistoryLogData::ACTION_INDEX, 00374 ALIAS_INDEX, 00375 NEWURL_INDEX, 00376 USERDATA_INDEX, 00377 }; 00378 00379 public: 00380 std::string alias() const; 00381 Url newUrl() const; 00382 std::string userdata() const; 00383 }; 00384 00385 00386 #if defined(WITH_DEPRECATED_HISTORYITEM_API) 00387 00388 00389 00390 00391 00392 00393 class HistoryItem 00394 { 00395 public: 00396 typedef shared_ptr<HistoryItem> Ptr; 00397 typedef std::vector<std::string> FieldVector; 00398 00399 public: 00400 HistoryItem(FieldVector & fields); 00401 virtual ~HistoryItem() 00402 {} 00403 00404 virtual void dumpTo(std::ostream & str) const; 00405 00406 public: 00407 Date date; 00408 HistoryActionID action; 00409 }; 00411 00412 00414 // 00415 // CLASS NAME: HistoryItemInstall 00416 // 00418 class ZYPP_DEPRECATED HistoryItemInstall : public HistoryItem 00419 { 00420 public: 00421 typedef shared_ptr<HistoryItemInstall> Ptr; 00422 00423 HistoryItemInstall(FieldVector & fields); 00424 virtual ~HistoryItemInstall() 00425 {} 00426 00427 virtual void dumpTo(std::ostream & str) const; 00428 00429 public: 00430 std::string name; 00431 Edition edition; 00432 Arch arch; 00433 std::string reqby; // TODO make this a class ReqBy 00434 std::string repoalias; 00435 CheckSum checksum; 00436 }; 00438 00439 00441 // 00442 // CLASS NAME: HistoryItemRemove 00443 // 00445 class ZYPP_DEPRECATED HistoryItemRemove : public HistoryItem 00446 { 00447 public: 00448 typedef shared_ptr<HistoryItemRemove> Ptr; 00449 00450 HistoryItemRemove(FieldVector & fields); 00451 virtual ~HistoryItemRemove() 00452 {} 00453 00454 virtual void dumpTo(std::ostream & str) const; 00455 00456 public: 00457 std::string name; 00458 Edition edition; 00459 Arch arch; 00460 std::string reqby; 00461 }; 00463 00464 00466 // 00467 // CLASS NAME: HistoryItemRepoAdd 00468 // 00470 class ZYPP_DEPRECATED HistoryItemRepoAdd : public HistoryItem 00471 { 00472 public: 00473 typedef shared_ptr<HistoryItemRepoAdd> Ptr; 00474 00475 HistoryItemRepoAdd(FieldVector & fields); 00476 virtual ~HistoryItemRepoAdd() 00477 {} 00478 00479 virtual void dumpTo(std::ostream & str) const; 00480 00481 public: 00482 std::string alias; 00483 Url url; 00484 }; 00486 00487 00489 // 00490 // CLASS NAME: HistoryItemRepoRemove 00491 // 00493 class ZYPP_DEPRECATED HistoryItemRepoRemove : public HistoryItem 00494 { 00495 public: 00496 typedef shared_ptr<HistoryItemRepoRemove> Ptr; 00497 00498 HistoryItemRepoRemove(FieldVector & fields); 00499 virtual ~HistoryItemRepoRemove() 00500 {} 00501 00502 virtual void dumpTo(std::ostream & str) const; 00503 00504 public: 00505 std::string alias; 00506 }; 00508 00509 00511 // 00512 // CLASS NAME: HistoryItemRepoAliasChange 00513 // 00515 class ZYPP_DEPRECATED HistoryItemRepoAliasChange : public HistoryItem 00516 { 00517 public: 00518 typedef shared_ptr<HistoryItemRepoAliasChange> Ptr; 00519 00520 HistoryItemRepoAliasChange(FieldVector & fields); 00521 virtual ~HistoryItemRepoAliasChange() 00522 {} 00523 00524 virtual void dumpTo(std::ostream & str) const; 00525 00526 public: 00527 std::string oldalias; 00528 std::string newalias; 00529 }; 00531 00532 00534 // 00535 // CLASS NAME: HistoryItemRepoUrlChange 00536 // 00538 class ZYPP_DEPRECATED HistoryItemRepoUrlChange : public HistoryItem 00539 { 00540 public: 00541 typedef shared_ptr<HistoryItemRepoUrlChange> Ptr; 00542 00543 HistoryItemRepoUrlChange(FieldVector & fields); 00544 virtual ~HistoryItemRepoUrlChange() 00545 {} 00546 00547 virtual void dumpTo(std::ostream & str) const; 00548 00549 public: 00550 std::string alias; 00551 Url newurl; 00552 }; 00554 00555 std::ostream & operator<<(std::ostream & str, const HistoryItem & obj); 00556 #endif // WITH_DEPRECATED_HISTORYITEM_API 00557 00558 } // namespace zypp 00560 #endif /* ZYPP_HISTORYLOGDATA_H_ */