00001 #ifndef _PkgSet_h 00002 #define _PkgSet_h 00003 00004 #include <list> 00005 #include <map> 00006 #include <y2util/hash.h> 00007 #include <y2pm/PMSolvablePtr.h> 00008 #include <y2pm/PkgRevRel.h> 00009 00024 class PkgSet { 00025 public: 00026 typedef std::map<PkgName,PMSolvablePtr> PkgList_type; 00027 typedef PkgList_type::iterator iterator; 00028 typedef PkgList_type::const_iterator const_iterator; 00029 00030 typedef std::list<PkgRevRelation> RevRelList_type; 00031 typedef RevRelList_type::iterator RevRelList_iterator; 00032 typedef RevRelList_type::const_iterator RevRelList_const_iterator; 00033 00034 typedef std::map<PkgName,RevRelList_type> InvRel_type; 00035 typedef InvRel_type::iterator InvRel_iterator; 00036 typedef InvRel_type::const_iterator InvRel_const_iterator; 00037 00038 typedef std::list<constPMSolvablePtr> SolvableList; 00039 00040 private: 00041 // list of pointers to package contained in this set (the pointers go into 00042 // the pool) 00043 PkgList_type contents; 00044 // reverse package relations 00045 InvRel_type _required; 00046 InvRel_type _conflicted; 00047 InvRel_type _provided; 00048 InvRel_type _obsoleted; 00049 00050 public: 00051 // default copy constructor and assigment are ok 00052 00053 PkgSet(); 00054 00055 ~PkgSet(); 00056 00057 bool empty() const; 00058 00059 unsigned size() const; 00060 00066 void add( PMSolvablePtr pkg, bool force = false ); 00067 00073 void remove( PMSolvablePtr pkg ); 00074 00076 void remove( PkgName name ); 00077 00078 /* notification from PkgPool that a pkg has a new provides 00079 <b>obsolete</b> 00080 */ 00081 void new_provides( PMSolvablePtr pkg, const PkgRelation& prov ); 00082 00087 PMSolvablePtr lookup( const PkgName& name ) const; 00088 00089 PMSolvablePtr operator[] ( const PkgName& name ) const { return lookup(name); } 00093 bool includes( const PkgName& name ) const; 00094 00095 // iterator (steps through all contained packages) 00096 iterator begin() { return contents.begin(); } 00097 iterator end() { return contents.end(); } 00098 const_iterator begin() const { return contents.begin(); } 00099 const_iterator end() const { return contents.end(); } 00100 00119 const InvRel_type& required() const { return _required; } 00120 const InvRel_type& conflicted() const { return _conflicted; } 00121 const InvRel_type& provided() const { return _provided; } 00122 const InvRel_type& obsoleted() const { return _obsoleted; } 00123 00124 static const RevRelList_type& getRevRelforPkg(const InvRel_type&, const PkgName&); 00125 00126 // for convenience: directly return an iterator 00127 #define decl_InvRel_iterators(name) \ 00128 InvRel_iterator name##_begin() { \ 00129 return _##name.begin(); } \ 00130 InvRel_const_iterator name##_begin() const { \ 00131 return _##name.begin(); } \ 00132 InvRel_iterator name##_end() { \ 00133 return _##name.end(); } \ 00134 InvRel_const_iterator name##_end() const { \ 00135 return _##name.end(); } 00136 00137 decl_InvRel_iterators(required) 00138 decl_InvRel_iterators(conflicted) 00139 decl_InvRel_iterators(provided) 00140 decl_InvRel_iterators(obsoleted) 00141 00142 std::ostream& dumpOn(std::ostream& os); 00143 }; 00144 00145 #endif /* _PkgSet_h */ 00146 00147 00148 // Local Variables: 00149 // tab-width: 4 00150 // End:
1.4.4