QueueItem.cc

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* QueueItem.cc
00003  *
00004  * Copyright (C) 2000-2002 Ximian, Inc.
00005  * Copyright (C) 2005 SUSE Linux Products GmbH
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License,
00009  * version 2, as published by the Free Software Foundation.
00010  *
00011  * This program is distributed in the hope that it will be useful, but
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019  * 02111-1307, USA.
00020  */
00021 
00022 #include "zypp/base/Logger.h"
00023 #include "zypp/solver/detail/QueueItem.h"
00024 #include "zypp/solver/detail/ResolverContext.h"
00025 
00026 
00028 namespace zypp 
00029 { 
00030 
00031   namespace solver
00032   { 
00033 
00034     namespace detail
00035     { 
00036 
00037 using namespace std;
00038 
00039 IMPL_PTR_TYPE(QueueItem);
00040 
00041 //---------------------------------------------------------------------------
00042 
00043 std::ostream &
00044 QueueItem::dumpOn( std::ostream & os ) const
00045 {
00046     switch (_type) {
00047       case QUEUE_ITEM_TYPE_UNKNOWN:     os << "unknown"; break;
00048       case QUEUE_ITEM_TYPE_INSTALL:     os << "install"; break;
00049       case QUEUE_ITEM_TYPE_REQUIRE:     os << "require"; break;
00050       case QUEUE_ITEM_TYPE_BRANCH:      os << "branch"; break;
00051       case QUEUE_ITEM_TYPE_GROUP:       os << "group"; break;
00052       case QUEUE_ITEM_TYPE_CONFLICT:    os << "conflict"; break;
00053       case QUEUE_ITEM_TYPE_UNINSTALL:   os << "uninstall"; break;
00054       case QUEUE_ITEM_TYPE_ESTABLISH:   os << "establish"; break;
00055       case QUEUE_ITEM_TYPE_LAST:        os << "last"; break;
00056       default: os << "?queueitem?"; break;
00057     }
00058     return os;
00059 }
00060 
00061 
00062 ostream&
00063 operator<<( ostream & os, const QueueItemList & itemlist )
00064 {
00065     for (QueueItemList::const_iterator iter = itemlist.begin(); iter != itemlist.end(); ++iter) {
00066         if (iter != itemlist.begin())
00067             os << "," << endl << "\t";
00068         os << **iter;
00069     }
00070     return os;
00071 }
00072 
00073 //---------------------------------------------------------------------------
00074 
00075 QueueItem::QueueItem (QueueItemType type, const ResPool & pool)
00076     : _type (type)
00077     , _pool (pool)
00078     , _priority (0)
00079     , _size (0)
00080 {
00081 }
00082 
00083 
00084 QueueItem::~QueueItem()
00085 {
00086 }
00087 
00088 //---------------------------------------------------------------------------
00089 
00090 void
00091 QueueItem::copy (const QueueItem *from)
00092 {
00093     _priority = from->_priority;
00094     _size = from->_size;
00095     _pending_info = ResolverInfoList (from->_pending_info.begin(), from->_pending_info.end());
00096 }
00097 
00098 
00099 //---------------------------------------------------------------------------
00100 
00101 void
00102 QueueItem::addInfo (ResolverInfo_Ptr info)
00103 {
00104     _pending_info.push_back (info);
00105 }
00106 
00107 
00108 void
00109 QueueItem::logInfo (ResolverContext_Ptr context)
00110 {
00111     for (ResolverInfoList::const_iterator iter = _pending_info.begin(); iter != _pending_info.end(); iter++) {
00112         context->addInfo (*iter);
00113     }
00114     _pending_info.clear();
00115 }
00116 
00118     };// namespace detail
00121   };// namespace solver
00124 };// namespace zypp

Generated on Thu Jul 6 00:07:23 2006 for zypp by  doxygen 1.4.6