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 const CapabilityImpl::Kind & HalCap::kind() const 00025 { return CapTraits<Self>::kind; } 00026 00027 CapMatch HalCap::matches( const constPtr & rhs ) const 00028 { 00029 if ( sameKindAndRefers( rhs ) ) 00030 { 00031 intrusive_ptr<const Self> halrhs( asKind<Self>(rhs) ); 00032 if ( isEvalCmd() == halrhs->isEvalCmd() ) 00033 return CapMatch::irrelevant; 00034 00035 return( isEvalCmd() ? halrhs->evaluate() : evaluate() ); 00036 } 00037 return false; 00038 } 00039 00040 std::string HalCap::encode() const 00041 { 00042 std::string ret( "hal(" ); 00043 ret += _name; 00044 ret += ")"; 00045 if ( _op != Rel::ANY ) 00046 { 00047 ret += " "; 00048 ret += _op.asString(); 00049 ret += " "; 00050 ret += _value; 00051 } 00052 return ret; 00053 } 00054 00055 std::string HalCap::index() const 00056 { 00057 return "hal()"; 00058 } 00059 00060 bool HalCap::isEvalCmd() const 00061 { return _name.empty(); } 00062 00063 bool HalCap::evaluate() const 00064 { 00065 return target::hal::Hal::instance().query( _name, _op, _value ); 00066 } 00067 00069 } // namespace capability 00072 } // namespace zypp