From 2f5f7a97aaaed8ca9c90d57c08a0b7678f986296 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Mon, 14 Apr 2008 17:33:35 +0000 Subject: [PATCH] added new solver request --- zypp/CMakeLists.txt | 8 +++ zypp/sat/SolverQueueItem.cc | 4 +- zypp/sat/SolverQueueItem.h | 10 ++- zypp/sat/SolverQueueItemDelete.cc | 87 ++++++++++++++++++++++++ zypp/sat/SolverQueueItemDelete.h | 85 +++++++++++++++++++++++ zypp/sat/SolverQueueItemInstall.cc | 87 ++++++++++++++++++++++++ zypp/sat/SolverQueueItemInstall.h | 85 +++++++++++++++++++++++ zypp/sat/SolverQueueItemInstallOneOf.cc | 90 +++++++++++++++++++++++++ zypp/sat/SolverQueueItemInstallOneOf.h | 88 ++++++++++++++++++++++++ zypp/sat/SolverQueueItemUpdate.cc | 88 ++++++++++++++++++++++++ zypp/sat/SolverQueueItemUpdate.h | 86 +++++++++++++++++++++++ 11 files changed, 710 insertions(+), 8 deletions(-) create mode 100644 zypp/sat/SolverQueueItemDelete.cc create mode 100644 zypp/sat/SolverQueueItemDelete.h create mode 100644 zypp/sat/SolverQueueItemInstall.cc create mode 100644 zypp/sat/SolverQueueItemInstall.h create mode 100644 zypp/sat/SolverQueueItemInstallOneOf.cc create mode 100644 zypp/sat/SolverQueueItemInstallOneOf.h create mode 100644 zypp/sat/SolverQueueItemUpdate.cc create mode 100644 zypp/sat/SolverQueueItemUpdate.h diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt index 6f05cf702..34203ef0f 100644 --- a/zypp/CMakeLists.txt +++ b/zypp/CMakeLists.txt @@ -522,6 +522,10 @@ SET( zypp_sat_SRCS sat/SATResolver.cc sat/SolvAttr.cc sat/SolverQueueItem.cc + sat/SolverQueueItemInstall.cc + sat/SolverQueueItemDelete.cc + sat/SolverQueueItemUpdate.cc + sat/SolverQueueItemInstallOneOf.cc ) SET( zypp_sat_HEADERS @@ -534,6 +538,10 @@ SET( zypp_sat_HEADERS sat/LookupAttr.h sat/SATResolver.h sat/SolverQueueItem.h + sat/SolverQueueItemInstall.h + sat/SolverQueueItemDelete.h + sat/SolverQueueItemUpdate.h + sat/SolverQueueItemInstallOneOf.h sat/SolvAttr.h ) diff --git a/zypp/sat/SolverQueueItem.cc b/zypp/sat/SolverQueueItem.cc index 85ad648d2..338eed34c 100644 --- a/zypp/sat/SolverQueueItem.cc +++ b/zypp/sat/SolverQueueItem.cc @@ -44,8 +44,8 @@ SolverQueueItem::dumpOn( std::ostream & os ) const switch (_type) { case QUEUE_ITEM_TYPE_UNKNOWN : os << "unknown"; break; case QUEUE_ITEM_TYPE_UPDATE : os << "update"; break; - case QUEUE_ITEM_TYPE_REQUIRE : os << "require"; break; - case QUEUE_ITEM_TYPE_CONFLICT : os << "conflict"; break; + case QUEUE_ITEM_TYPE_INSTALL : os << "install"; break; + case QUEUE_ITEM_TYPE_DELETE : os << "delete"; break; case QUEUE_ITEM_TYPE_INSTALL_ONE_OF: os << "install one of"; break; default: os << "?solverqueueitem?"; break; } diff --git a/zypp/sat/SolverQueueItem.h b/zypp/sat/SolverQueueItem.h index e1433446c..2f9ee4c61 100644 --- a/zypp/sat/SolverQueueItem.h +++ b/zypp/sat/SolverQueueItem.h @@ -28,10 +28,8 @@ #include "zypp/base/ReferenceCounted.h" #include "zypp/base/NonCopyable.h" #include "zypp/base/PtrTypes.h" - #include "zypp/ResPool.h" - ///////////////////////////////////////////////////////////////////////// namespace zypp { /////////////////////////////////////////////////////////////////////// @@ -45,8 +43,8 @@ namespace zypp typedef enum { QUEUE_ITEM_TYPE_UNKNOWN = 0, QUEUE_ITEM_TYPE_UPDATE, - QUEUE_ITEM_TYPE_REQUIRE, - QUEUE_ITEM_TYPE_CONFLICT, + QUEUE_ITEM_TYPE_INSTALL, + QUEUE_ITEM_TYPE_DELETE, QUEUE_ITEM_TYPE_INSTALL_ONE_OF, } SolverQueueItemType; @@ -91,8 +89,8 @@ class SolverQueueItem : public base::ReferenceCounted, private base::NonCopyable void copy (const SolverQueueItem *from); - bool isConflict (void) const { return _type == QUEUE_ITEM_TYPE_CONFLICT; } - bool isRequire (void) const { return _type == QUEUE_ITEM_TYPE_REQUIRE; } + bool isDelete (void) const { return _type == QUEUE_ITEM_TYPE_DELETE; } + bool isInstall (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL; } bool isUpdate (void) const { return _type == QUEUE_ITEM_TYPE_UPDATE; } bool isInstallOneOf (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL_ONE_OF; } diff --git a/zypp/sat/SolverQueueItemDelete.cc b/zypp/sat/SolverQueueItemDelete.cc new file mode 100644 index 000000000..61674e49a --- /dev/null +++ b/zypp/sat/SolverQueueItemDelete.cc @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* SolverQueueItem.cc + * + * Copyright (C) 2008 SUSE Linux Products GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include "zypp/base/Logger.h" +#include "zypp/sat/SolverQueueItemDelete.h" + +///////////////////////////////////////////////////////////////////////// +namespace zypp +{ /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + namespace solver + { ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + namespace detail + { /////////////////////////////////////////////////////////////////// + +using namespace std; + +IMPL_PTR_TYPE(SolverQueueItemDelete); + +//--------------------------------------------------------------------------- + +std::ostream & +SolverQueueItemDelete::dumpOn( std::ostream & os ) const +{ + os << "[" << (_soft?"Soft":"") << "Delete: "; + os << _name; + + return os; +} + +//--------------------------------------------------------------------------- + +SolverQueueItemDelete::SolverQueueItemDelete (const ResPool & pool, std::string name, bool soft) + : SolverQueueItem (QUEUE_ITEM_TYPE_DELETE, pool) + , _name (name) + , _soft (soft) +{ +} + + +SolverQueueItemDelete::~SolverQueueItemDelete() +{ +} + +//--------------------------------------------------------------------------- + +SolverQueueItem_Ptr +SolverQueueItemDelete::copy (void) const +{ + SolverQueueItemDelete_Ptr new_delete = new SolverQueueItemDelete (pool(), _name); + new_delete->SolverQueueItem::copy(this); + + new_delete->_soft = _soft; + return new_delete; +} + + +//--------------------------------------------------------------------------- + + +/////////////////////////////////////////////////////////////////// + };// namespace detail + ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + };// namespace solver + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// +};// namespace zypp +///////////////////////////////////////////////////////////////////////// diff --git a/zypp/sat/SolverQueueItemDelete.h b/zypp/sat/SolverQueueItemDelete.h new file mode 100644 index 000000000..5ae629d3f --- /dev/null +++ b/zypp/sat/SolverQueueItemDelete.h @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* QueueItem.h + * + * Copyright (C) 2008 SUSE Linux Products GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef ZYPP_SOLVER_DETAIL_QUEUEITEMDELETE_H +#define ZYPP_SOLVER_DETAIL_QUEUEITEMDELETE_H + +#include +#include + +#include "zypp/sat/SolverQueueItem.h" + +///////////////////////////////////////////////////////////////////////// +namespace zypp +{ /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + namespace solver + { ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + namespace detail + { /////////////////////////////////////////////////////////////////// + +DEFINE_PTR_TYPE(SolverQueueItemDelete); + + +/////////////////////////////////////////////////////////////////// +// +// CLASS NAME : SolverQueueItemDelete + +class SolverQueueItemDelete : public SolverQueueItem { + + private: + + std::string _name; + bool _soft; // if triggered by a soft requirement (a recommends) + + public: + + SolverQueueItemDelete (const ResPool & pool, std::string name, bool soft = false); + virtual ~SolverQueueItemDelete(); + + // ---------------------------------- I/O + + virtual std::ostream & dumpOn( std::ostream & str ) const; + + friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemDelete & obj) + { return obj.dumpOn (str); } + + // ---------------------------------- accessors + + bool isSoft (void) const { return _soft; } + + // ---------------------------------- methods + + virtual SolverQueueItem_Ptr copy (void) const; + virtual int cmp (SolverQueueItem_constPtr item) const; +}; + +/////////////////////////////////////////////////////////////////// + };// namespace detail + ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + };// namespace solver + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// +};// namespace zypp +///////////////////////////////////////////////////////////////////////// + +#endif // ZYPP_SOLVER_DETAIL_QUEUEITEMDELETE_H diff --git a/zypp/sat/SolverQueueItemInstall.cc b/zypp/sat/SolverQueueItemInstall.cc new file mode 100644 index 000000000..b54e5bbf6 --- /dev/null +++ b/zypp/sat/SolverQueueItemInstall.cc @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* SolverQueueItem.cc + * + * Copyright (C) 2008 SUSE Linux Products GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include "zypp/base/Logger.h" +#include "zypp/sat/SolverQueueItemInstall.h" + +///////////////////////////////////////////////////////////////////////// +namespace zypp +{ /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + namespace solver + { ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + namespace detail + { /////////////////////////////////////////////////////////////////// + +using namespace std; + +IMPL_PTR_TYPE(SolverQueueItemInstall); + +//--------------------------------------------------------------------------- + +std::ostream & +SolverQueueItemInstall::dumpOn( std::ostream & os ) const +{ + os << "[" << (_soft?"Soft":"") << "Install: "; + os << _name; + + return os; +} + +//--------------------------------------------------------------------------- + +SolverQueueItemInstall::SolverQueueItemInstall (const ResPool & pool, std::string name, bool soft) + : SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL, pool) + , _name (name) + , _soft (soft) +{ +} + + +SolverQueueItemInstall::~SolverQueueItemInstall() +{ +} + +//--------------------------------------------------------------------------- + +SolverQueueItem_Ptr +SolverQueueItemInstall::copy (void) const +{ + SolverQueueItemInstall_Ptr new_install = new SolverQueueItemInstall (pool(), _name); + new_install->SolverQueueItem::copy(this); + + new_install->_soft = _soft; + return new_install; +} + + +//--------------------------------------------------------------------------- + + +/////////////////////////////////////////////////////////////////// + };// namespace detail + ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + };// namespace solver + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// +};// namespace zypp +///////////////////////////////////////////////////////////////////////// diff --git a/zypp/sat/SolverQueueItemInstall.h b/zypp/sat/SolverQueueItemInstall.h new file mode 100644 index 000000000..1a954dec2 --- /dev/null +++ b/zypp/sat/SolverQueueItemInstall.h @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* QueueItem.h + * + * Copyright (C) 2008 SUSE Linux Products GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef ZYPP_SOLVER_DETAIL_QUEUEITEMINSTALL_H +#define ZYPP_SOLVER_DETAIL_QUEUEITEMINSTALL_H + +#include +#include + +#include "zypp/sat/SolverQueueItem.h" + +///////////////////////////////////////////////////////////////////////// +namespace zypp +{ /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + namespace solver + { ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + namespace detail + { /////////////////////////////////////////////////////////////////// + +DEFINE_PTR_TYPE(SolverQueueItemInstall); + + +/////////////////////////////////////////////////////////////////// +// +// CLASS NAME : SolverQueueItemInstall + +class SolverQueueItemInstall : public SolverQueueItem { + + private: + + std::string _name; + bool _soft; // if triggered by a soft requirement (a recommends) + + public: + + SolverQueueItemInstall (const ResPool & pool, std::string name, bool soft = false); + virtual ~SolverQueueItemInstall(); + + // ---------------------------------- I/O + + virtual std::ostream & dumpOn( std::ostream & str ) const; + + friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemInstall & obj) + { return obj.dumpOn (str); } + + // ---------------------------------- accessors + + bool isSoft (void) const { return _soft; } + + // ---------------------------------- methods + + virtual SolverQueueItem_Ptr copy (void) const; + virtual int cmp (SolverQueueItem_constPtr item) const; +}; + +/////////////////////////////////////////////////////////////////// + };// namespace detail + ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + };// namespace solver + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// +};// namespace zypp +///////////////////////////////////////////////////////////////////////// + +#endif // ZYPP_SOLVER_DETAIL_QUEUEITEMINSTALL_H diff --git a/zypp/sat/SolverQueueItemInstallOneOf.cc b/zypp/sat/SolverQueueItemInstallOneOf.cc new file mode 100644 index 000000000..58a3de1f6 --- /dev/null +++ b/zypp/sat/SolverQueueItemInstallOneOf.cc @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* SolverQueueItem.cc + * + * Copyright (C) 2008 SUSE Linux Products GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include "zypp/base/Logger.h" +#include "zypp/sat/SolverQueueItemInstallOneOf.h" + +///////////////////////////////////////////////////////////////////////// +namespace zypp +{ /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + namespace solver + { ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + namespace detail + { /////////////////////////////////////////////////////////////////// + +using namespace std; + +IMPL_PTR_TYPE(SolverQueueItemInstallOneOf); + +//--------------------------------------------------------------------------- + +std::ostream & +SolverQueueItemInstallOneOf::dumpOn( std::ostream & os ) const +{ + os << "[" << (_soft?"Soft":"") << "InstallOneOf: "; + for (PoolItemList::const_iterator iter = _oneOfList.begin(); + iter != _oneOfList.end(); + iter++) + os << *iter; + + return os; +} + +//--------------------------------------------------------------------------- + +SolverQueueItemInstallOneOf::SolverQueueItemInstallOneOf (const ResPool & pool, const PoolItemList & itemList, bool soft) + : SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL_ONE_OF, pool) + , _oneOfList (itemList) + , _soft (soft) +{ +} + + +SolverQueueItemInstallOneOf::~SolverQueueItemInstallOneOf() +{ +} + +//--------------------------------------------------------------------------- + +SolverQueueItem_Ptr +SolverQueueItemInstallOneOf::copy (void) const +{ + SolverQueueItemInstallOneOf_Ptr new_installOneOf = new SolverQueueItemInstallOneOf (pool(), _oneOfList, _soft); + new_installOneOf->SolverQueueItem::copy(this); + + new_installOneOf->_soft = _soft; + return new_installOneOf; +} + + +//--------------------------------------------------------------------------- + + +/////////////////////////////////////////////////////////////////// + };// namespace detail + ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + };// namespace solver + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// +};// namespace zypp +///////////////////////////////////////////////////////////////////////// diff --git a/zypp/sat/SolverQueueItemInstallOneOf.h b/zypp/sat/SolverQueueItemInstallOneOf.h new file mode 100644 index 000000000..1d428b2f0 --- /dev/null +++ b/zypp/sat/SolverQueueItemInstallOneOf.h @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* QueueItem.h + * + * Copyright (C) 2008 SUSE Linux Products GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef ZYPP_SOLVER_DETAIL_QUEUEITEMINSTALLONEOF_H +#define ZYPP_SOLVER_DETAIL_QUEUEITEMINSTALLONEOF_H + +#include +#include + +#include "zypp/sat/SolverQueueItem.h" + +///////////////////////////////////////////////////////////////////////// +namespace zypp +{ /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + namespace solver + { ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + namespace detail + { /////////////////////////////////////////////////////////////////// + +DEFINE_PTR_TYPE(SolverQueueItemInstallOneOf); + + +/////////////////////////////////////////////////////////////////// +// +// CLASS NAME : SolverQueueItemInstallOneOf + +class SolverQueueItemInstallOneOf : public SolverQueueItem { + + public: + typedef std::list PoolItemList; + + private: + + PoolItemList _oneOfList; // List of candidates + bool _soft; // if triggered by a soft requirement (a recommends) + + public: + + SolverQueueItemInstallOneOf (const ResPool & pool, const PoolItemList & itemList, bool soft = false); + virtual ~SolverQueueItemInstallOneOf(); + + // ---------------------------------- I/O + + virtual std::ostream & dumpOn( std::ostream & str ) const; + + friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemInstallOneOf & obj) + { return obj.dumpOn (str); } + + // ---------------------------------- accessors + + bool isSoft (void) const { return _soft; } + + // ---------------------------------- methods + + virtual SolverQueueItem_Ptr copy (void) const; + virtual int cmp (SolverQueueItem_constPtr item) const; +}; + +/////////////////////////////////////////////////////////////////// + };// namespace detail + ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + };// namespace solver + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// +};// namespace zypp +///////////////////////////////////////////////////////////////////////// + +#endif // ZYPP_SOLVER_DETAIL_QUEUEITEMINSTALLONEOF_H diff --git a/zypp/sat/SolverQueueItemUpdate.cc b/zypp/sat/SolverQueueItemUpdate.cc new file mode 100644 index 000000000..750938c57 --- /dev/null +++ b/zypp/sat/SolverQueueItemUpdate.cc @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* SolverQueueItem.cc + * + * Copyright (C) 2008 SUSE Linux Products GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include "zypp/base/Logger.h" +#include "zypp/sat/SolverQueueItemUpdate.h" + +///////////////////////////////////////////////////////////////////////// +namespace zypp +{ /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + namespace solver + { ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + namespace detail + { /////////////////////////////////////////////////////////////////// + +using namespace std; + +IMPL_PTR_TYPE(SolverQueueItemUpdate); + +//--------------------------------------------------------------------------- + +std::ostream & +SolverQueueItemUpdate::dumpOn( std::ostream & os ) const +{ + os << "[" << (_soft?"Soft":"") << "Update: "; + os << _item; + + return os; +} + +//--------------------------------------------------------------------------- + +SolverQueueItemUpdate::SolverQueueItemUpdate (const ResPool & pool, + const PoolItem & item, bool soft) + : SolverQueueItem (QUEUE_ITEM_TYPE_UPDATE, pool) + , _item (item) + , _soft (soft) +{ +} + + +SolverQueueItemUpdate::~SolverQueueItemUpdate() +{ +} + +//--------------------------------------------------------------------------- + +SolverQueueItem_Ptr +SolverQueueItemUpdate::copy (void) const +{ + SolverQueueItemUpdate_Ptr new_update = new SolverQueueItemUpdate (pool(), _item); + new_update->SolverQueueItem::copy(this); + + new_update->_soft = _soft; + return new_update; +} + + +//--------------------------------------------------------------------------- + + +/////////////////////////////////////////////////////////////////// + };// namespace detail + ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + };// namespace solver + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// +};// namespace zypp +///////////////////////////////////////////////////////////////////////// diff --git a/zypp/sat/SolverQueueItemUpdate.h b/zypp/sat/SolverQueueItemUpdate.h new file mode 100644 index 000000000..8f41da277 --- /dev/null +++ b/zypp/sat/SolverQueueItemUpdate.h @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* QueueItem.h + * + * Copyright (C) 2008 SUSE Linux Products GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef ZYPP_SOLVER_DETAIL_QUEUEITEMUPDATE_H +#define ZYPP_SOLVER_DETAIL_QUEUEITEMUPDATE_H + +#include +#include + +#include "zypp/sat/SolverQueueItem.h" +#include "zypp/PoolItem.h" + +///////////////////////////////////////////////////////////////////////// +namespace zypp +{ /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + namespace solver + { ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + namespace detail + { /////////////////////////////////////////////////////////////////// + +DEFINE_PTR_TYPE(SolverQueueItemUpdate); + + +/////////////////////////////////////////////////////////////////// +// +// CLASS NAME : SolverQueueItemUpdate + +class SolverQueueItemUpdate : public SolverQueueItem { + + private: + + PoolItem _item; // the item to-be-updated + bool _soft; // if triggered by a soft requirement (a recommends) + + public: + + SolverQueueItemUpdate (const ResPool & pool, const PoolItem & item, bool soft = false); + virtual ~SolverQueueItemUpdate(); + + // ---------------------------------- I/O + + virtual std::ostream & dumpOn( std::ostream & str ) const; + + friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemUpdate & obj) + { return obj.dumpOn (str); } + + // ---------------------------------- accessors + + bool isSoft (void) const { return _soft; } + + // ---------------------------------- methods + + virtual SolverQueueItem_Ptr copy (void) const; + virtual int cmp (SolverQueueItem_constPtr item) const; +}; + +/////////////////////////////////////////////////////////////////// + };// namespace detail + ///////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////// + };// namespace solver + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// +};// namespace zypp +///////////////////////////////////////////////////////////////////////// + +#endif // ZYPP_SOLVER_DETAIL_QUEUEITEMUPDATE_H -- 2.34.1