From 49bcb5f823a814fbbcba31f3fb8bc39cee040441 Mon Sep 17 00:00:00 2001 From: Jiri Srain Date: Tue, 25 Oct 2005 15:47:21 +0000 Subject: [PATCH] backup --- test/devel.jsrain/Makefile.am | 7 +- test/devel.jsrain/Msg.cc | 16 ---- test/devel.jsrain/Patch.cc | 13 --- test/devel.jsrain/PatchSelect.cc | 166 +++++++++++++++++++++++++++++++++++++++ test/devel.jsrain/Script.cc | 16 ---- zypp/Makefile.am | 6 +- zypp/Message.cc | 11 ++- zypp/Message.h | 6 +- zypp/Patch.cc | 53 ++++++------- zypp/Patch.h | 23 +++--- zypp/Product.cc | 57 ++++++++++++++ zypp/Product.h | 57 ++++++++++++++ zypp/Script.cc | 15 ++-- zypp/Script.h | 8 +- zypp/detail/Makefile.am | 6 +- zypp/detail/MessageImpl.cc | 11 +-- zypp/detail/MessageImpl.h | 8 +- zypp/detail/PatchImpl.cc | 55 +++++++------ zypp/detail/PatchImpl.h | 26 +++--- zypp/detail/ProductImpl.cc | 60 ++++++++++++++ zypp/detail/ProductImpl.h | 62 +++++++++++++++ zypp/detail/ScriptImpl.cc | 15 ++-- zypp/detail/ScriptImpl.h | 10 +-- 23 files changed, 525 insertions(+), 182 deletions(-) create mode 100644 test/devel.jsrain/PatchSelect.cc create mode 100644 zypp/Product.cc create mode 100644 zypp/Product.h create mode 100644 zypp/detail/ProductImpl.cc create mode 100644 zypp/detail/ProductImpl.h diff --git a/test/devel.jsrain/Makefile.am b/test/devel.jsrain/Makefile.am index 3980618..765195f 100644 --- a/test/devel.jsrain/Makefile.am +++ b/test/devel.jsrain/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in ## ################################################## -noinst_PROGRAMS = Main Main.debug Msg Msg.debug Patch Patch.debug Script Script.debug +noinst_PROGRAMS = Main Main.debug Msg Msg.debug Patch Patch.debug Script Script.debug PatchSelect PatchSelect.debug ## ################################################## @@ -35,6 +35,11 @@ Script_SOURCES = Script.cc Script_debug_SOURCES = $(Script_SOURCES) Script_debug_LDFLAGS = -static +PatchSelect_SOURCES = PatchSelect.cc + +PatchSelect_debug_SOURCES = $(PatchSelect_SOURCES) +PatchSelect_debug_LDFLAGS = -static + ## ################################################## .PHONY: always diff --git a/test/devel.jsrain/Msg.cc b/test/devel.jsrain/Msg.cc index 4cf0bd3..b72f298 100644 --- a/test/devel.jsrain/Msg.cc +++ b/test/devel.jsrain/Msg.cc @@ -1,21 +1,5 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include -#include - -/////////////////////////////////////////////////////////////////// - -#include #include diff --git a/test/devel.jsrain/Patch.cc b/test/devel.jsrain/Patch.cc index ebc91cb..5cc825d 100644 --- a/test/devel.jsrain/Patch.cc +++ b/test/devel.jsrain/Patch.cc @@ -1,23 +1,10 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include -#include /////////////////////////////////////////////////////////////////// #include #include -#include #include #include #include diff --git a/test/devel.jsrain/PatchSelect.cc b/test/devel.jsrain/PatchSelect.cc new file mode 100644 index 0000000..c8cef5f --- /dev/null +++ b/test/devel.jsrain/PatchSelect.cc @@ -0,0 +1,166 @@ +#include +#include + +/////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include + +#include +#include + + +using namespace std; +using namespace zypp; + +DEFINE_PTR_TYPE(MyPatchImpl) + +class MyPatchImpl : public detail::PatchImpl +{ + public: + MyPatchImpl( std::string name, + std::list atoms, + std::string category) + : PatchImpl (name, + Edition (), + Arch ("noarch")) + { + _reboot_needed = false; + _atoms = atoms; + _category = category; + } +}; + +/****************************************************************** +** +** +** FUNCTION NAME : main +** FUNCTION TYPE : int +** +** DESCRIPTION : +*/ +int main( int argc, char * argv[] ) +{ + INT << "===[START]==========================================" << endl; + + atom_list atoms; + + std::string _name( "foo" ); + Edition _edition( "1.0", "42" ); + Arch _arch( "i386" ); + detail::PackageImplPtr pi( new detail::PackageImpl(_name,_edition,_arch) ); + PackagePtr p (new Package (pi)); + atoms.push_back (p); + + std::string _name2( "bar" ); + Edition _edition2( "1.0", "43" ); + Arch _arch2( "noarch" ); + detail::PackageImplPtr pi2(new detail::PackageImpl(_name2,_edition2,_arch2)); + PackagePtr p2 (new Package (pi2)); + atoms.push_back (p2); + + MyPatchImplPtr q (new MyPatchImpl ("patch1", atoms, "recommended")); + PatchPtr patch1 (new Patch (q)); + + atom_list atoms2; + std::string _name3( "msg" ); + Arch _arch3( "noarch" ); + detail::MessageImplPtr mi(new detail::MessageImpl(_name3,Edition (),_arch3)); + MessagePtr m (new Message (mi)); + atoms2.push_back (m); + + MyPatchImplPtr q2 (new MyPatchImpl ("patch2", atoms2, "recommended")); + PatchPtr patch2 (new Patch (q2)); + + list patches; + patches.push_back (patch1); + patches.push_back (patch2); + + // input values + bool interactive_run = true; + set levels_to_preselect; + levels_to_preselect.insert ("security"); + levels_to_preselect.insert ("recommended"); + + // output values + list patches_to_display; + list patches_for_manual; + +// really start here + + // count patches to offer + if (interactive_run) + { + for (list::iterator it = patches.begin(); + it != patches.end(); + it++) + { + (*it)->select (); + } + DBG << "Running solver here..." << endl; // TODO + for (list::iterator it = patches.begin(); + it != patches.end(); + it++) + { + if ((*it)->any_atom_selected()) + { + patches_to_display.push_back( *it ); + } + (*it)->select(); + } + } + + // count patches to preselect + for (list::iterator it = patches.begin(); + it != patches.end(); + it++) + { + PatchPtr ptr = *it; + string category = ptr->category (); + // interactive patches can be applied only in interactive mode + if (interactive_run + || (! (ptr->reboot_needed() || ptr->interactive()))) + { + if (levels_to_preselect.count( category ) > 0) + { + // select only packages severe enough + DBG << "Selecting patch: " << *ptr << endl; + ptr->select(); + } + else + { + // and the rest keep neutral (they can be selected by dependencies) + DBG << "Category unsufficient: " << *ptr << endl; + ptr->select(); // FIXME unselect, but not taboo + } + } + else + { + // in non-interactive mode, they mustn't be applied in any case + DBG << "Patch interactive: " << *ptr << endl; + ptr->select(); // FIXME taboo - mustn't be selected by resolver + // instead, admin should be notified + patches_for_manual.push_back( ptr ); + + } + } + DBG << "Running solver here..." << endl; // TODO + // hoping resolver solves obsoletes as well + + for (list::iterator it = patches.begin(); + it != patches.end(); + it++) + { + PatchPtr ptr = *it; + if (! ptr->any_atom_selected()) + { + ptr->select(); // TODO use deselected here instead + } + } + + INT << "===[END]============================================" << endl; + return 0; +} diff --git a/test/devel.jsrain/Script.cc b/test/devel.jsrain/Script.cc index 1cd5a3a..7c2984b 100644 --- a/test/devel.jsrain/Script.cc +++ b/test/devel.jsrain/Script.cc @@ -1,21 +1,5 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include -#include - -/////////////////////////////////////////////////////////////////// - -#include #include diff --git a/zypp/Makefile.am b/zypp/Makefile.am index 7bf90a4..5da33ba 100644 --- a/zypp/Makefile.am +++ b/zypp/Makefile.am @@ -18,7 +18,8 @@ include_HEADERS = \ Message.h \ Script.h \ SolverContext.h \ - Patch.h + Patch.h \ + Product.h ## ################################################## @@ -39,7 +40,8 @@ lib@PACKAGE@_la_SOURCES = \ Message.cc \ Script.cc \ SolverContext.cc\ - Patch.cc + Patch.cc \ + Product.cc lib@PACKAGE@_la_LDFLAGS = @LIB_VERSION_INFO@ diff --git a/zypp/Message.cc b/zypp/Message.cc index 34ed077..0ddcdf6 100644 --- a/zypp/Message.cc +++ b/zypp/Message.cc @@ -11,7 +11,6 @@ */ #include -#include "zypp/base/Logger.h" #include "zypp/Message.h" #include "zypp/detail/MessageImpl.h" @@ -27,7 +26,7 @@ namespace zypp // METHOD TYPE : Ctor // Message::Message( detail::MessageImplPtr impl_r ) - : Resolvable ( impl_r ) + : Resolvable( impl_r ) , _pimpl( impl_r ) {} @@ -44,9 +43,9 @@ namespace zypp // METHOD NAME : Message::text // Get the text of the message // - std::string Message::text () + std::string Message::text() { - return _pimpl->text (); + return _pimpl->text(); } /////////////////////////////////////////////////////////////////// @@ -54,9 +53,9 @@ namespace zypp // METHOD NAME : Message::text // Get the type of the message ("OK", "YesNo") // - std::string Message::type () + std::string Message::type() { - return _pimpl->type (); + return _pimpl->type(); } ///////////////////////////////////////////////////////////////// diff --git a/zypp/Message.h b/zypp/Message.h index 3829cdd..d636929 100644 --- a/zypp/Message.h +++ b/zypp/Message.h @@ -12,8 +12,6 @@ #ifndef ZYPP_MESSAGE_H #define ZYPP_MESSAGE_H -#include - #include "zypp/Resolvable.h" /////////////////////////////////////////////////////////////////// @@ -43,9 +41,9 @@ namespace zypp ~Message(); public: /** Get the text of the message */ - std::string text (); + std::string text(); /** Get the type of the message (YesNo / OK) */ - std::string type (); + std::string type(); private: /** Pointer to implementation */ detail::MessageImplPtr _pimpl; diff --git a/zypp/Patch.cc b/zypp/Patch.cc index 24b54d6..a0f59ed 100644 --- a/zypp/Patch.cc +++ b/zypp/Patch.cc @@ -11,7 +11,6 @@ */ #include -#include "zypp/base/Logger.h" #include "zypp/Patch.h" #include "zypp/detail/PatchImpl.h" @@ -27,7 +26,7 @@ namespace zypp // METHOD TYPE : Ctor // Patch::Patch( detail::PatchImplPtr impl_r ) - : Resolvable (impl_r) + : Resolvable( impl_r ) , _pimpl( impl_r ) { } @@ -46,9 +45,9 @@ namespace zypp // METHOD NAME : Patch::id // Get the patch id // - std::string Patch::id () const + std::string Patch::id() const { - return _pimpl->id (); + return _pimpl->id(); } /////////////////////////////////////////////////////////////////// @@ -56,9 +55,9 @@ namespace zypp // METHOD NAME : Patch::id // Get the patch id // - unsigned int Patch::timestamp () const + unsigned int Patch::timestamp() const { - return _pimpl->timestamp (); + return _pimpl->timestamp(); } /////////////////////////////////////////////////////////////////// @@ -66,9 +65,9 @@ namespace zypp // METHOD NAME : Patch::summary // Get the patch summary // - std::string Patch::summary () const + std::string Patch::summary() const { - return _pimpl->summary (); + return _pimpl->summary(); } /////////////////////////////////////////////////////////////////// @@ -76,9 +75,9 @@ namespace zypp // METHOD NAME : Patch::description // Get the patch description // - std::list Patch::description () const + std::list Patch::description() const { - return _pimpl->description (); + return _pimpl->description(); } /////////////////////////////////////////////////////////////////// @@ -86,9 +85,9 @@ namespace zypp // METHOD NAME : Patch::category // Get the category of the patch // - std::string Patch::category () const + std::string Patch::category() const { - return _pimpl->category (); + return _pimpl->category(); } /////////////////////////////////////////////////////////////////// @@ -96,8 +95,8 @@ namespace zypp // METHOD NAME : Patch::reboot_needed // Check whether reboot is needed to finish the patch installation // - bool Patch::reboot_needed () const { - return _pimpl->reboot_needed (); + bool Patch::reboot_needed() const { + return _pimpl->reboot_needed(); } /////////////////////////////////////////////////////////////////// @@ -106,8 +105,8 @@ namespace zypp // Check whether the patch installation affects package manager // (and it should be restarted after patch installation) // - bool Patch::affects_pkg_manager () const { - return _pimpl->affects_pkg_manager (); + bool Patch::affects_pkg_manager() const { + return _pimpl->affects_pkg_manager(); } /////////////////////////////////////////////////////////////////// @@ -115,31 +114,31 @@ namespace zypp // METHOD NAME : Patch::atoms // Get the list of all atoms building the patch // - atom_list Patch::atoms () const { - return _pimpl->all_atoms (); + atom_list Patch::atoms() const { + return _pimpl->all_atoms(); } /////////////////////////////////////////////////////////////////// // // METHOD NAME : Patch::interactive // Check whether patch can be applied only interactivly // - bool Patch::interactive () + bool Patch::interactive() { - return _pimpl->interactive (); + return _pimpl->interactive(); } - void Patch::mark_atoms_to_freshen (bool freshen) + void Patch::mark_atoms_to_freshen(bool freshen) { - _pimpl->mark_atoms_to_freshen (freshen); + _pimpl->mark_atoms_to_freshen(freshen); } /////////////////////////////////////////////////////////////////// // // METHOD NAME : Patch::any_atom_selected // Check whether there is at least one atom of the solution selected // - bool Patch::any_atom_selected () + bool Patch::any_atom_selected() { - return _pimpl->any_atom_selected (); + return _pimpl->any_atom_selected(); } /////////////////////////////////////////////////////////////////// @@ -149,10 +148,10 @@ namespace zypp // the patch itself as selected for being installed/updated // // FIXME to be changed to inherit Resolvable's method - void Patch::select () -// : Resolvable::select () + void Patch::select() +// : Resolvable::select() { - mark_atoms_to_freshen (true); // FIXME + mark_atoms_to_freshen(true); // FIXME } ///////////////////////////////////////////////////////////////// diff --git a/zypp/Patch.h b/zypp/Patch.h index aac32b5..dc54f0e 100644 --- a/zypp/Patch.h +++ b/zypp/Patch.h @@ -12,7 +12,6 @@ #ifndef ZYPP_PATCH_H #define ZYPP_PATCH_H -#include #include #include "zypp/Resolvable.h" @@ -46,27 +45,27 @@ namespace zypp ~Patch(); public: /** Patch ID */ - std::string id () const; + std::string id() const; /** Patch time stamp */ - unsigned int timestamp () const; + unsigned int timestamp() const; /** Patch summary */ - std::string summary () const; + std::string summary() const; /** Patch description */ std::list description() const; /** Patch category (recommended, security,...) */ - std::string category () const; + std::string category() const; /** Does the system need to reboot to finish the update process? */ - bool reboot_needed () const; + bool reboot_needed() const; /** Does the patch affect the package manager itself? */ - bool affects_pkg_manager () const; + bool affects_pkg_manager() const; /** The list of all atoms building the patch */ - atom_list atoms () const; + atom_list atoms() const; /** Is the patch installation interactive? (does it need user input?) */ - bool interactive (); + bool interactive(); // TODO add comments and reevaluate the need for functions below - void mark_atoms_to_freshen (bool freshen); - bool any_atom_selected (); - void select (); // TODO parameter to specify select/unselect or another function + void mark_atoms_to_freshen(bool freshen); + bool any_atom_selected(); + void select(); // TODO parameter to specify select/unselect or another function private: /** Pointer to implementation */ detail::PatchImplPtr _pimpl; diff --git a/zypp/Product.cc b/zypp/Product.cc new file mode 100644 index 0000000..c6af92a --- /dev/null +++ b/zypp/Product.cc @@ -0,0 +1,57 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/Product.cc + * +*/ +#include + +#include "zypp/Product.h" +#include "zypp/detail/ProductImpl.h" + +using namespace std; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : Product::Product + // METHOD TYPE : Ctor + // + Product::Product( detail::ProductImplPtr impl_r ) + : Resolvable( impl_r ) + , _pimpl( impl_r ) + {} + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : Product::~Product + // METHOD TYPE : Dtor + // + Product::~Product() + {} + + std::list Product::description() const + { + return _pimpl->description(); + } + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : Product::do_script + // Get the product category + // + std::string Product::category() + { + return _pimpl->category(); + } + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// diff --git a/zypp/Product.h b/zypp/Product.h new file mode 100644 index 0000000..cac4c28 --- /dev/null +++ b/zypp/Product.h @@ -0,0 +1,57 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/Product.h + * +*/ +#ifndef ZYPP_PRODUCT_H +#define ZYPP_PRODUCT_H + +#include "zypp/Resolvable.h" +#include +#include + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + namespace detail + { ///////////////////////////////////////////////////////////////// + DEFINE_PTR_TYPE(ProductImpl) + ///////////////////////////////////////////////////////////////// + } // namespace detail + /////////////////////////////////////////////////////////////////// + DEFINE_PTR_TYPE(Product) + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : Product + // + /** Class representing an update script */ + class Product : public Resolvable + { + public: + /** Default ctor */ + Product( detail::ProductImplPtr impl_r ); + /** Dtor */ + ~Product(); + public: + /** Get the product description */ + std::list description() const; + /** Get the product categoty (base, add-on) */ + std::string category(); + private: + /** Pointer to implementation */ + detail::ProductImplPtr _pimpl; + }; + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_PRODUCT_H diff --git a/zypp/Script.cc b/zypp/Script.cc index ffa57f1..aec5bbd 100644 --- a/zypp/Script.cc +++ b/zypp/Script.cc @@ -11,7 +11,6 @@ */ #include -#include "zypp/base/Logger.h" #include "zypp/Script.h" #include "zypp/detail/ScriptImpl.h" @@ -27,7 +26,7 @@ namespace zypp // METHOD TYPE : Ctor // Script::Script( detail::ScriptImplPtr impl_r ) - : Resolvable (impl_r) + : Resolvable( impl_r ) , _pimpl( impl_r ) {} @@ -44,9 +43,9 @@ namespace zypp // METHOD NAME : Script::do_script // Get the script to perform the action // - std::string Script::do_script () + std::string Script::do_script() { - return _pimpl->do_script (); + return _pimpl->do_script(); } /////////////////////////////////////////////////////////////////// @@ -54,9 +53,9 @@ namespace zypp // METHOD NAME : Script::undo_script // Get the script to revert the action // - std::string Script::undo_script () + std::string Script::undo_script() { - return _pimpl->undo_script (); + return _pimpl->undo_script(); } /////////////////////////////////////////////////////////////////// @@ -64,9 +63,9 @@ namespace zypp // METHOD NAME : Script::undo_available // Check whether the action can be reverted // - bool Script::undo_available () + bool Script::undo_available() { - return _pimpl->undo_available (); + return _pimpl->undo_available(); } ///////////////////////////////////////////////////////////////// diff --git a/zypp/Script.h b/zypp/Script.h index 43ef2c7..a52b367 100644 --- a/zypp/Script.h +++ b/zypp/Script.h @@ -12,8 +12,6 @@ #ifndef ZYPP_SCRIPT_H #define ZYPP_SCRIPT_H -#include - #include "zypp/Resolvable.h" /////////////////////////////////////////////////////////////////// @@ -43,11 +41,11 @@ namespace zypp ~Script(); public: /** Get the script to perform the change */ - std::string do_script (); + std::string do_script(); /** Get the script to undo the change */ - std::string undo_script (); + std::string undo_script(); /** Check whether script to undo the change is available */ - bool undo_available (); + bool undo_available(); private: /** Pointer to implementation */ detail::ScriptImplPtr _pimpl; diff --git a/zypp/detail/Makefile.am b/zypp/detail/Makefile.am index 3175dd9..2cc7f47 100644 --- a/zypp/detail/Makefile.am +++ b/zypp/detail/Makefile.am @@ -11,7 +11,8 @@ include_HEADERS = \ SelectionImpl.h \ MessageImpl.h \ ScriptImpl.h \ - PatchImpl.h + PatchImpl.h \ + ProductImpl.h noinst_LTLIBRARIES = lib@PACKAGE@_detail.la @@ -24,6 +25,7 @@ lib@PACKAGE@_detail_la_SOURCES = \ SelectionImpl.cc \ MessageImpl.cc \ ScriptImpl.cc \ - PatchImpl.cc + PatchImpl.cc \ + ProductImpl.cc ## ################################################## diff --git a/zypp/detail/MessageImpl.cc b/zypp/detail/MessageImpl.cc index 60097f8..2483cc6 100644 --- a/zypp/detail/MessageImpl.cc +++ b/zypp/detail/MessageImpl.cc @@ -9,11 +9,8 @@ /** \file zypp/detail/MessageImpl.cc * */ -#include -#include "zypp/base/Logger.h" #include "zypp/detail/MessageImpl.h" -//#include "zypp/Message.h" using namespace std; @@ -35,10 +32,10 @@ namespace zypp MessageImpl::MessageImpl( const std::string & name_r, const Edition & edition_r, const Arch & arch_r ) - : ResolvableImpl (ResKind ("message"), + : ResolvableImpl( ResKind( "message" ), name_r, edition_r, - arch_r) + arch_r ) { } /** Dtor */ @@ -46,11 +43,11 @@ namespace zypp { } - std::string MessageImpl::type () const { + std::string MessageImpl::type() const { return _type; } - std::string MessageImpl::text () const { + std::string MessageImpl::text() const { return _text; } diff --git a/zypp/detail/MessageImpl.h b/zypp/detail/MessageImpl.h index 8b3d39f..a5b57bf 100644 --- a/zypp/detail/MessageImpl.h +++ b/zypp/detail/MessageImpl.h @@ -12,11 +12,7 @@ #ifndef ZYPP_DETAIL_MESSAGEIMPL_H #define ZYPP_DETAIL_MESSAGEIMPL_H -#include - #include "zypp/detail/ResolvableImpl.h" -//#include "zypp/Resolvable.h" -//#include "zypp/Message.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -43,9 +39,9 @@ namespace zypp public: /** Get the text of the message */ - virtual std::string text () const; + virtual std::string text() const; /** Get the type of the message (YesNo / OK) */ - virtual std::string type () const; + virtual std::string type() const; protected: /** The text of the message */ std::string _text; diff --git a/zypp/detail/PatchImpl.cc b/zypp/detail/PatchImpl.cc index c0881d2..f9473d2 100644 --- a/zypp/detail/PatchImpl.cc +++ b/zypp/detail/PatchImpl.cc @@ -13,7 +13,6 @@ #include "zypp/base/Logger.h" #include "zypp/detail/PatchImpl.h" -#include "zypp/Patch.h" #include "zypp/Package.h" using namespace std; @@ -36,10 +35,10 @@ namespace zypp PatchImpl::PatchImpl( const std::string & name_r, const Edition & edition_r, const Arch & arch_r ) - : ResolvableImpl (ResKind ("patch"), + : ResolvableImpl( ResKind( "patch" ), name_r, - Edition (edition_r), - Arch (arch_r)) + edition_r, + arch_r ) { } @@ -48,57 +47,57 @@ namespace zypp { } - std::string PatchImpl::id () const + std::string PatchImpl::id() const { return _patch_id; } - unsigned int PatchImpl::timestamp () const + unsigned int PatchImpl::timestamp() const { return _timestamp; } - std::string PatchImpl::summary () const + std::string PatchImpl::summary() const { return _summary; } - std::list PatchImpl::description () const + std::list PatchImpl::description() const { return _description; } - std::string PatchImpl::category () const + std::string PatchImpl::category() const { return _category; } - bool PatchImpl::reboot_needed () const + bool PatchImpl::reboot_needed() const { return _reboot_needed; } - bool PatchImpl::affects_pkg_manager () const + bool PatchImpl::affects_pkg_manager() const { return _affects_pkg_manager; } - bool PatchImpl::interactive () { + bool PatchImpl::interactive() { if (_reboot_needed) { DBG << "Patch needs reboot" << endl; return true; } - atom_list not_installed = not_installed_atoms (); - for (atom_list::iterator it = not_installed.begin (); - it != not_installed.end (); + atom_list not_installed = not_installed_atoms(); + for (atom_list::iterator it = not_installed.begin(); + it != not_installed.end(); it++) { - if ((std::string)((*it)->kind ()) == "message") + if ((std::string)((*it)->kind()) == "message") { // DBG << "Patch contains a message" << endl; return true; } - if ((std::string)((*it)->kind ()) == "package") + if ((std::string)((*it)->kind()) == "package") { // Resolvable* // Resolvable @@ -116,19 +115,19 @@ namespace zypp return false; } - atom_list PatchImpl::all_atoms () { + atom_list PatchImpl::all_atoms() { return _atoms; } - atom_list PatchImpl::not_installed_atoms () { + atom_list PatchImpl::not_installed_atoms() { atom_list ret; - for (atom_list::iterator it = _atoms.begin (); - it != _atoms.end (); + for (atom_list::iterator it = _atoms.begin(); + it != _atoms.end(); it++) { if (true) // FIXME check if atom/resolvable is not installed { - ret.push_back (*it); + ret.push_back(*it); } } return ret; @@ -136,9 +135,9 @@ namespace zypp // TODO check necessarity of functions below - bool PatchImpl::any_atom_selected () { - for (atom_list::iterator it = _atoms.begin (); - it != _atoms.end (); + bool PatchImpl::any_atom_selected() { + for (atom_list::iterator it = _atoms.begin(); + it != _atoms.end(); it++) { if (false) // FIXME check if atom/resolvable is selected @@ -149,9 +148,9 @@ namespace zypp return false; } - void PatchImpl::mark_atoms_to_freshen (bool freshen) { - for (atom_list::iterator it = _atoms.begin (); - it != _atoms.end (); + void PatchImpl::mark_atoms_to_freshen( bool freshen ) { + for (atom_list::iterator it = _atoms.begin(); + it != _atoms.end(); it++) { // TODO mark the resolvable to be or not to be freshed diff --git a/zypp/detail/PatchImpl.h b/zypp/detail/PatchImpl.h index 5afe5de..d90d610 100644 --- a/zypp/detail/PatchImpl.h +++ b/zypp/detail/PatchImpl.h @@ -17,7 +17,7 @@ #include "zypp/detail/ResolvableImpl.h" #include "zypp/Resolvable.h" -#include "zypp/Patch.h" +#include "zypp/Patch.h" // contains atom_list macro /////////////////////////////////////////////////////////////////// namespace zypp @@ -44,30 +44,30 @@ namespace zypp public: /** Patch ID */ - std::string id () const; + std::string id() const; /** Patch time stamp */ - unsigned int timestamp () const; + unsigned int timestamp() const; /** Patch summary */ - std::string summary () const; + std::string summary() const; /** Patch description */ - std::list description () const; + std::list description() const; /** Patch category (recommended, security,...) */ - std::string category () const; + std::string category() const; /** Does the system need to reboot to finish the update process? */ - bool reboot_needed () const; + bool reboot_needed() const; /** Does the patch affect the package manager itself? */ - bool affects_pkg_manager () const; + bool affects_pkg_manager() const; /** Is the patch installation interactive? (does it need user input?) */ - bool interactive (); + bool interactive(); /** The list of all atoms building the patch */ - atom_list all_atoms (); + atom_list all_atoms(); /** The list of those atoms which have not been installed */ - atom_list not_installed_atoms (); + atom_list not_installed_atoms(); // TODO check necessarity of functions below - bool any_atom_selected (); - void mark_atoms_to_freshen (bool freshen); + bool any_atom_selected(); + void mark_atoms_to_freshen(bool freshen); protected: /** Patch ID */ std::string _patch_id; diff --git a/zypp/detail/ProductImpl.cc b/zypp/detail/ProductImpl.cc new file mode 100644 index 0000000..5ced8ff --- /dev/null +++ b/zypp/detail/ProductImpl.cc @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/detail/ProductImpl.cc + * +*/ + +#include "zypp/detail/ProductImpl.h" + +using namespace std; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace detail + { ///////////////////////////////////////////////////////////////// + IMPL_PTR_TYPE(ProductImpl) + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : ProductImpl + // + /////////////////////////////////////////////////////////////////// + + /** Default ctor */ + ProductImpl::ProductImpl( const std::string & name_r, + const Edition & edition_r, + const Arch & arch_r ) + : ResolvableImpl( ResKind( "script"), + name_r, + edition_r, + arch_r ) + { + } + /** Dtor */ + ProductImpl::~ProductImpl() + { + } + + std::list ProductImpl::description() const + { + return _description; + } + + std::string ProductImpl::category() const { + return _category; + } + + ///////////////////////////////////////////////////////////////// + } // namespace detail + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// diff --git a/zypp/detail/ProductImpl.h b/zypp/detail/ProductImpl.h new file mode 100644 index 0000000..a0b9200 --- /dev/null +++ b/zypp/detail/ProductImpl.h @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/detail/ProductImpl.h + * +*/ +#ifndef ZYPP_DETAIL_PRODUCTIMPL_H +#define ZYPP_DETAIL_PRODUCTIMPL_H + +#include +#include + +#include "zypp/detail/ResolvableImpl.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace detail + { ///////////////////////////////////////////////////////////////// + DEFINE_PTR_TYPE(ProductImpl) + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : ProductImpl + // + /** Class representing an update script */ + class ProductImpl : public ResolvableImpl + { + public: + /** Default ctor */ + ProductImpl( const std::string & name_r, + const Edition & edition_r, + const Arch & arch_r ); + /** Dtor */ + ~ProductImpl(); + + public: + /** Get the product description */ + std::list description() const; + /** Get the category of the product */ + std::string category() const; + protected: + /** Product description */ + std::list _description; + /** The category of the product */ + std::string _category; + }; + /////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////// + } // namespace detail + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_DETAIL_PRODUCTIMPL_H diff --git a/zypp/detail/ScriptImpl.cc b/zypp/detail/ScriptImpl.cc index 6912786..89e0fb4 100644 --- a/zypp/detail/ScriptImpl.cc +++ b/zypp/detail/ScriptImpl.cc @@ -9,11 +9,8 @@ /** \file zypp/detail/ScriptImpl.cc * */ -#include -#include "zypp/base/Logger.h" #include "zypp/detail/ScriptImpl.h" -#include "zypp/Script.h" using namespace std; @@ -35,10 +32,10 @@ namespace zypp ScriptImpl::ScriptImpl( const std::string & name_r, const Edition & edition_r, const Arch & arch_r ) - : ResolvableImpl (ResKind ("script"), + : ResolvableImpl( ResKind( "script"), name_r, - Edition (edition_r), - Arch (arch_r)) + edition_r, + arch_r ) { } /** Dtor */ @@ -46,15 +43,15 @@ namespace zypp { } - std::string ScriptImpl::do_script () const { + std::string ScriptImpl::do_script() const { return _do_script; } - std::string ScriptImpl::undo_script () const { + std::string ScriptImpl::undo_script() const { return _undo_script; } - bool ScriptImpl::undo_available () const { + bool ScriptImpl::undo_available() const { return _undo_script != ""; } diff --git a/zypp/detail/ScriptImpl.h b/zypp/detail/ScriptImpl.h index 74d8d67..b70db95 100644 --- a/zypp/detail/ScriptImpl.h +++ b/zypp/detail/ScriptImpl.h @@ -12,11 +12,7 @@ #ifndef ZYPP_DETAIL_SCRIPTIMPL_H #define ZYPP_DETAIL_SCRIPTIMPL_H -#include - #include "zypp/detail/ResolvableImpl.h" -#include "zypp/Resolvable.h" -#include "zypp/Script.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -43,11 +39,11 @@ namespace zypp public: /** Get the script to perform the change */ - std::string do_script () const; + std::string do_script() const; /** Get the script to undo the change */ - std::string undo_script () const; + std::string undo_script() const; /** Check whether script to undo the change is available */ - virtual bool undo_available () const; + virtual bool undo_available() const; protected: /** The script to perform the change */ std::string _do_script; -- 2.7.4