* \todo Fix incaccuracy.
*/
static CapabilityImpl::Ptr buildHal( const Resolvable::Kind & refers_r,
- const std::string & name_r,
- Rel op_r = Rel::ANY,
- const std::string & value_r = std::string() )
+ const std::string & name_r,
+ Rel op_r = Rel::ANY,
+ const std::string & value_r = std::string() )
{
if ( op_r != Rel::ANY )
{
- ZYPP_THROW( Exception("Unsupported kind of Hal Capability") );
+ ZYPP_THROW( Exception("Unsupported kind of Hal Capability '" + op_r.asString() + "'") );
}
//split: hal(name) [op string]
{
// Hal always refers to 'System' kind of Resolvable.
return usetInsert
- ( new capability::HalCap( ResTraits<System>::kind,
+ ( new capability::HalCap( ResTraits<SystemResObject>::kind,
what[1].str() ) );
}
// otherwise
- ZYPP_THROW( Exception("Unsupported kind of Hal Capability") );
+ ZYPP_THROW( Exception("Unsupported kind of Hal Capability '" + name_r + "'") );
return NULL; // make gcc happy
}
* \todo Fix incaccuracy.
*/
static CapabilityImpl::Ptr buildModalias( const Resolvable::Kind & refers_r,
- const std::string & name_r,
- Rel op_r = Rel::ANY,
- const std::string & value_r = std::string() )
+ const std::string & name_r,
+ Rel op_r = Rel::ANY,
+ const std::string & value_r = std::string() )
{
if ( op_r != Rel::ANY )
{
- ZYPP_THROW( Exception("Unsupported kind of Modalias Capability") );
+ ZYPP_THROW( Exception("Unsupported kind of Modalias Capability '" + op_r.asString() + "'") );
}
//split: modalias(name) [op string]
{
// Modalias always refers to 'System' kind of Resolvable.
return usetInsert
- ( new capability::ModaliasCap( ResTraits<System>::kind,
- what[1].str() ) );
+ ( new capability::ModaliasCap( ResTraits<SystemResObject>::kind,
+ what[1].str() ) );
}
// otherwise
- ZYPP_THROW( Exception("Unsupported kind of Modalias Capability") );
+ ZYPP_THROW( Exception("Unsupported kind of Modalias Capability'" + name_r + "'") );
return NULL; // make gcc happy
}
};
{
return Capability( Impl::buildHal( refers_r, strval_r ) );
}
- else if ( Impl::isFileSpec( strval_r ) )
+ if ( Impl::isModaliasSpec( strval_r ) )
+ {
+ return Capability( Impl::buildModalias( refers_r, strval_r ) );
+ }
+ if ( Impl::isFileSpec( strval_r ) )
{
return Capability( Impl::buildFile( refers_r, strval_r ) );
}
- else
- {
- // strval_r has at least two words which could make 'op edition'?
- // improve regex!
- str::regex rx( "(.*[^ \t])([ \t]+)([^ \t]+)([ \t]+)([^ \t]+)" );
- str::smatch what;
- if( str::regex_match( strval_r.begin(), strval_r.end(),what, rx ) )
- {
- Rel op;
- Edition edition;
- try
- {
- op = Rel(what[3].str());
- edition = Edition(what[5].str());
- }
- catch ( Exception & excpt )
- {
- // So they don't make valid 'op edition'
- ZYPP_CAUGHT( excpt );
- DBG << "Trying named cap for: " << strval_r << endl;
- // See whether it makes a named cap.
- return Capability( Impl::buildNamed( refers_r, strval_r ) );
- }
-
- // Valid 'op edition'
- return Capability ( Impl::buildVersioned( refers_r,
- what[1].str(), op, edition ) );
- }
- //else
- // not a VersionedCap
-
- return Capability( Impl::buildNamed( refers_r, strval_r ) );
- }
+
+ // strval_r has at least two words which could make 'op edition'?
+ // improve regex!
+ str::regex rx( "(.*[^ \t])([ \t]+)([^ \t]+)([ \t]+)([^ \t]+)" );
+ str::smatch what;
+ if( str::regex_match( strval_r.begin(), strval_r.end(),what, rx ) )
+ {
+ Rel op;
+ Edition edition;
+ try
+ {
+ op = Rel(what[3].str());
+ edition = Edition(what[5].str());
+ }
+ catch ( Exception & excpt )
+ {
+ // So they don't make valid 'op edition'
+ ZYPP_CAUGHT( excpt );
+ DBG << "Trying named cap for: " << strval_r << endl;
+ // See whether it makes a named cap.
+ return Capability( Impl::buildNamed( refers_r, strval_r ) );
+ }
+
+ // Valid 'op edition'
+ return Capability ( Impl::buildVersioned( refers_r,
+ what[1].str(), op, edition ) );
+ }
+ //else
+ // not a VersionedCap
+ return Capability( Impl::buildNamed( refers_r, strval_r ) );
}
catch ( Exception & excpt )
{
{
return Capability( Impl::buildHal( refers_r, name_r, Rel(op_r), edition_r ) );
}
+ if ( Impl::isModaliasSpec( name_r ) )
+ {
+ return Capability( Impl::buildModalias( refers_r, name_r, Rel(op_r), edition_r ) );
+ }
// Try creating Rel and Edition, then parse
return parse( refers_r, name_r, Rel(op_r), Edition(edition_r) );
}
{
return Capability( Impl::buildHal( refers_r, name_r, op_r, edition_r.asString() ) );
}
- return Capability
- ( Impl::buildVersioned( refers_r, name_r, op_r, edition_r ) );
+ if ( Impl::isModaliasSpec( name_r ) )
+ {
+ return Capability( Impl::buildModalias( refers_r, name_r, op_r, edition_r.asString() ) );
+ }
+ return Capability( Impl::buildVersioned( refers_r, name_r, op_r, edition_r ) );
}
catch ( Exception & excpt )
{
Rel.h \
RelCompare.h \
ResObject.h \
+ SystemResObject.h \
Resolvable.h \
ResTraits.h \
ResStatus.h \
Range.cc \
Rel.cc \
ResObject.cc \
+ SystemResObject.cc \
Resolvable.cc \
ResTraits.cc \
ResStatus.cc \
const ResolvableTraits::KindType ResTraits<Atom> ::kind( "Atom" );
template<>
- const ResolvableTraits::KindType ResTraits<System> ::kind( "System" );
+ const ResolvableTraits::KindType ResTraits<SystemResObject> ::kind( "System" );
template<>
const ResolvableTraits::KindType ResTraits<SrcPackage> ::kind( "SrcPackage" );
class Message;
class Language;
- class System;
+ class SystemResObject;
/** Base of ResTraits. Defines the Resolvable::Kind type. */
struct ResolvableTraits
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/SystemResObject.cc
+ *
+*/
+//#include <iostream>
+//#include "zypp/base/Logger.h"
+
+#include "zypp/SystemResObject.h"
+#include "zypp/CapFactory.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : SystemResObject::SystemResObject
+ // METHOD TYPE : Ctor
+ //
+ SystemResObject::SystemResObject( const NVRAD & nvrad_r )
+ : ResObject( TraitsType::kind, nvrad_r )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : SystemResObject::~SystemResObject
+ // METHOD TYPE : Dtor
+ //
+ SystemResObject::~SystemResObject()
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : SystemResObject::instance()
+ // METHOD TYPE : SystemResObject::Ptr
+ //
+ SystemResObject::Ptr SystemResObject::instance()
+ {
+ static Ptr _ptr;
+ if ( ! _ptr )
+ {
+ NVRAD dataCollect( "system" );
+ dataCollect[Dep::PROVIDES].insert( CapFactory().halEvalCap() );
+ dataCollect[Dep::PROVIDES].insert( CapFactory().modaliasEvalCap() );
+
+ detail::ResImplTraits<detail::SystemResObjectImplIf>::Ptr sysImpl;
+ _ptr = detail::makeResolvableAndImpl( dataCollect, sysImpl );
+ }
+
+ return _ptr ;
+ }
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/SystemResObject.h
+ *
+*/
+#ifndef ZYPP_SYSTEMRESOBJECT_H
+#define ZYPP_SYSTEMRESOBJECT_H
+
+#include "zypp/ResObject.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ class SystemResObject;
+
+ ///////////////////////////////////////////////////////////////////
+ namespace detail
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : SystemResObjectImplIf
+ //
+ /** Abstract SystemResObject implementation interface.
+ */
+ class SystemResObjectImplIf : public ResObjectImplIf
+ {
+ public:
+ typedef SystemResObject ResType;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace detail
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : SystemResObject
+ //
+ /** */
+ class SystemResObject : public ResObject
+ {
+ public:
+ typedef detail::SystemResObjectImplIf Impl;
+ typedef SystemResObject Self;
+ typedef ResTraits<Self> TraitsType;
+ typedef TraitsType::PtrType Ptr;
+ typedef TraitsType::constPtrType constPtr;
+
+ /** Default SystemResObject instance. */
+ static Ptr instance();
+
+ protected:
+ /** Ctor */
+ SystemResObject( const NVRAD & nvrad_r );
+ /** Dtor */
+ virtual ~SystemResObject();
+
+ private:
+ /** Access implementation */
+ virtual Impl & pimpl() = 0;
+ /** Access implementation */
+ virtual const Impl & pimpl() const = 0;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SYSTEMRESOBJECT_H
std::string HalCap::index() const
{
- std::string ret( "hal(" );
- ret += _name;
- return ret += ")";
+ return "hal()";
}
bool HalCap::isEvalCmd() const
/** \file zypp/capability/ModaliasCap.cc
*
*/
+#include <iostream>
+#include "zypp/base/Logger.h"
+
#include "zypp/capability/ModaliasCap.h"
#include "zypp/target/modalias/Modalias.h"
std::string ModaliasCap::index() const
{
- std::string ret( "modalias(" );
- ret += _name;
- return ret += ")";
+ return "modalias()";
}
bool ModaliasCap::isEvalCmd() const
bool operator()( const Capability & cap_r ) const
{
- if (cap_r.index().substr( 0, 9 ) == "modalias(") {
- deps[Dep::SUPPLEMENTS].insert( CapFactory().parse( ResTraits<System>::kind, cap_r.index() ) );
- return true; // strip from provides
- }
+ if ( isKind<capability::ModaliasCap>(cap_r) )
+ {
+ deps[Dep::SUPPLEMENTS].insert( cap_r );
+ return true; // strip from provides
+ }
if (cap_r.index().substr( 0, 7 ) != "locale(")
return false;
next = provides.size()-1; // none left, set next to end-1 (strip trailing ')' )
string loc( provides, pos, next-pos );
- if (loc.size() < 2
- || loc.size() > 5)
- {
- WAR << "Looks wrong " << cap_r.index() << endl;
- }
if (_zypp) _zypp->availableLocale( Locale( loc ) );
deps[Dep::FRESHENS].insert( f.parse( ResTraits<Language>::kind, loc ) );
pos = next + 1;
switch (_trigger) {
case ResolverInfoMisc::NONE: os << "none"; break;
case ResolverInfoMisc::OBSOLETE: os << "obsoletes"; break;
- case ResolverInfoMisc::REQUIRE: os << "requires"; break;
+ case ResolverInfoMisc::REQUIRE: os << "requires"; break;
case ResolverInfoMisc::CONFLICT: os << "conflicts"; break;
}
os << endl;
// Translator: Notation for atom (part of a patch)
return _( "atom" );
}
- else if (kind == ResTraits<System>::kind) {
+ else if (kind == ResTraits<SystemResObject>::kind) {
// Translator: Notation for computer system
return _( "system" );
}
cpy->_other_capability = _other_capability;
cpy->_action = _action;
cpy->_trigger = _trigger;
-
+
return cpy;
}