1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Capability.h
12 #ifndef ZYPP_CAPABILITY_H
13 #define ZYPP_CAPABILITY_H
18 #include "zypp/base/PtrTypes.h"
20 #include "zypp/Resolvable.h"
21 #include "zypp/solver/SolverFwd.h"
23 ///////////////////////////////////////////////////////////////////
25 { /////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////
29 DEFINE_PTR_TYPE(CapabilityImpl);
30 /////////////////////////////////////////////////////////////////
31 } // namespace capability
32 ///////////////////////////////////////////////////////////////////
36 ///////////////////////////////////////////////////////////////////
38 // CLASS NAME : Capability
40 /** Resolvable capabilitiy.
42 * Capability is created by a Factory class. Only a default ctor
43 * creating a dummy capability is provided.
48 * cap = CapFactory().parse( ResTraits<Patch>::kind,
51 * Edition( parsed.ver,
55 * catch ( const Exception & excpt_r )
57 * ERR << excpt_r << endl;
58 * ... Or maybe just WAR, or ?
61 * \see CapFactory: Factory creating Capability.
63 * \invariant Nonzero \c _pimpl
64 * \invariant Unified \c _pimpl asserted by CapFactory.
66 * \todo Need a trival return from matches. E.g. Conditional
67 * cpabilities must be able to indicate that they should be
68 * treated as if they were not present at all, if the precondition
69 * does no apply. Same for the defaut Capability.
74 friend class CapFactory;
76 /** Ordering for use in CapSet */
77 friend class CapOrder;
78 friend bool operator==( const Capability & lhs, const Capability & rhs );
79 friend std::ostream & operator<<( std::ostream & str, const Capability & obj );
82 typedef capability::CapabilityImpl Impl;
83 typedef capability::CapabilityImpl_Ptr Impl_Ptr ;
84 typedef capability::CapabilityImpl_constPtr Impl_constPtr;
88 Capability( Impl_Ptr impl_r );
92 typedef CapFactory Factory;
94 /** DefaultCtor creating a dummy Capability. */
98 virtual ~Capability();
101 /** Kind of Resolvable the Capability refers to. */
102 const Resolvable::Kind & refers() const;
104 /** More or less human readable representation as string. */
105 std::string asString() const;
108 bool matches( Resolvable::constPtr resolvable_r,
109 solver::Context_constPtr solverContext_r ) const;
111 /** \todo this does not make sense until ther's a default context available*/
112 bool matches( Resolvable::constPtr resolvable_r ) const;
115 /** Pointer to implementation */
116 RW_pointer<Impl,Impl_Ptr> _pimpl;
118 ///////////////////////////////////////////////////////////////////
120 /** Ordering relation used by ::CapSet. */
121 struct CapOrder : public std::binary_function<Capability, Capability, bool>
123 bool operator()( const Capability & lhs, const Capability & rhs ) const
124 { return lhs._pimpl.get() < rhs._pimpl.get(); }
127 ///////////////////////////////////////////////////////////////////
129 /** \relates Capability */
130 inline bool operator==( const Capability & lhs, const Capability & rhs )
131 { return lhs._pimpl.get() == rhs._pimpl.get(); }
133 /** \relates Capability */
134 inline bool operator!=( const Capability & lhs, const Capability & rhs )
135 { return ! (lhs == rhs); }
137 /** \relates Capability Stream output */
138 extern std::ostream & operator<<( std::ostream & str, const Capability & obj );
140 /////////////////////////////////////////////////////////////////
142 ///////////////////////////////////////////////////////////////////
143 #endif // ZYPP_CAPABILITY_H