Capability.h

Go to the documentation of this file.
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     Rel op() const;
00124     Edition edition() const;
00125 
00126   private:
00127     typedef capability::CapabilityImpl          Impl;
00128     typedef capability::CapabilityImpl_Ptr      Impl_Ptr ;
00129     typedef capability::CapabilityImpl_constPtr Impl_constPtr;
00130 
00132     friend class CapFactory;
00133 
00135     explicit
00136     Capability( Impl_Ptr impl_r );
00137 
00138   private:
00140     friend class capability::CapabilityImpl;
00142     RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
00143   };
00145 
00146   template<class _Cap>
00147     inline bool isKind( const Capability & cap )
00148     { return cap.kind() == capability::CapTraits<_Cap>::kind; }
00149 
00151 
00153   struct CapOrder : public std::binary_function<Capability, Capability, bool>
00154   {
00155     bool operator()( const Capability & lhs, const Capability & rhs ) const
00156     { return lhs._pimpl.get() < rhs._pimpl.get(); }
00157   };
00158 
00160 
00162   inline bool operator==( const Capability & lhs, const Capability & rhs )
00163   { return lhs._pimpl.get() == rhs._pimpl.get(); }
00164 
00166   inline bool operator!=( const Capability & lhs, const Capability & rhs )
00167   { return ! (lhs == rhs); }
00168 
00170   extern std::ostream & operator<<( std::ostream & str, const Capability & obj );
00171 
00173 } // namespace zypp
00175 #endif // ZYPP_CAPABILITY_H

Generated on Thu Jul 6 00:07:20 2006 for zypp by  doxygen 1.4.6