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"
21 #include "zypp/sat/IdRel.h"
23 ///////////////////////////////////////////////////////////////////
25 { /////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////
30 ///////////////////////////////////////////////////////////////////
32 // CLASS NAME : Solvable
35 class Solvable : protected detail::PoolMember,
36 private base::SafeBool<Solvable>
39 /** Default ctor creates \ref nosolvable.*/
41 : _id( detail::noSolvableId ) {}
43 /** \ref PoolImpl ctor. */
44 explicit Solvable( detail::SolvableIdType id_r )
48 /** Represents no \ref Solvable. */
49 static const Solvable nosolvable;
51 /** Evaluate \ref Solvable in a boolean context (\c != \c nosolvable). */
52 using base::SafeBool<Solvable>::operator bool_type;
54 /** Return whether this \ref Solvable belongs to the system repo. */
55 bool isSystem() const;
61 VendorId vendor() const;
67 /** Return next Solvable in \ref Pool (or \ref nosolvable). */
68 Solvable nextInPool() const;
69 /** Return next Solvable in \ref Repo (or \ref nosolvable). */
70 Solvable nextInRepo() const;
72 /** Expert backdoor. */
73 ::_Solvable * get() const;
74 /** Expert backdoor. */
75 detail::SolvableIdType id() const { return _id; }
77 friend base::SafeBool<Solvable>::operator bool_type() const;
78 bool boolTest() const { return get(); }
80 detail::SolvableIdType _id;
82 ///////////////////////////////////////////////////////////////////
84 /** \relates Solvable Stream output */
85 std::ostream & operator<<( std::ostream & str, const Solvable & obj );
87 /** \relates Solvable */
88 inline bool operator==( const Solvable & lhs, const Solvable & rhs )
89 { return lhs.get() == rhs.get(); }
91 /** \relates Solvable */
92 inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
93 { return lhs.get() != rhs.get(); }
95 /** \relates Solvable */
96 inline bool operator<( const Solvable & lhs, const Solvable & rhs )
97 { return lhs.get() < rhs.get(); }
99 ///////////////////////////////////////////////////////////////////
101 { /////////////////////////////////////////////////////////////////
102 ///////////////////////////////////////////////////////////////////
104 // CLASS NAME : SolvableIterator
107 class SolvableIterator : public boost::iterator_adaptor<
108 SolvableIterator // Derived
109 , ::_Solvable* // Base
111 , boost::single_pass_traversal_tag // CategoryOrTraversal
112 , Solvable // Reference
117 : SolvableIterator::iterator_adaptor_( 0 )
120 explicit SolvableIterator( const Solvable & val_r )
121 : SolvableIterator::iterator_adaptor_( 0 )
122 { assignVal( val_r ); }
124 explicit SolvableIterator( SolvableIdType id_r )
125 : SolvableIterator::iterator_adaptor_( 0 )
126 { assignVal( Solvable( id_r ) ); }
129 friend class boost::iterator_core_access;
132 { assignVal( _val.nextInPool() ); }
134 Solvable dereference() const
137 void assignVal( const Solvable & val_r )
138 { _val = val_r; base_reference() = _val.get(); }
142 ///////////////////////////////////////////////////////////////////
143 /////////////////////////////////////////////////////////////////
144 } // namespace detail
145 ///////////////////////////////////////////////////////////////////
147 /////////////////////////////////////////////////////////////////
149 ///////////////////////////////////////////////////////////////////
150 /////////////////////////////////////////////////////////////////
152 ///////////////////////////////////////////////////////////////////
153 #endif // ZYPP_SAT_SOLVABLE_H