1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/sat/Solvable.h
12 #ifndef ZYPP_SAT_SOLVABLE_H
13 #define ZYPP_SAT_SOLVABLE_H
17 #include "zypp/base/SafeBool.h"
19 #include "zypp/sat/detail/PoolMember.h"
20 #include "zypp/sat/IdStr.h"
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////
27 { /////////////////////////////////////////////////////////////////
29 ///////////////////////////////////////////////////////////////////
31 // CLASS NAME : Solvable
34 class Solvable : protected detail::PoolMember,
35 private base::SafeBool<Solvable>
38 /** Default ctor creates \ref nosolvable.*/
40 : _id( detail::noSolvableId ) {}
42 /** \ref PoolImpl ctor. */
43 explicit Solvable( detail::SolvableIdType id_r )
47 /** Represents no \ref Solvable. */
48 static const Solvable nosolvable;
50 /** Evaluate \ref Solvable in a boolean context (\c != \c nosolvable). */
51 using base::SafeBool<Solvable>::operator bool_type;
53 /** Return whether this \ref Solvable belongs to the system repo. */
54 bool isSystem() const;
60 VendorId vendor() const;
66 /** Return next Solvable in \ref Pool (or \ref nosolvable). */
67 Solvable nextInPool() const;
68 /** Return next Solvable in \ref Repo (or \ref nosolvable). */
69 Solvable nextInRepo() const;
71 /** Expert backdoor. */
72 ::_Solvable * get() const;
73 /** Expert backdoor. */
74 detail::SolvableIdType id() const { return _id; }
76 friend base::SafeBool<Solvable>::operator bool_type() const;
77 bool boolTest() const { return get(); }
79 detail::SolvableIdType _id;
81 ///////////////////////////////////////////////////////////////////
83 /** \relates Solvable Stream output */
84 std::ostream & operator<<( std::ostream & str, const Solvable & obj );
86 /** \relates Solvable */
87 inline bool operator==( const Solvable & lhs, const Solvable & rhs )
88 { return lhs.get() == rhs.get(); }
90 /** \relates Solvable */
91 inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
92 { return lhs.get() != rhs.get(); }
94 /** \relates Solvable */
95 inline bool operator<( const Solvable & lhs, const Solvable & rhs )
96 { return lhs.get() < rhs.get(); }
98 ///////////////////////////////////////////////////////////////////
100 { /////////////////////////////////////////////////////////////////
101 ///////////////////////////////////////////////////////////////////
103 // CLASS NAME : SolvableIterator
106 class SolvableIterator : public boost::iterator_adaptor<
107 SolvableIterator // Derived
108 , ::_Solvable* // Base
110 , boost::single_pass_traversal_tag // CategoryOrTraversal
111 , Solvable // Reference
116 : SolvableIterator::iterator_adaptor_( 0 )
119 explicit SolvableIterator( const Solvable & val_r )
120 : SolvableIterator::iterator_adaptor_( 0 )
121 { assignVal( val_r ); }
123 explicit SolvableIterator( SolvableIdType id_r )
124 : SolvableIterator::iterator_adaptor_( 0 )
125 { assignVal( Solvable( id_r ) ); }
128 friend class boost::iterator_core_access;
131 { assignVal( _val.nextInPool() ); }
133 Solvable dereference() const
136 void assignVal( const Solvable & val_r )
137 { _val = val_r; base_reference() = _val.get(); }
141 ///////////////////////////////////////////////////////////////////
142 /////////////////////////////////////////////////////////////////
143 } // namespace detail
144 ///////////////////////////////////////////////////////////////////
146 /////////////////////////////////////////////////////////////////
148 ///////////////////////////////////////////////////////////////////
149 /////////////////////////////////////////////////////////////////
151 ///////////////////////////////////////////////////////////////////
152 #endif // ZYPP_SAT_SOLVABLE_H