- Added helper struct NVR (name,edition(version,relase))
authorMichael Andres <ma@suse.de>
Mon, 9 Jan 2006 22:41:18 +0000 (22:41 +0000)
committerMichael Andres <ma@suse.de>
Mon, 9 Jan 2006 22:41:18 +0000 (22:41 +0000)
  and NVRAD(name,edition,arch,dependencies).
- Resolvable construction now supports NVRAD. Manipulation of
  Dependencies after construction via the Resolvables public
  interface is deprecated. To be fixed in RpmDb and YUMParser.

29 files changed:
devel/devel.ma/Parse.cc
zypp/Capability.h
zypp/Dependencies.cc
zypp/Edition.cc
zypp/Makefile.am
zypp/Message.cc
zypp/Message.h
zypp/NVR.cc [new file with mode: 0644]
zypp/NVR.h [new file with mode: 0644]
zypp/NVRA.h
zypp/NVRAD.cc [new file with mode: 0644]
zypp/NVRAD.h [new file with mode: 0644]
zypp/Package.cc
zypp/Package.h
zypp/Patch.cc
zypp/Patch.h
zypp/Product.cc
zypp/Product.h
zypp/ResObject.cc
zypp/ResObject.h
zypp/Resolvable.cc
zypp/Resolvable.h
zypp/Script.cc
zypp/Script.h
zypp/Selection.cc
zypp/Selection.h
zypp/detail/ResObjectFactory.h
zypp/detail/ResolvableImpl.h
zypp/solver/temporary/ResItem.h

index 69ef321..25803e4 100644 (file)
@@ -1,15 +1,25 @@
 //http://www.boost.org/libs/libraries.htm
 #include <iostream>
 #include <list>
+#include <vector>
 #include <string>
+#include <iterator>
 
 #include <zypp/base/Logger.h>
 #include <zypp/base/Exception.h>
+#include <zypp/base/String.h>
 #include <zypp/base/PtrTypes.h>
-#include <zypp/parser/tagfile/Tags.h>
+
+#include <zypp/parser/tagfile/Parser.h>
+#include <zypp/Package.h>
+#include <zypp/CapSet.h>
+#include <zypp/CapFactory.h>
+#include <zypp/detail/PackageImpl.h>
 
 #include <zypp/NVRA.h>
 
+using std::endl;
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -20,61 +30,89 @@ namespace zypp
     namespace tagfile
     { /////////////////////////////////////////////////////////////////
 
-      void echoOn( std::ostream & str,
-                   iterator_t first, const iterator_t last,
-                   const char* s = "" )
-      {
-        //return;
-        str << first.get_position() << last.get_position();
-        str << s << ">>";
-        while ( first != last )
-          str << *first++;
-        str << "<< " << std::endl;
-      }
 
-      void echo( iterator_t first, const iterator_t last, const char* s = "" )
+      struct PackagesParser : public Parser
       {
-        echoOn( DBG, first, last, s );
-      }
-      void xecho( const char * first, const char *const last, const char* s = "" )
-      {
-        DBG << ">>" << std::string(first,last) << "<< " << std::endl;
-      }
-      void mecho( iterator_t first, const iterator_t last, const char* s = "" )
-      {
-        echoOn( MIL, first, last, s );
-      }
-
-      ////////////////////////////////////////////////////////////////////////////
-      //
-      //  SingleTag Grammar
-      //
-      ////////////////////////////////////////////////////////////////////////////
-
-
-      struct Merror_report_parser
-      {
-        Merror_report_parser( const char * msg_r )
-        : msg( msg_r )
-        {}
-
-        typedef spirit::nil_t result_t;
-
-        template <typename ScannerT>
-          int operator()( const ScannerT & scan, result_t & /*result*/ ) const
-          {
-            SEC << scan.first.get_position() << ' ' << msg << std::endl;
-            return -1; // Fail.
-          }
-
-        const char * msg;
+        std::list<Package::Ptr> result;
+
+        shared_ptr<detail::PackageImpl> pkgImpl;
+
+        Package::Ptr pkg;
+        Dependencies deps;
+
+        void collectPkg()
+        {
+          if ( pkg )
+            {
+              pkg->setDeps( deps );
+              result.push_back( pkg );
+              // reset
+              deps = Dependencies();
+            }
+        }
+
+        void collectDeps( const std::list<std::string> & depstr_r,
+                          std::insert_iterator<CapSet> result_r )
+        {
+          Capability c( CapFactory().parse( ResTraits<Package>::kind, "" ) );
+          INT << c << endl;
+          *result_r++ = c;
+        }
+
+        CapSet collectDeps( const std::list<std::string> & depstr_r )
+        {
+          return CapSet();
+        }
+
+        /* Overload to consume SingleTag data. */
+        virtual void consume( const STag & stag_r )
+        {
+          if ( stag_r.stag.isPlain( "Pkg" ) )
+            {
+              collectPkg();
+
+              std::vector<std::string> words;
+              str::split( stag_r.value, std::back_inserter(words) );
+
+              if ( str::split( stag_r.value, std::back_inserter(words) ) != 4 )
+                ZYPP_THROW( ParseException( "Pkg" ) );
+
+              pkg = detail::makeResolvableAndImpl( words[0],
+                                                   Edition(words[1],words[2]),
+                                                   Arch(words[4]),
+                                                   pkgImpl );
+            }
+          //MIL << stag_r << endl;
+        }
+        /* Overload to consume MulitTag data. */
+        virtual void consume( const MTag & mtag_r )
+        {
+          if ( mtag_r.stag.isPlain( "Prv" ) )
+            {
+              CapSet cs;
+              collectDeps( mtag_r.value, std::inserter(cs,cs.end()) );
+              INT << cs.size() << endl;
+              deps.setProvides( cs );
+            }
+          else if ( mtag_r.stag.isPlain( "Prq" ) )
+            {
+              deps.setPrerequires( collectDeps( mtag_r.value ) );
+            }
+          else if ( mtag_r.stag.isPlain( "Req" ) )
+            {
+              deps.setRequires( collectDeps( mtag_r.value ) );
+            }
+          else if ( mtag_r.stag.isPlain( "Con" ) )
+            {
+              deps.setConflicts( collectDeps( mtag_r.value ) );
+            }
+          else if ( mtag_r.stag.isPlain( "Obs" ) )
+            {
+              deps.setObsoletes( collectDeps( mtag_r.value ) );
+            }
+        }
       };
 
-      typedef functor_parser<Merror_report_parser> Merror_report_p;
-
-
-
-
       /////////////////////////////////////////////////////////////////
     } // namespace tagfile
     ///////////////////////////////////////////////////////////////////
@@ -89,13 +127,11 @@ namespace zypp
 //  Types
 //
 ////////////////////////////////////////////////////////////////////////////
+
 using std::endl;
-using std::list;
-using std::string;
 using namespace zypp;
 using namespace zypp::parser::tagfile;
-typedef scanner<iterator_t>            scanner_t;
-typedef rule<scanner_t>                rule_t;
+
 ////////////////////////////////////////////////////////////////////////////
 //
 //  Just for the stats
@@ -116,71 +152,8 @@ struct Measure
 };
 ////////////////////////////////////////////////////////////////////////////
 
-NVRA parseNVRA( const std::string & value )
-{
-  std::string n;
-  std::string v;
-  std::string r;
-  std::string a;
-
-  parse_info<> info = parse( value.c_str(),
-
-       lexeme_d[(+~space_p)]                    [assign_a(n)]
-       >> lexeme_d[(+(~space_p & ~ch_p('-')))]  [assign_a(v)]
-       >> lexeme_d[(+(~space_p & ~ch_p('-')))]  [assign_a(r)]
-       >> lexeme_d[(+~space_p)]                 [assign_a(a)]
-       ,
-                             space_p );
-
-  NVRA data;
-  if ( info.full )
-    {
-      data = NVRA( n, Edition(v,r), Arch(a) );
-    }
-  else
-    {
-      ERR << "parseNVRA failed on " << value << std::endl;
-    }
-  INT << data << endl;
-  return data;
-}
-
-
-struct PConsume
-{
-  static bool isTag( const Tag & tag_r, const std::string & ident_r )
-  {
-    return tag_r.ident == ident_r && tag_r.ext.empty();
-  }
-  static bool isLangTag( const Tag & tag_r, const std::string & ident_r )
-  {
-    return tag_r.ident == ident_r && ! tag_r.ext.empty();
-  }
-
-  bool newPkg( const std::string & value )
-  {
-    NVRA data( parseNVRA( value ) );
-    return true;
-  }
-
-
-  PConsume & operator=( const STag & stag_r )
-  {
-    if ( isTag( stag_r.stag, "Pkg" ) )
-      {
-        newPkg( stag_r.value );
-        MIL << stag_r << endl;
-      }
-    return *this;
-  }
-  PConsume & operator=( const MTag & mtag_r )
-  {
-    return *this;
-  }
-
-  scoped_ptr<NVRA> _nvra;
-};
 
+using namespace std;
 ////////////////////////////////////////////////////////////////////////////
 //
 //  Main
@@ -193,76 +166,12 @@ int main( int argc, char* argv[] )
   if (argc >= 2 )
     infile = argv[1];
 
-  // Create a file iterator for this file
-  fiterator_t first(infile);
-  if (!first)
-    {
-      ERR << "Unable to open file!\n";
-      return -1;
-    }
-  // Create an EOF iterator
-  fiterator_t last = first.make_end();
-
-  // Create position iterators
-  iterator_t begin( first, last, infile );
-  iterator_t end;
-
-  // Result var
-  SingleTag stag;
-  MultiTag  mtag;
-  STag      stagData;
-  MTag      mtagData;
-
-  PConsume  consume;
-
-#if 1
-  rule_t file =   end_p
-                | ( stag [var(consume)=arg1]
-                  | mtag [var(consume)=arg1]
-                  | ( *blank_p
-                      >> !( ch_p('#')
-                            >> *(anychar_p - eol_p)
-                          )
-                      >> (eol_p|end_p)
-                    )
-                    | error_report_p( "illegal line" )
-                  )
-                  >> file
-                  ;
-#else
-  rule_t file =
-            end_p
-          | (+~space_p) [&echo]
-            >> ( lazy_p(var(skip))
-               | Merror_report_p( "lazy failed" )
-               )
-            >> file
-          ;
-#endif
-
-  // Parse
-  shared_ptr<Measure> duration( new Measure );
-  parse_info<iterator_t> info
-    = parse( begin, end,
-
-             file
-
-           );
-  duration.reset();
+  PackagesParser p;
+  p.parse( infile );
 
-  // Check for fail...
-  if ( info.full )
-    USR << "Parse succeeded!\n";
-  else if ( info.hit )
-    {
-      ERR << "Parse partial!\n";
-      ERR << " at pos " << info.length << endl;
-    }
-  else
-    {
-      ERR << "Parse failed!\n";
-      ERR << " at pos " << info.length << endl;
-    }
+  SEC << p.result.size() << endl;
+  MIL << *p.result.front() << endl;
+  MIL << p.result.front()->deps() << endl;
 
   INT << "===[END]============================================" << endl;
   return 0;
index bd5a844..4316d43 100644 (file)
@@ -32,7 +32,6 @@ namespace zypp
   ///////////////////////////////////////////////////////////////////
 
   class CapFactory;
-  struct CapMatchContext {};
 
   ///////////////////////////////////////////////////////////////////
   //
index 8234cdf..ccc17e8 100644 (file)
@@ -65,15 +65,24 @@ namespace zypp
   /** \relates DependenciesImpl Stream output */
   inline std::ostream & operator<<( std::ostream & str, const Dependencies::Impl & obj )
   {
-    str << "PROVIDES:"    << endl << obj._provides;
-    str << "PREREQUIRES:" << endl << obj._prerequires;
-    str << "REQUIRES:"    << endl << obj._requires;
-    str << "CONFLICTS:"   << endl << obj._conflicts;
-    str << "OBSOLETES:"   << endl << obj._obsoletes;
-    str << "RECOMMENDS:"  << endl << obj._recommends;
-    str << "SUGGESTS:"    << endl << obj._suggests;
-    str << "FRESHENS:"    << endl << obj._freshens;
-    return str;
+    str << "Dependencies: [" << endl;
+    if ( ! obj._provides.empty() )
+      str << "PROVIDES:" << endl << obj._provides;
+    if ( ! obj._prerequires.empty() )
+      str << "PREREQUIRES:" << endl << obj._prerequires;
+    if ( ! obj._requires.empty() )
+      str << "REQUIRES:" << endl << obj._requires;
+    if ( ! obj._conflicts.empty() )
+      str << "CONFLICTS:" << endl << obj._conflicts;
+    if ( ! obj._obsoletes.empty() )
+      str << "OBSOLETES:" << endl << obj._obsoletes;
+    if ( ! obj._recommends.empty() )
+      str << "RECOMMENDS:" << endl << obj._recommends;
+    if ( ! obj._suggests.empty() )
+      str << "SUGGESTS:" << endl << obj._suggests;
+    if ( ! obj._freshens.empty() )
+      str << "FRESHENS:" << endl << obj._freshens;
+    return str << "]";
   }
   ///////////////////////////////////////////////////////////////////
 
index e252367..7aa7991 100644 (file)
@@ -269,6 +269,7 @@ namespace zypp
   {
     string ret;
 
+#warning RE-fix asString and supress epoch
 //    if ( _pimpl->_epoch )
       ret += str::form(  "%d:", _pimpl->_epoch );
 
index 51e8373..d0d77a6 100644 (file)
@@ -18,7 +18,9 @@ include_HEADERS = NeedAType.h \
        Edition.h       \
        LanguageCode.h  \
        Locale.h        \
+       NVR.h           \
        NVRA.h          \
+       NVRAD.h         \
        Rel.h           \
        ResObject.h     \
        Resolvable.h    \
@@ -59,7 +61,9 @@ lib@PACKAGE@_la_SOURCES = \
        Edition.cc      \
        LanguageCode.cc \
        Locale.cc       \
+       NVR.cc          \
        NVRA.cc         \
+       NVRAD.cc        \
        Rel.cc          \
        ResObject.cc    \
        Resolvable.cc   \
index b7c1400..0bbe29d 100644 (file)
@@ -22,10 +22,8 @@ namespace zypp
   //   METHOD NAME : Message::Message
   //   METHOD TYPE : Ctor
   //
-  Message::Message( const std::string & name_r,
-                    const Edition & edition_r,
-                    const Arch & arch_r )
-  : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+  Message::Message( const NVRAD & nvrad_r )
+  : ResObject( TraitsType::kind, nvrad_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 231acf8..104d9fa 100644 (file)
@@ -41,10 +41,7 @@ namespace zypp
     std::string type();
 
   protected:
-    /** Ctor */
-    Message( const std::string & name_r,
-             const Edition & edition_r,
-             const Arch & arch_r );
+    Message( const NVRAD & nvrad_r );
     /** Dtor */
     virtual ~Message();
 
diff --git a/zypp/NVR.cc b/zypp/NVR.cc
new file mode 100644 (file)
index 0000000..bb6daf5
--- /dev/null
@@ -0,0 +1,32 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/NVR.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/NVR.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  /******************************************************************
+  **
+  **   FUNCTION NAME : operator<<
+  **   FUNCTION TYPE : std::ostream &
+  */
+  std::ostream & operator<<( std::ostream & str, const NVR & obj )
+  {
+    return str << obj.name << '-' << obj.edition;
+  }
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/NVR.h b/zypp/NVR.h
new file mode 100644 (file)
index 0000000..0c7ef27
--- /dev/null
@@ -0,0 +1,56 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/NVR.h
+ *
+*/
+#ifndef ZYPP_NVR_H
+#define ZYPP_NVR_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/Edition.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : NVR
+  //
+  /** Helper storing Name and Edition. */
+  struct NVR
+  {
+    /** Default ctor */
+    NVR()
+    {}
+
+    /** Ctor */
+    explicit
+    NVR( const std::string & name_r,
+         const Edition & edition_r = Edition() )
+    : name( name_r )
+    , edition( edition_r )
+    {}
+
+    /**  */
+    std::string name;
+    /**  */
+    Edition edition;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /** \relates NVR Stream output */
+  std::ostream & operator<<( std::ostream & str, const NVR & obj );
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_NVR_H
index f84b9a3..9f7fd12 100644 (file)
 #define ZYPP_NVRA_H
 
 #include <iosfwd>
-#include <string>
 
-#include "zypp/base/PtrTypes.h"
-#include "zypp/Edition.h"
+#include "zypp/NVR.h"
 #include "zypp/Arch.h"
 
 ///////////////////////////////////////////////////////////////////
@@ -27,8 +25,8 @@ namespace zypp
   //
   //   CLASS NAME : NVRA
   //
-  /** */
-  struct NVRA
+  /**  Helper storing Name, Edition and Arch. */
+  struct NVRA : public NVR
   {
     /** Default ctor */
     NVRA()
@@ -39,15 +37,18 @@ namespace zypp
     NVRA( const std::string & name_r,
           const Edition & edition_r = Edition(),
           const Arch & arch_r = Arch() )
-    : name( name_r )
-    , edition( edition_r )
+    : NVR( name_r, edition_r )
+    , arch( arch_r )
+    {}
+
+    /** Ctor */
+    explicit
+    NVRA( const NVR & nvr_r,
+          const Arch & arch_r = Arch() )
+    : NVR( nvr_r )
     , arch( arch_r )
     {}
 
-    /**  */
-    std::string name;
-    /**  */
-    Edition edition;
     /**  */
     Arch arch;
   };
diff --git a/zypp/NVRAD.cc b/zypp/NVRAD.cc
new file mode 100644 (file)
index 0000000..1506e63
--- /dev/null
@@ -0,0 +1,21 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/NVRAD.cc
+ *
+*/
+
+#include "zypp/NVRAD.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/NVRAD.h b/zypp/NVRAD.h
new file mode 100644 (file)
index 0000000..715ab30
--- /dev/null
@@ -0,0 +1,68 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/NVRAD.h
+ *
+*/
+#ifndef ZYPP_NVRAD_H
+#define ZYPP_NVRAD_H
+
+#include "zypp/NVRA.h"
+#include "zypp/Dependencies.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : NVRAD
+  //
+  /**  Helper storing Name, Edition, Arch and Dependencies. */
+  struct NVRAD : public NVRA
+  {
+    /** Default ctor */
+    NVRAD()
+    {}
+
+    /** Ctor */
+    explicit
+    NVRAD( const std::string & name_r,
+           const Edition & edition_r = Edition(),
+           const Arch & arch_r = Arch(),
+           const Dependencies & deps_r = Dependencies() )
+    : NVRA( name_r, edition_r, arch_r )
+    , deps( deps_r )
+    {}
+
+    /** Ctor */
+    explicit
+    NVRAD( const NVRA & nvra_r,
+           const Dependencies & deps_r = Dependencies() )
+    : NVRA( nvra_r )
+    , deps( deps_r )
+    {}
+
+    /** Ctor */
+    explicit
+    NVRAD( const NVR & nvr_r,
+           const Arch & arch_r = Arch(),
+           const Dependencies & deps_r = Dependencies() )
+    : NVRA( nvr_r, arch_r )
+    , deps( deps_r )
+    {}
+
+    /**  */
+    Dependencies deps;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_NVRAD_H
index 979cbf3..acbe142 100644 (file)
@@ -22,10 +22,8 @@ namespace zypp
   //   METHOD NAME : Package::Package
   //   METHOD TYPE : Ctor
   //
-  Package::Package( const std::string & name_r,
-                    const Edition & edition_r,
-                    const Arch & arch_r )
-  : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+  Package::Package( const NVRAD & nvrad_r )
+  : ResObject( TraitsType::kind, nvrad_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index b35b1a1..232cce7 100644 (file)
@@ -43,10 +43,7 @@ namespace zypp
     // data here:
 
   protected:
-    /** Ctor */
-    Package( const std::string & name_r,
-             const Edition & edition_r,
-             const Arch & arch_r );
+    Package( const NVRAD & nvrad_r );
     /** Dtor */
     virtual ~Package();
 
index 3b2c092..8d6fa41 100644 (file)
@@ -22,10 +22,8 @@ namespace zypp
   //   METHOD NAME : Patch::Patch
   //   METHOD TYPE : Ctor
   //
-  Patch::Patch( const std::string & name_r,
-                const Edition & edition_r,
-                const Arch & arch_r )
-  : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+  Patch::Patch( const NVRAD & nvrad_r )
+  : ResObject( TraitsType::kind, nvrad_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 40d25f0..aabe1e8 100644 (file)
@@ -61,9 +61,7 @@ namespace zypp
 
   protected:
     /** Ctor */
-    Patch( const std::string & name_r,
-           const Edition & edition_r,
-           const Arch & arch_r );
+    Patch( const NVRAD & nvrad_r );
     /** Dtor */
     virtual ~Patch();
 
index a27fa87..ec39335 100644 (file)
@@ -24,10 +24,8 @@ namespace zypp
   //   METHOD NAME : Product::Product
   //   METHOD TYPE : Ctor
   //
-  Product::Product( const std::string & name_r,
-                    const Edition & edition_r,
-                    const Arch & arch_r )
-  : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+  Product::Product( const NVRAD & nvrad_r )
+  : ResObject( TraitsType::kind, nvrad_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 93d73e0..8069b0a 100644 (file)
@@ -40,9 +40,7 @@ namespace zypp
 
   protected:
     /** Ctor */
-    Product( const std::string & name_r,
-             const Edition & edition_r,
-             const Arch & arch_r );
+    Product( const NVRAD & nvrad_r );
     /** Dtor */
     virtual ~Product();
 
index eea62c9..9106958 100644 (file)
@@ -23,10 +23,8 @@ namespace zypp
   //   METHOD TYPE : Ctor
   //
   ResObject::ResObject( const Kind & kind_r,
-                        const std::string & name_r,
-                        const Edition & edition_r,
-                        const Arch & arch_r )
-  : Resolvable( kind_r, name_r, edition_r, arch_r )
+                        const NVRAD & nvrad_r )
+  : Resolvable( kind_r, nvrad_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 7d81b71..878375e 100644 (file)
@@ -43,9 +43,7 @@ namespace zypp
   protected:
     /** Ctor */
     ResObject( const Kind & kind_r,
-               const std::string & name_r,
-               const Edition & edition_r,
-               const Arch & arch_r );
+               const NVRAD & nvrad_r );
     /** Dtor */
     virtual ~ResObject();
 
index 113f648..823bbd3 100644 (file)
@@ -26,10 +26,8 @@ namespace zypp
   //   METHOD TYPE : Ctor
   //
   Resolvable::Resolvable( const Kind & kind_r,
-                          const std::string & name_r,
-                          const Edition & edition_r,
-                          const Arch & arch_r )
-  : _pimpl( new Impl( kind_r, name_r, edition_r, arch_r ) )
+                          const NVRAD & nvrad_r )
+  : _pimpl( new Impl( kind_r, nvrad_r ) )
   {}
 
   ///////////////////////////////////////////////////////////////////
@@ -69,6 +67,31 @@ namespace zypp
   const Arch & Resolvable::arch() const
   { return _pimpl->arch(); }
 
+  const CapSet & Resolvable::provides() const
+  { return _pimpl->deps().provides(); }
+
+  const CapSet & Resolvable::prerequires() const
+  { return _pimpl->deps().prerequires(); }
+
+  const CapSet & Resolvable::requires() const
+  { return _pimpl->deps().requires(); }
+
+  const CapSet & Resolvable::conflicts() const
+  { return _pimpl->deps().conflicts(); }
+
+  const CapSet & Resolvable::obsoletes() const
+  { return _pimpl->deps().obsoletes(); }
+
+  const CapSet & Resolvable::recommends() const
+  { return _pimpl->deps().recommends(); }
+
+  const CapSet & Resolvable::suggests() const
+  { return _pimpl->deps().suggests(); }
+
+  const CapSet & Resolvable::freshens() const
+  { return _pimpl->deps().freshens(); }
+
+
   const Dependencies & Resolvable::deps() const
   { return _pimpl->deps(); }
 
index 369c4ef..fc54593 100644 (file)
 
 #include "zypp/Edition.h"
 #include "zypp/Arch.h"
+#include "zypp/CapSetFwd.h"
 #include "zypp/Dependencies.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
+  struct NVRAD;
+
   ///////////////////////////////////////////////////////////////////
   //
   //   CLASS NAME : Resolvable
@@ -52,6 +55,19 @@ namespace zypp
     const Edition & edition() const;
     /**  */
     const Arch & arch() const;
+
+    /** \name Dependencies. */
+    //@{
+    const CapSet & provides() const;
+    const CapSet & prerequires() const;
+    const CapSet & requires() const;
+    const CapSet & conflicts() const;
+    const CapSet & obsoletes() const;
+    const CapSet & recommends() const;
+    const CapSet & suggests() const;
+    const CapSet & freshens() const;
+    //@}
+
     /**  */
     const Dependencies & deps() const;
     /** */
@@ -60,9 +76,7 @@ namespace zypp
   protected:
     /** Ctor */
     Resolvable( const Kind & kind_r,
-                const std::string & name_r,
-                const Edition & edition_r,
-                const Arch & arch_r );
+                const NVRAD & nvrad_r );
     /** Dtor */
     virtual ~Resolvable();
     /** Helper for stream output */
index 489d90e..b0e9ed6 100644 (file)
@@ -22,10 +22,8 @@ namespace zypp
   //   METHOD NAME : Script::Script
   //   METHOD TYPE : Ctor
   //
-  Script::Script( const std::string & name_r,
-                  const Edition & edition_r,
-                  const Arch & arch_r )
-  : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+  Script::Script( const NVRAD & nvrad_r )
+  : ResObject( TraitsType::kind, nvrad_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 50b350d..aacd10a 100644 (file)
@@ -44,9 +44,7 @@ namespace zypp
 
   protected:
     /** Ctor */
-    Script( const std::string & name_r,
-            const Edition & edition_r,
-            const Arch & arch_r );
+    Script( const NVRAD & nvrad_r );
     /** Dtor */
     virtual ~Script();
 
index dcf2c76..fd4d101 100644 (file)
@@ -24,10 +24,8 @@ namespace zypp
   //   METHOD NAME : Selection::Selection
   //   METHOD TYPE : Ctor
   //
-  Selection::Selection( const std::string & name_r,
-                        const Edition & edition_r,
-                        const Arch & arch_r )
-  : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+  Selection::Selection( const NVRAD & nvrad_r )
+  : ResObject( TraitsType::kind, nvrad_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 733ba72..00fba3b 100644 (file)
@@ -40,9 +40,7 @@ namespace zypp
 
   protected:
     /** Ctor */
-    Selection( const std::string & name_r,
-               const Edition & edition_r,
-               const Arch & arch_r );
+    Selection( const NVRAD & nvrad_r );
     /** Dtor */
     virtual ~Selection();
 
index 12fa0be..f0beb70 100644 (file)
@@ -13,6 +13,7 @@
 #define ZYPP_DETAIL_RESOBJECTFACTORY_H
 
 #include "zypp/base/PtrTypes.h"
+#include "zypp/NVRAD.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -20,6 +21,7 @@ namespace zypp
 
   class Edition;
   class Arch;
+  struct NVRAD;
 
   ///////////////////////////////////////////////////////////////////
   namespace detail
@@ -28,6 +30,7 @@ namespace zypp
     namespace _resobjectfactory_detail
     { /////////////////////////////////////////////////////////////////
 
+      /** Glues a Resolvable to it's implementation. */
       template<class _Res>
         class ResImplConnect : public _Res
         {
@@ -39,16 +42,16 @@ namespace zypp
           // typedef intrusive_ptr<Self>       Ptr;
           // typedef intrusive_ptr<const Self> constPtr;
         public:
-          /** \todo protect against NULL Impl. */
-          ResImplConnect( const std::string & name_r,
-                          const Edition & edition_r,
-                          const Arch & arch_r,
+          /** Ctor */
+          ResImplConnect( const NVRAD & nvrad_r,
                           Impl_Ptr impl_r )
-          : _Res( name_r, edition_r, arch_r )
+          : _Res( nvrad_r )
           , _impl( impl_r )
           { _impl->_backRef = this; }
+
           virtual ~ResImplConnect()
           { _impl->_backRef = 0; }
+
         private:
           Impl_Ptr _impl;
           virtual Impl &       pimpl()       { return *_impl; }
@@ -61,22 +64,28 @@ namespace zypp
 
     template<class _Impl>
       typename _Impl::ResType::Ptr
-      makeResolvableAndImpl( const std::string & name_r,
-                             const Edition & edition_r,
-                             const Arch & arch_r,
+      makeResolvableAndImpl( const NVRAD & nvrad_r,
                              shared_ptr<_Impl> & impl_r )
       {
         impl_r.reset( new _Impl );
         return new
                _resobjectfactory_detail::ResImplConnect<typename _Impl::ResType>
-               ( name_r, edition_r, arch_r, impl_r );
+               ( nvrad_r, impl_r );
       }
 
     template<class _Impl>
       typename _Impl::ResType::Ptr
-      makeResolvableFromImpl( const std::string & name_r,
-                              const Edition & edition_r,
-                              const Arch & arch_r,
+      makeResolvableAndImpl( const std::string & name_r,
+                             const Edition & edition_r,
+                             const Arch & arch_r,
+                             shared_ptr<_Impl> & impl_r )
+      {
+        return makeResolvableAndImpl( NVRAD( name_r, edition_r, arch_r ), impl_r );
+      }
+
+    template<class _Impl>
+      typename _Impl::ResType::Ptr
+      makeResolvableFromImpl( const NVRAD & nvrad_r,
                               shared_ptr<_Impl> impl_r )
       {
         if ( ! impl_r )
@@ -85,7 +94,17 @@ namespace zypp
           throw ( "makeResolvableFromImpl: Impl already managed" );
         return new
                _resobjectfactory_detail::ResImplConnect<typename _Impl::ResType>
-               ( name_r, edition_r, arch_r, impl_r );
+               ( nvrad_r, impl_r );
+      }
+
+    template<class _Impl>
+      typename _Impl::ResType::Ptr
+      makeResolvableFromImpl( const std::string & name_r,
+                              const Edition & edition_r,
+                              const Arch & arch_r,
+                              shared_ptr<_Impl> impl_r )
+      {
+        return makeResolvableFromImpl( NVRAD( name_r, edition_r, arch_r ), impl_r );
       }
 
     /////////////////////////////////////////////////////////////////
index 7ad2708..317b478 100644 (file)
@@ -13,6 +13,7 @@
 #define ZYPP_DETAIL_RESOLVABLEIMPL_H
 
 #include "zypp/Resolvable.h"
+#include "zypp/NVRAD.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -29,31 +30,27 @@ namespace zypp
   {
     /** Ctor */
     Impl( const Kind & kind_r,
-          const std::string & name_r,
-          const Edition & edition_r,
-          const Arch & arch_r )
+          const NVRAD & nvrad_r )
     : _kind( kind_r )
-    , _name( name_r )
-    , _edition( edition_r )
-    , _arch( arch_r )
+    , _name( nvrad_r.name )
+    , _edition( nvrad_r.edition )
+    , _arch( nvrad_r.arch )
+    , _deps( nvrad_r.deps )
     {}
 
   public:
     /**  */
     const Kind & kind() const
     { return _kind; }
-      
     /**  */
     const std::string & name() const
     { return _name; }
-      
     /**  */
     const Edition & edition() const
     { return _edition; }
-
+    /**  */
     const Arch & arch() const
     { return _arch; }
-      
     /**  */
     const Dependencies & deps() const
     { return _deps; }
@@ -64,8 +61,6 @@ namespace zypp
     void setDeps( const Dependencies & val_r )
     { _deps = val_r; }
 
-      
-
   private:
     /**  */
     Kind _kind;
index 2a34750..38837a1 100644 (file)
@@ -68,7 +68,7 @@ namespace zypp
        **/
 
       class ResItem : public base::ReferenceCounted, private base::NonCopyable {
-          
+
 
         private:
           Channel_constPtr _channel;
@@ -129,13 +129,13 @@ namespace zypp
           size_t installedSize() const { return _installed_size; }
           void setInstalledSize (size_t installed_size) { _installed_size = installed_size; }
 
-          const CapSet & requires() const { return _resObject->deps().requires(); }
-          const CapSet & provides() const { return _resObject->deps().provides(); }
-          const CapSet & conflicts() const { return _resObject->deps().conflicts(); }
-          const CapSet & obsoletes() const { return _resObject->deps().obsoletes(); }
-          const CapSet & suggests() const { return _resObject->deps().suggests(); }
-          const CapSet & recommends() const { return _resObject->deps().recommends(); }
-          const CapSet & freshens() const { return _resObject->deps().freshens(); }
+          const CapSet & requires() const { return _resObject->requires(); }
+          const CapSet & provides() const { return _resObject->provides(); }
+          const CapSet & conflicts() const { return _resObject->conflicts(); }
+          const CapSet & obsoletes() const { return _resObject->obsoletes(); }
+          const CapSet & suggests() const { return _resObject->suggests(); }
+          const CapSet & recommends() const { return _resObject->recommends(); }
+          const CapSet & freshens() const { return _resObject->freshens(); }
 
           void setDependencies (const Dependencies & dependencies) { _resObject->setDeps(dependencies); }