00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #include "zypp/capability/HalCap.h" 00013 #include "zypp/target/hal/Hal.h" 00014 00015 using namespace std; 00016 00018 namespace zypp 00019 { 00020 00021 namespace capability 00022 { 00023 00024 IMPL_PTR_TYPE(HalCap) 00025 00026 const CapabilityImpl::Kind & HalCap::kind() const 00027 { return CapTraits<Self>::kind; } 00028 00029 CapMatch HalCap::matches( const CapabilityImpl::constPtr & rhs ) const 00030 { 00031 if ( sameKindAndRefers( rhs ) ) 00032 { 00033 intrusive_ptr<const Self> halrhs( asKind<Self>(rhs) ); 00034 if ( isEvalCmd() == halrhs->isEvalCmd() ) 00035 return CapMatch::irrelevant; 00036 00037 return( isEvalCmd() ? halrhs->evaluate() : evaluate() ); 00038 } 00039 return false; 00040 } 00041 00042 std::string HalCap::encode() const 00043 { 00044 std::string ret( "hal(" ); 00045 ret += _name; 00046 ret += ")"; 00047 if ( _op != Rel::ANY ) 00048 { 00049 ret += " "; 00050 ret += _op.asString(); 00051 ret += " "; 00052 ret += _value; 00053 } 00054 return ret; 00055 } 00056 00057 std::string HalCap::index() const 00058 { 00059 return "hal()"; 00060 } 00061 00062 bool HalCap::isEvalCmd() const 00063 { return _name.empty(); } 00064 00065 bool HalCap::evaluate() const 00066 { 00067 return target::hal::Hal::instance().query( _name, _op, _value ); 00068 } 00069 00071 } // namespace capability 00074 } // namespace zypp
1.5.3