InstallOrder.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* InstallOrder.h
00003  *
00004  * Copyright (C) 2005 SUSE Linux Products GmbH
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License,
00008  * version 2, as published by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018  * 02111-1307, USA.
00019  */
00020 
00021 // stolen from yast2-packagemanager
00022 /*
00023    File:       InstallOrder.h
00024    Purpose:    Determine order for installing packages
00025    Author:     Ludwig Nussel <lnussel@suse.de>
00026    Maintainer: Ludwig Nussel <lnussel@suse.de>
00027 
00028 /-*/
00029 
00030 #ifndef ZYPP_SOLVER_DETAIL_INSTALLORDER_H
00031 #define ZYPP_SOLVER_DETAIL_INSTALLORDER_H
00032 
00033 #include <list>
00034 #include <map>
00035 
00036 #include "zypp/PoolItem.h"
00037 #include "zypp/ResPool.h"
00038 #include "zypp/CapSet.h"
00039 
00040 #include "zypp/solver/detail/Types.h"
00041 
00043 namespace zypp
00044 { 
00045 
00046   namespace solver
00047   { 
00048 
00049     namespace detail
00050     { 
00051 
00060 class InstallOrder
00061 {
00062     private:
00063         const ResPool & _pool;
00064         PoolItemSet _toinstall;
00065         PoolItemSet _installed;
00066 
00068         typedef std::map<PoolItem_Ref, PoolItemList> Graph;
00069 
00071         Graph _graph;
00072 
00074         Graph _rgraph;
00075 
00076         struct NodeInfo
00077         {
00078             unsigned begintime;
00079             unsigned endtime;
00080             bool visited;
00081             int order; // number of incoming edges in reverse graph
00082 
00083             PoolItem_Ref item;
00084 
00085             NodeInfo() : begintime(0), endtime(0), visited(false), order(0) {}
00086             NodeInfo(PoolItem_Ref item) : begintime(0), endtime(0), visited(false), order(0), item(item) {}
00087         };
00088         
00089         typedef std::map<PoolItem_Ref, NodeInfo> Nodes;
00090 
00091         Nodes _nodes;
00092 
00093         unsigned _rdfstime;
00094 
00095         PoolItemList _topsorted;
00096 
00097         bool _dirty;
00098 
00099         unsigned _numrun;
00100 
00101     private:
00102         void rdfsvisit (PoolItem_Ref item);
00103 
00104         PoolItem_Ref findProviderInSet( const Capability requirement, const PoolItemSet & candidates ) const;
00105         bool doesProvide( const Capability requirement, PoolItem_Ref item ) const;
00106 
00107     public:
00108 
00115         InstallOrder( const ResPool & pool, const PoolItemSet & toinstall, const PoolItemSet & installed);
00116 
00121         PoolItemList computeNextSet();
00122 
00127         void setInstalled( PoolItem_Ref item );
00128         
00132         void setInstalled( const PoolItemList & list );
00133 
00137         void startrdfs();
00138 
00143         void init() { startrdfs(); }
00144 
00150         const PoolItemList getTopSorted() const;
00151 
00152         const void printAdj (std::ostream & os, bool reversed = false) const;
00153 };
00154 
00156     };// namespace detail
00159   };// namespace solver
00162 };// namespace zypp
00164 
00165 #endif // ZYPP_SOLVER_DETAIL_INSTALLORDER_H

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