From 7627422c9850c5d45431566b624a924e2e6ba41a Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Tue, 12 Jun 2007 11:48:09 +0000 Subject: [PATCH] atom and script implementation --- zypp/CMakeLists.txt | 4 + zypp/detail/ScriptImplIf.cc | 3 - zypp/detail/ScriptImplIf.h | 2 - zypp/repo/cached/AtomImpl.cc | 120 ++++++++++++++++++++++++++++ zypp/repo/cached/AtomImpl.h | 61 ++++++++++++++ zypp/repo/cached/ScriptImpl.cc | 140 +++++++++++++++++++++++++++++++++ zypp/repo/cached/ScriptImpl.h | 66 ++++++++++++++++ 7 files changed, 391 insertions(+), 5 deletions(-) create mode 100644 zypp/repo/cached/AtomImpl.cc create mode 100644 zypp/repo/cached/AtomImpl.h create mode 100644 zypp/repo/cached/ScriptImpl.cc create mode 100644 zypp/repo/cached/ScriptImpl.h diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt index 24aab7ecf..5e217f7c8 100644 --- a/zypp/CMakeLists.txt +++ b/zypp/CMakeLists.txt @@ -1085,6 +1085,8 @@ SET( zypp_repository_cached_SRCS repo/cached/PatternImpl.cc repo/cached/ProductImpl.cc repo/cached/MessageImpl.cc + repo/cached/ScriptImpl.cc + repo/cached/AtomImpl.cc ) SET( zypp_repository_cached_HEADERS @@ -1094,6 +1096,8 @@ SET( zypp_repository_cached_HEADERS repo/cached/PatternImpl.h repo/cached/ProductImpl.h repo/cached/MessageImpl.h + repo/cached/ScriptImpl.h + repo/cached/AtomImpl.h ) SET( zypp_repository_data_SRCS diff --git a/zypp/detail/ScriptImplIf.cc b/zypp/detail/ScriptImplIf.cc index 73b6d6a14..d17c61935 100644 --- a/zypp/detail/ScriptImplIf.cc +++ b/zypp/detail/ScriptImplIf.cc @@ -32,9 +32,6 @@ namespace zypp bool ScriptImplIf::undo_available() const { return false; } - ByteCount ScriptImplIf::size() const - { return ResObjectImplIf::size(); } - ///////////////////////////////////////////////////////////////// } // namespace detail /////////////////////////////////////////////////////////////////// diff --git a/zypp/detail/ScriptImplIf.h b/zypp/detail/ScriptImplIf.h index fe1ff5419..6e5fbf10b 100644 --- a/zypp/detail/ScriptImplIf.h +++ b/zypp/detail/ScriptImplIf.h @@ -43,8 +43,6 @@ namespace zypp virtual Pathname undo_script() const PURE_VIRTUAL; /** Check whether script to undo the change is available */ virtual bool undo_available() const PURE_VIRTUAL; - /** */ - virtual ByteCount size() const; }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/repo/cached/AtomImpl.cc b/zypp/repo/cached/AtomImpl.cc new file mode 100644 index 000000000..43c33e82c --- /dev/null +++ b/zypp/repo/cached/AtomImpl.cc @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ + +#include "zypp/TranslatedText.h" +#include "zypp/base/String.h" +#include "zypp/base/Logger.h" +#include "zypp/repo/RepositoryImpl.h" +#include "AtomImpl.h" + + +using namespace std; +using namespace zypp::detail; +using namespace::zypp::repo; + +/////////////////////////////////////////////////////////////////// +namespace zypp { namespace repo { namespace cached { + +/////////////////////////////////////////////////////////////////// +// +// CLASS NAME : AtomImpl +// +/////////////////////////////////////////////////////////////////// + +/** Default ctor +*/ +AtomImpl::AtomImpl (const data::RecordId &id, cached::RepoImpl::Ptr repository_r) + : _repository (repository_r), + _id(id) +{} + +Repository +AtomImpl::repository() const +{ + return _repository->selfRepository(); +} + +/////////////////////////////////////////////////// +// ResObject Attributes +/////////////////////////////////////////////////// + +TranslatedText AtomImpl::summary() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "summary" ); +} + +TranslatedText AtomImpl::description() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "description" ); +} + +TranslatedText AtomImpl::insnotify() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "insnotify" ); +} + +TranslatedText AtomImpl::delnotify() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "delnotify" ); +} + +TranslatedText AtomImpl::licenseToConfirm() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "licenseToConfirm" ); +} + +Vendor AtomImpl::vendor() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "ResObject", "vendor" ); +} + + +ByteCount AtomImpl::size() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "size" ); +} + +ByteCount AtomImpl::archivesize() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "archivesize" ); +} + +bool AtomImpl::installOnly() const +{ + return _repository->resolvableQuery().queryBooleanAttribute( _id, "ResObject", "installOnly" ); +} + +Date AtomImpl::buildtime() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "buildtime" ); +} + +Date AtomImpl::installtime() const +{ + return Date(); +} + +////////////////////////////////////////// +// DEPRECATED +////////////////////////////////////////// + +Source_Ref AtomImpl::source() const +{ + return Source_Ref::noSource; +} + +unsigned AtomImpl::sourceMediaNr() const +{ + return 1; +} + +///////////////////////////////////////////////////////////////// +} } } // namespace zypp::repo::cached +/////////////////////////////////////////////////////////////////// + diff --git a/zypp/repo/cached/AtomImpl.h b/zypp/repo/cached/AtomImpl.h new file mode 100644 index 000000000..d4e73be4d --- /dev/null +++ b/zypp/repo/cached/AtomImpl.h @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ + +#ifndef zypp_repo_cached_AtomImpl_H +#define zypp_repo_cached_AtomImpl_H + +#include "zypp/detail/AtomImpl.h" +#include "zypp/repo/cached/RepoImpl.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// +namespace repo +{ ///////////////////////////////////////////////////////////////// +namespace cached +{ ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : AtomImpl + // + class AtomImpl : public detail::AtomImplIf + { + public: + + AtomImpl( const data::RecordId &id, repo::cached::RepoImpl::Ptr repository_r ); + + virtual TranslatedText summary() const; + virtual TranslatedText description() const; + virtual TranslatedText insnotify() const; + virtual TranslatedText delnotify() const; + virtual TranslatedText licenseToConfirm() const; + virtual Vendor vendor() const; + virtual ByteCount size() const; + virtual ByteCount archivesize() const; + virtual bool installOnly() const; + virtual Date buildtime() const; + virtual Date installtime() const; + + virtual Source_Ref source() const; + virtual unsigned sourceMediaNr() const; + + virtual Repository repository() const; + + protected: + repo::cached::RepoImpl::Ptr _repository; + data::RecordId _id; + }; + ///////////////////////////////////////////////////////////////// +} // namespace cached +} // namespace repository +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZMD_BACKEND_DBSOURCE_DBPACKAGEIMPL_H + diff --git a/zypp/repo/cached/ScriptImpl.cc b/zypp/repo/cached/ScriptImpl.cc new file mode 100644 index 000000000..d2a415b80 --- /dev/null +++ b/zypp/repo/cached/ScriptImpl.cc @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ + +#include "zypp/TranslatedText.h" +#include "zypp/base/String.h" +#include "zypp/base/Logger.h" +#include "zypp/repo/RepositoryImpl.h" +#include "ScriptImpl.h" + + +using namespace std; +using namespace zypp::detail; +using namespace::zypp::repo; + +/////////////////////////////////////////////////////////////////// +namespace zypp { namespace repo { namespace cached { + +/////////////////////////////////////////////////////////////////// +// +// CLASS NAME : ScriptImpl +// +/////////////////////////////////////////////////////////////////// + +/** Default ctor +*/ +ScriptImpl::ScriptImpl (const data::RecordId &id, cached::RepoImpl::Ptr repository_r) + : _repository (repository_r), + _id(id) +{} + +Repository +ScriptImpl::repository() const +{ + return _repository->selfRepository(); +} + +/////////////////////////////////////////////////// +// ResObject Attributes +/////////////////////////////////////////////////// + +TranslatedText ScriptImpl::summary() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "summary" ); +} + +TranslatedText ScriptImpl::description() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "description" ); +} + +TranslatedText ScriptImpl::insnotify() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "insnotify" ); +} + +TranslatedText ScriptImpl::delnotify() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "delnotify" ); +} + +TranslatedText ScriptImpl::licenseToConfirm() const +{ + return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "licenseToConfirm" ); +} + +Vendor ScriptImpl::vendor() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "ResObject", "vendor" ); +} + + +ByteCount ScriptImpl::size() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "size" ); +} + +ByteCount ScriptImpl::archivesize() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "archivesize" ); +} + +bool ScriptImpl::installOnly() const +{ + return _repository->resolvableQuery().queryBooleanAttribute( _id, "ResObject", "installOnly" ); +} + +Date ScriptImpl::buildtime() const +{ + return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "buildtime" ); +} + +Date ScriptImpl::installtime() const +{ + return Date(); +} + +////////////////////////////////////////// +// DEPRECATED +////////////////////////////////////////// + +Source_Ref ScriptImpl::source() const +{ + return Source_Ref::noSource; +} + +unsigned ScriptImpl::sourceMediaNr() const +{ + return 1; +} + +////////////////////////////////////////// +// MESSAGE +///////////////////////////////////////// + +Pathname ScriptImpl::do_script() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Script", "doScript" ); +} + +Pathname ScriptImpl::undo_script() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, "Script", "undoScript" ); +} + +bool ScriptImpl::undo_available() const +{ + return _repository->resolvableQuery().queryBooleanAttribute( _id, "Script", "undoAvailable", false ); +} + + +///////////////////////////////////////////////////////////////// +} } } // namespace zypp::repo::cached +/////////////////////////////////////////////////////////////////// + diff --git a/zypp/repo/cached/ScriptImpl.h b/zypp/repo/cached/ScriptImpl.h new file mode 100644 index 000000000..e1cf2dc92 --- /dev/null +++ b/zypp/repo/cached/ScriptImpl.h @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ + +#ifndef zypp_repo_cached_ScriptImpl_H +#define zypp_repo_cached_ScriptImpl_H + +#include "zypp/detail/ScriptImpl.h" +#include "zypp/repo/cached/RepoImpl.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// +namespace repo +{ ///////////////////////////////////////////////////////////////// +namespace cached +{ ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : ScriptImpl + // + class ScriptImpl : public detail::ScriptImplIf + { + public: + + ScriptImpl( const data::RecordId &id, repo::cached::RepoImpl::Ptr repository_r ); + + virtual TranslatedText summary() const; + virtual TranslatedText description() const; + virtual TranslatedText insnotify() const; + virtual TranslatedText delnotify() const; + virtual TranslatedText licenseToConfirm() const; + virtual Vendor vendor() const; + virtual ByteCount size() const; + virtual ByteCount archivesize() const; + virtual bool installOnly() const; + virtual Date buildtime() const; + virtual Date installtime() const; + + virtual Source_Ref source() const; + virtual unsigned sourceMediaNr() const; + + // SCRIPT + virtual Pathname do_script() const; + virtual Pathname undo_script() const; + virtual bool undo_available() const; + + virtual Repository repository() const; + + protected: + repo::cached::RepoImpl::Ptr _repository; + data::RecordId _id; + }; + ///////////////////////////////////////////////////////////////// +} // namespace cached +} // namespace repository +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZMD_BACKEND_DBSOURCE_DBPACKAGEIMPL_H + -- 2.34.1