- Define pointer types for specific capability
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Wed, 21 Mar 2007 16:52:24 +0000 (16:52 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Wed, 21 Mar 2007 16:52:24 +0000 (16:52 +0000)
  implementations
- Get rid of the edition() and op() accessors
  in Capability class. Those are only used
  by uggly hacks which don't deserve a
  convenience API to their uggly behavior.

13 files changed:
zypp/Capability.cc
zypp/Capability.h
zypp/capability/CapabilityImpl.h
zypp/capability/FileCap.cc
zypp/capability/FileCap.h
zypp/capability/NamedCap.cc
zypp/capability/NamedCap.h
zypp/capability/VersionedCap.cc
zypp/capability/VersionedCap.h
zypp/data/ResolvableData.h
zypp/detail/ResolvableImpl.cc
zypp/solver/detail/Testcase.cc
zypp2/CMakeLists.txt

index 35bcb08..b644211 100644 (file)
@@ -67,11 +67,11 @@ namespace zypp
   std::string Capability::index() const
   { return _pimpl->index(); }
 
-  Rel Capability::op() const
-  { return _pimpl->op(); }
-
-  Edition Capability::edition() const
-  { return _pimpl->edition(); }
+//   Rel Capability::op() const
+//   { return _pimpl->op(); }
+// 
+//   Edition Capability::edition() const
+//   { return _pimpl->edition(); }
 
   /******************************************************************
   **
index 7820f9c..c92c453 100644 (file)
@@ -118,10 +118,6 @@ namespace zypp
     /** accessors needed by solver/zmd  */
     /** Deprecated */
     std::string index() const;
-    /** Deprecated, defaults to Rel::NONE */
-    Rel op() const;
-    /** Deprecated, defaults to Edition::noedition */
-    Edition edition() const;
 
   private:
     typedef capability::CapabilityImpl          Impl;
index d8a4e27..138f0bb 100644 (file)
@@ -80,12 +80,6 @@ namespace zypp
       */
       virtual std::string index() const
       { return encode(); }
-      /** \deprecated, defaults to Rel::NONE */
-      virtual Rel op() const
-      { return Rel::NONE; }
-      /** \deprecated, defaults to Edition::noedition */
-      virtual Edition edition() const
-      { return Edition::noedition; }
 
     public:
       /** Solver hack. */
index 6a40810..6d68f60 100644 (file)
@@ -20,10 +20,12 @@ namespace zypp
   namespace capability
   { /////////////////////////////////////////////////////////////////
 
+    IMPL_PTR_TYPE(FileCap)
+    
     const CapabilityImpl::Kind & FileCap::kind() const
     { return CapTraits<Self>::kind; }
 
-    CapMatch FileCap::matches( const constPtr & rhs ) const
+    CapMatch FileCap::matches( const CapabilityImpl::constPtr & rhs ) const
     {
       return (    sameKindAndRefers( rhs )
                && _fname == asKind<Self>(rhs)->_fname );
index a3f7ad6..b96bf06 100644 (file)
@@ -21,6 +21,8 @@ namespace zypp
   namespace capability
   { /////////////////////////////////////////////////////////////////
 
+    DEFINE_PTR_TYPE(FileCap)
+    
     ///////////////////////////////////////////////////////////////////
     //
     // CLASS NAME : FileCap
@@ -33,6 +35,8 @@ namespace zypp
     {
     public:
       typedef FileCap Self;
+      typedef FileCap_Ptr       Ptr;
+      typedef FileCap_constPtr  constPtr;
 
       /** Ctor */
       FileCap( const Resolvable::Kind & refers_r, const std::string & fname_r )
@@ -41,11 +45,14 @@ namespace zypp
       {}
 
     public:
+      std::string filename() const
+      { return _fname; }
+      
       /**  */
       virtual const Kind & kind() const;
 
       /** Same kind, refers and filename. */
-      virtual CapMatch matches( const constPtr & rhs ) const;
+      virtual CapMatch matches( const CapabilityImpl::constPtr & rhs ) const;
 
       /** Filename. */
       virtual std::string encode() const;
index 9c3c8bd..a8efd80 100644 (file)
@@ -20,10 +20,12 @@ namespace zypp
   namespace capability
   { /////////////////////////////////////////////////////////////////
 
+    IMPL_PTR_TYPE(NamedCap)
+    
     const CapabilityImpl::Kind & NamedCap::kind() const
     { return CapTraits<Self>::kind; }
 
-    CapMatch NamedCap::matches( const constPtr & rhs ) const
+    CapMatch NamedCap::matches( const CapabilityImpl::constPtr & rhs ) const
     {
       if ( sameKindAndRefers( rhs ) )
         {
index 8c39242..0966450 100644 (file)
@@ -21,6 +21,8 @@ namespace zypp
   namespace capability
   { /////////////////////////////////////////////////////////////////
 
+    DEFINE_PTR_TYPE(NamedCap)
+    
     ///////////////////////////////////////////////////////////////////
     //
     // CLASS NAME : NamedCap
@@ -32,6 +34,8 @@ namespace zypp
     {
     public:
       typedef NamedCap Self;
+      typedef NamedCap_Ptr       Ptr;
+      typedef NamedCap_constPtr  constPtr;
 
       /** Ctor */
       NamedCap( const Resolvable::Kind & refers_r, const std::string & name_r )
@@ -44,15 +48,17 @@ namespace zypp
       virtual const Kind & kind() const;
 
       /** Return whether the Capabilities match. */
-      virtual CapMatch matches( const constPtr & rhs ) const;
+      virtual CapMatch matches( const CapabilityImpl::constPtr & rhs ) const;
 
       /** Name. */
       virtual std::string encode() const;
-
-    protected:
+      
       /**  */
       const std::string & name() const
       { return _name; }
+      
+    protected:
+      
       /**  Rel::ANY. */
       virtual const Edition::MatchRange & range() const;
 
index 4767490..dac6511 100644 (file)
@@ -20,6 +20,8 @@ namespace zypp
   namespace capability
   { /////////////////////////////////////////////////////////////////
 
+    IMPL_PTR_TYPE(VersionedCap)
+    
     std::string VersionedCap::encode() const
     {
       std::string ret( name() );
index 064b60d..433a55e 100644 (file)
@@ -21,6 +21,8 @@ namespace zypp
   namespace capability
   { /////////////////////////////////////////////////////////////////
 
+    DEFINE_PTR_TYPE(VersionedCap)
+    
     ///////////////////////////////////////////////////////////////////
     //
     // CLASS NAME : VersionedCap
@@ -31,7 +33,11 @@ namespace zypp
     */
     class VersionedCap : public NamedCap
     {
-    public:
+      public:
+      typedef VersionedCap Self;
+      typedef VersionedCap_Ptr       Ptr;
+      typedef VersionedCap_constPtr  constPtr;
+
       /** Ctor */
       VersionedCap( const Resolvable::Kind & refers_r,
                     const std::string & name_r,
index 830d6ad..145c065 100644 (file)
@@ -34,37 +34,7 @@ namespace zypp
 namespace data
 {
   typedef std::list< capability::CapabilityImpl::Ptr > DependencyList;
-
-  struct Dependencies
-  {
-//     DependencyList & operator[]( zypp::Dep idx )
-//     {
-//       switch ( idx.inSwitch() )
-//       {
-//         case zypp::Dep::PROVIDES.inSwitch(): return provides; break;
-//         case zypp::Dep::CONFLICTS.inSwitch(): return conflicts; break;
-//         case zypp::Dep::OBSOLETES.inSwitch(): return obsoletes; break;
-//         case zypp::Dep::FRESHENS.inSwitch(): return freshens; break;
-//         case zypp::Dep::REQUIRES.inSwitch(): return requires; break;
-//         case zypp::Dep::PREREQUIRES.inSwitch(): return prerequires; break;
-//         case zypp::Dep::RECOMMENDS.inSwitch(): return recommends; break;
-//         case zypp::Dep::SUGGESTS.inSwitch(): return suggests; break;
-//         case zypp::Dep::SUPPLEMENTS.inSwitch(): return supplements; break;
-//         case zypp::Dep::ENHANCES.inSwitch(): return enhances; break;
-//       }
-//     }
-    
-    DependencyList provides;
-    DependencyList conflicts;
-    DependencyList obsoletes;
-    DependencyList freshens;
-    DependencyList requires;
-    DependencyList prerequires;
-    DependencyList recommends;
-    DependencyList suggests;
-    DependencyList supplements;
-    DependencyList enhances;
-  };
+  typedef std::map< zypp::Dep, DependencyList> Dependencies;
   
   class Resolvable : public base::ReferenceCounted, private base::NonCopyable
   {
index dc17408..fa7c851 100644 (file)
@@ -168,13 +168,20 @@ namespace zypp
        // if its a provides, check for non-empty edition since
        //   kernels provide "kernel-flavor-nongpl" (empty edition)
        //     and "kernel-flavor = x.y" (non-empty edition)
-
-       if ( it->index().substr( 0, 7 ) == "kernel-"
-            && (dep == Dep::REQUIRES
-               || it->edition() != Edition::noedition ) )
-       {
-         return it->index().erase( 0, 7 );     // erase "kernel-"
-       }
+        capability::VersionedCap::constPtr vercap = capability::asKind<capability::VersionedCap>(*it);
+        if ( vercap ) {
+          
+          if ( vercap->index().substr( 0, 7 ) == "kernel-"
+              && (dep == Dep::REQUIRES
+                  || vercap->edition() != Edition::noedition ) )
+          {
+            return vercap->index().erase( 0, 7 );      // erase "kernel-"
+          }
+        }
+        else
+        {
+          ERR << *it << " is not a VersionedCap" << std::endl;
+        }
       }
       return "";
     }
@@ -201,12 +208,17 @@ namespace zypp
       flavor.append( ":" );
       CapFactory factory;
       deps[dep].clear();
-      for (CapSet::iterator it = cset.begin(); it != cset.end(); ++it) {
+      for (CapSet::const_iterator it = cset.begin(); it != cset.end(); ++it) {
        std::string idx( it->index() );
        if ( idx.substr( 0, 7 ) == "kernel("            // capability is "kernel(..."
             && idx.find( ":" ) == std::string::npos )  //  without a colon
        {
-         deps[dep].insert( factory.parse( it->refers(), idx.insert( 7, flavor ), it->op(), it->edition() ) );
+           capability::VersionedCap::constPtr vercap = capability::asKind<capability::VersionedCap>(*it);
+          if ( vercap )
+           
+            deps[dep].insert( factory.parse( vercap->refers(), idx.insert( 7, flavor ), vercap->op(), vercap->edition() ) );
+          else
+            ERR << *it << " is not a VersionedCap" << std::endl;
        }
        else {
          deps[dep].insert( *it );
index bb570ef..38c256c 100644 (file)
@@ -94,21 +94,27 @@ template<>
 std::string helixXML( const Capability &cap )
 {
     stringstream str;
-    if (isKind<VersionedCap>(cap)
-       && cap.op() != Rel::NONE
-       && cap.op() != Rel::ANY
-       && !cap.edition().version().empty()) {
-       // version capability
-       str << "<dep name='" << xml_escape(cap.index()) << "' op='" << xml_escape(cap.op().asString()) <<
-           "' version='" << cap.edition().version() << "'";
-       if (!cap.edition().release().empty())
-           str << " release='" << cap.edition().release() << "'";
-       if (cap.edition().epoch() != Edition::noepoch)
-           str << " epoch='" << numstring(cap.edition().epoch()) << "'";
-    } else {
-       // anything else
-       str << "<dep name='" << xml_escape(cap.asString()) << "'";
+    if (isKind<VersionedCap>(cap))
+    {
+      VersionedCap::constPtr vercap = asKind<VersionedCap>(cap);
+      if (
+          vercap->op() != Rel::NONE
+          && vercap->op() != Rel::ANY
+          && !vercap->edition().version().empty() ) {
+          // version capability
+          str << "<dep name='" << xml_escape(vercap->index()) << "' op='" << xml_escape(vercap->op().asString()) <<
+              "' version='" << vercap->edition().version() << "'";
+          if (!vercap->edition().release().empty())
+              str << " release='" << vercap->edition().release() << "'";
+          if (vercap->edition().epoch() != Edition::noepoch)
+              str << " epoch='" << numstring(vercap->edition().epoch()) << "'";
+      }
     }
+    else
+    {
+      str << "<dep name='" << xml_escape(cap.asString()) << "'";
+    }
+    
     str << " kind=\"" << toLower (cap.refers().asString()) << "\""
        << " />" << endl;
        
index b36c774..b50a4e4 100644 (file)
@@ -101,7 +101,7 @@ SET( zypp2_lib_SRCS
 ${zypp2_source_SRCS}
 ${zypp2_SRCS}
 ${zypp2_cache_SRCS}
-${zypp2_source_sqlite-source_SRCS}
+#${zypp2_source_sqlite-source_SRCS}
 ${zypp2_cache_sqlite3x_SRCS}
 )
 
@@ -109,7 +109,7 @@ SET( zypp2_lib_HEADERS
 ${zypp2_source_HEADERS}
 ${zypp2_HEADERS}
 ${zypp2_cache_HEADERS}
-${zypp2_source_sqlite-source_HEADERS}
+#${zypp2_source_sqlite-source_HEADERS}
 ${zypp2_cache_sqlite3x_HEADERS}
 )