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/CapMatch.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 ( 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 /** Whether to consider this Capability.
105 * Evaluates the Capabilities pre-condition (if any), and
106 * returns whether the condition applies. If not, the Capability
109 bool relevant() const;
111 /** Return whether the Capabilities match.
112 * If either Capability is not \ref relevant, CapMatch::irrelevant
115 CapMatch matches( const Capability & rhs ) const;
117 /** More or less human readable representation as string. */
118 std::string asString() const;
120 /** accessors needed by solver/zmd */
122 std::string index() const;
123 /** Deprecated, defaults to Rel::NONE */
125 /** Deprecated, defaults to Edition::noedition */
126 Edition edition() const;
129 /** Pointer to implementation */
130 RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
132 ///////////////////////////////////////////////////////////////////
134 /** Ordering relation used by ::CapSet. */
135 struct CapOrder : public std::binary_function<Capability, Capability, bool>
137 bool operator()( const Capability & lhs, const Capability & rhs ) const
138 { return lhs._pimpl.get() < rhs._pimpl.get(); }
141 ///////////////////////////////////////////////////////////////////
143 /** \relates Capability */
144 inline bool operator==( const Capability & lhs, const Capability & rhs )
145 { return lhs._pimpl.get() == rhs._pimpl.get(); }
147 /** \relates Capability */
148 inline bool operator!=( const Capability & lhs, const Capability & rhs )
149 { return ! (lhs == rhs); }
151 /** \relates Capability Stream output */
152 extern std::ostream & operator<<( std::ostream & str, const Capability & obj );
154 /////////////////////////////////////////////////////////////////
156 ///////////////////////////////////////////////////////////////////
157 #endif // ZYPP_CAPABILITY_H