00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_CAPABILITY_H 00013 #define ZYPP_CAPABILITY_H 00014 00015 #include <iosfwd> 00016 #include <functional> 00017 00018 #include "zypp/base/PtrTypes.h" 00019 #include "zypp/capability/CapTraits.h" 00020 #include "zypp/Resolvable.h" 00021 #include "zypp/CapMatch.h" 00022 00024 namespace zypp 00025 { 00026 00027 namespace capability 00028 { 00029 DEFINE_PTR_TYPE(CapabilityImpl); 00031 } // namespace capability 00033 00034 class CapFactory; 00035 00037 // 00038 // CLASS NAME : Capability 00039 // 00071 class Capability 00072 { 00074 friend class CapOrder; 00075 friend bool operator==( const Capability & lhs, const Capability & rhs ); 00076 friend std::ostream & operator<<( std::ostream & str, const Capability & obj ); 00077 00078 public: 00080 typedef capability::CapabilityTraits::KindType Kind; 00081 00082 public: 00084 Capability(); 00085 00087 virtual ~Capability(); 00088 00093 static const Capability noCap; 00094 00095 public: 00097 const Kind & kind() const; 00098 00100 const Resolvable::Kind & refers() const; 00101 00107 bool relevant() const; 00108 00113 CapMatch matches( const Capability & rhs ) const; 00114 00116 std::string asString() const; 00117 00120 std::string index() const; 00122 std::string name() const; 00124 Rel op() const; 00126 Edition edition() const; 00127 00128 private: 00129 typedef capability::CapabilityImpl Impl; 00130 typedef capability::CapabilityImpl_Ptr Impl_Ptr ; 00131 typedef capability::CapabilityImpl_constPtr Impl_constPtr; 00132 00134 friend class CapFactory; 00135 00137 explicit 00138 Capability( Impl_Ptr impl_r ); 00139 00140 private: 00142 friend class capability::CapabilityImpl; 00144 RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl; 00145 }; 00147 00148 template<class _Cap> 00149 inline bool isKind( const Capability & cap ) 00150 { return cap.kind() == capability::CapTraits<_Cap>::kind; } 00151 00153 00155 struct CapOrder : public std::binary_function<Capability, Capability, bool> 00156 { 00157 bool operator()( const Capability & lhs, const Capability & rhs ) const 00158 { return lhs._pimpl.get() < rhs._pimpl.get(); } 00159 }; 00160 00162 00164 inline bool operator==( const Capability & lhs, const Capability & rhs ) 00165 { return lhs._pimpl.get() == rhs._pimpl.get(); } 00166 00168 inline bool operator!=( const Capability & lhs, const Capability & rhs ) 00169 { return ! (lhs == rhs); } 00170 00172 extern std::ostream & operator<<( std::ostream & str, const Capability & obj ); 00173 00175 } // namespace zypp 00177 #endif // ZYPP_CAPABILITY_H
1.5.0