- added helper struct NVRA
authorMichael Andres <ma@suse.de>
Mon, 2 Jan 2006 17:15:29 +0000 (17:15 +0000)
committerMichael Andres <ma@suse.de>
Mon, 2 Jan 2006 17:15:29 +0000 (17:15 +0000)
- removed unneeded solver::context
- removed Capability::matches(). To be replaced by an Iterator
  visiting all matches in the pool.

devel/devel.ma/Makefile.am
devel/devel.ma/Parse.cc
devel/genclass.in
zypp/Capability.cc
zypp/Capability.h
zypp/Makefile.am
zypp/NVRA.cc [moved from zypp/solver/SolverFwd.h with 70% similarity]
zypp/NVRA.h [moved from zypp/solver/Context.cc with 52% similarity]
zypp/capability/CapabilityImpl.h
zypp/solver/Context.h [deleted file]
zypp/solver/Makefile.am

index b6cd68f..4cd9389 100644 (file)
@@ -16,7 +16,7 @@ LDADD =               $(top_srcdir)/zypp/lib@PACKAGE@.la -lboost_regex
 
 ## ##################################################
 
-Main_SOURCES =                 Main.cc
+Main_SOURCES =                 Main.cc Packages.cc
 
 Main_debug_SOURCES =   $(Main_SOURCES)
 Main_debug_LDFLAGS =   -static
index 56e373c..82159b4 100644 (file)
@@ -8,6 +8,8 @@
 #include <zypp/base/PtrTypes.h>
 #include <zypp/parser/tagfile/Tags.h>
 
+#include <zypp/NVRA.h>
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -34,6 +36,10 @@ namespace zypp
       {
         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 );
@@ -79,6 +85,88 @@ 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;
+};
+
+struct X
+{
+  template <typename Item>
+    struct result
+    {
+      typedef rule_t type;
+    };
+
+  template <typename Item>
+    rule_t operator<<(  const Item & stag_r ) const
+    {
+      return eps_p;//error_report_p( "neither empty nor comment" );
+    }
+};
+//const phoenix::function<X_impl> XX = X_impl();
+
+////////////////////////////////////////////////////////////////////////////
 //
 //  Main
 //
@@ -110,16 +198,22 @@ int main( int argc, char* argv[] )
   STag      stagData;
   MTag      mtagData;
 
+  PConsume  consume;
+  rule_t c = eps_p;
+  rule_t a = nothing_p;
+  rule_t x = error_report_p( "abort" );
+
   rule_t file =   end_p
-                | ( stag
-                  | mtag
+                | ( stag //[var(consume)=arg1]
+                    >> lazy_p(var(x))
+                  | mtag [var(consume)=arg1]
                   | ( *blank_p
                       >> !( ch_p('#')
                             >> *(anychar_p - eol_p)
                           )
                       >> (eol_p|end_p)
-                    | error_report_p( "neither empty nor comment" )
                     )
+                  | error_report_p( "neither empty nor comment" )
                   )
                   >> file;
 
index e46288e..2cf8229 100644 (file)
@@ -113,6 +113,7 @@ ${INDENT}/** */
 ${INDENT}class ${CLASS}
 ${INDENT}{
 ${INDENT}  friend std::ostream & operator<<( std::ostream & str, const ${CLASS} & obj );
+
 ${INDENT}public:
 ${INDENT}  /** Implementation  */
 ${INDENT}  class Impl;
index ba7f7a7..cb45bea 100644 (file)
@@ -53,15 +53,7 @@ namespace zypp
   std::string Capability::asString() const
   { return _pimpl->asString(); }
 
-  bool Capability::matches( Resolvable::constPtr resolvable_r,
-                            solver::Context_constPtr solverContext_r ) const
-  { return _pimpl->matches( resolvable_r, solverContext_r ); }
 
-  bool Capability::matches( Resolvable::constPtr resolvable_r ) const
-  {
-    // NULL: actually a default context needed
-    return _pimpl->matches( resolvable_r, NULL );
-  }
 
   /******************************************************************
   **
index b40a2d1..91f81cf 100644 (file)
@@ -18,7 +18,6 @@
 #include "zypp/base/PtrTypes.h"
 
 #include "zypp/Resolvable.h"
-#include "zypp/solver/SolverFwd.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -105,11 +104,7 @@ namespace zypp
     std::string asString() const;
 
     /** */
-    bool matches( Resolvable::constPtr resolvable_r,
-                  solver::Context_constPtr solverContext_r ) const;
 
-    /**  \todo this does not make sense until ther's a default context available*/
-    bool matches( Resolvable::constPtr resolvable_r ) const;
 
   private:
     /** Pointer to implementation */
index 5fc1e08..7c7f2a6 100644 (file)
@@ -17,6 +17,7 @@ include_HEADERS = NeedAType.h \
        Edition.h       \
        LanguageCode.h  \
        Locale.h        \
+       NVRA.h          \
        Rel.h           \
        ResObject.h     \
        Resolvable.h    \
@@ -56,6 +57,7 @@ lib@PACKAGE@_la_SOURCES = \
        Edition.cc      \
        LanguageCode.cc \
        Locale.cc       \
+       NVRA.cc         \
        Rel.cc          \
        ResObject.cc    \
        Resolvable.cc   \
similarity index 70%
rename from zypp/solver/SolverFwd.h
rename to zypp/NVRA.cc
index 976f4b5..96d7e84 100644 (file)
@@ -6,27 +6,36 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file      zypp/solver/SolverFwd.h
- *
- * Forward declaration of Solver related public types.
+/** \file      zypp/NVRA.cc
  *
 */
-#ifndef ZYPP_SOLVER_SOLVERFWD_H
-#define ZYPP_SOLVER_SOLVERFWD_H
+#include <iostream>
+//#include "zypp/base/Logger.h"
+
+#include "zypp/NVRA.h"
+
+using std::endl;
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : NVRA
+  //
   ///////////////////////////////////////////////////////////////////
-  namespace solver
-  { /////////////////////////////////////////////////////////////////
 
-    DEFINE_PTR_TYPE(Context);
+  /******************************************************************
+  **
+  **   FUNCTION NAME : operator<<
+  **   FUNCTION TYPE : std::ostream &
+  */
+  std::ostream & operator<<( std::ostream & str, const NVRA & obj )
+  {
+    return str << obj.name << '-' << obj.edition << '.' << obj.arch;
+  }
 
-    /////////////////////////////////////////////////////////////////
-  } // namespace solver
-  ///////////////////////////////////////////////////////////////////
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOLVER_SOLVERFWD_H
similarity index 52%
rename from zypp/solver/Context.cc
rename to zypp/NVRA.h
index 846ea3b..f84b9a3 100644 (file)
@@ -6,55 +6,57 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file      zypp/solver/Context.cc
+/** \file      zypp/NVRA.h
  *
 */
-#include <iostream>
+#ifndef ZYPP_NVRA_H
+#define ZYPP_NVRA_H
 
-#include "zypp/base/Logger.h"
+#include <iosfwd>
+#include <string>
 
-#include "zypp/solver/Context.h"
-
-using namespace std;
+#include "zypp/base/PtrTypes.h"
+#include "zypp/Edition.h"
+#include "zypp/Arch.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////
-  namespace solver
-  { /////////////////////////////////////////////////////////////////
 
-    IMPL_PTR_TYPE(Context);
-
-    ///////////////////////////////////////////////////////////////////
-    //
-    // METHOD NAME : Context::Context
-    // METHOD TYPE : Ctor
-    //
-    Context::Context()
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : NVRA
+  //
+  /** */
+  struct NVRA
+  {
+    /** Default ctor */
+    NVRA()
     {}
 
-    ///////////////////////////////////////////////////////////////////
-    //
-    // METHOD NAME : Context::~Context
-    // METHOD TYPE : Dtor
-    //
-    Context::~Context()
+    /** Ctor */
+    explicit
+    NVRA( const std::string & name_r,
+          const Edition & edition_r = Edition(),
+          const Arch & arch_r = Arch() )
+    : name( name_r )
+    , edition( edition_r )
+    , arch( arch_r )
     {}
 
-    /******************************************************************
-     **
-     **        FUNCTION NAME : operator<<
-     **        FUNCTION TYPE : std::ostream &
-    */
-    std::ostream & operator<<( std::ostream & str, const Context & obj )
-    {
-      return str;
-    }
-
-  /////////////////////////////////////////////////////////////////
-  } // namespace solver
+    /**  */
+    std::string name;
+    /**  */
+    Edition edition;
+    /**  */
+    Arch arch;
+  };
   ///////////////////////////////////////////////////////////////////
+
+  /** \relates NVRA Stream output */
+  std::ostream & operator<<( std::ostream & str, const NVRA & obj );
+
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
+#endif // ZYPP_NVRA_H
index a7c0e0e..b376785 100644 (file)
@@ -17,7 +17,6 @@
 #include "zypp/base/KindOf.h"
 
 #include "zypp/Resolvable.h" // maybe ResTraits are sufficient?
-#include "zypp/solver/SolverFwd.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -27,6 +26,12 @@ namespace zypp
   { /////////////////////////////////////////////////////////////////
     DEFINE_PTR_TYPE(CapabilityImpl)
 
+    namespace solver
+    {
+      typedef void * Context_constPtr;
+    }
+
+
     ///////////////////////////////////////////////////////////////////
     //
     // CLASS NAME : CapabilityImpl
diff --git a/zypp/solver/Context.h b/zypp/solver/Context.h
deleted file mode 100644 (file)
index 3912c7e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/solver/Context.h
- *
-*/
-#ifndef ZYPP_SOLVER_CONTEXT_H
-#define ZYPP_SOLVER_CONTEXT_H
-
-#include <iosfwd>
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/base/PtrTypes.h"
-
-#include "zypp/solver/SolverFwd.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////
-  namespace solver
-  { /////////////////////////////////////////////////////////////////
-
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : Context
-    //
-    /** Solver context.
-    */
-    class Context : public base::ReferenceCounted, private base::NonCopyable
-    {
-    public:
-      typedef Context            Self;
-      typedef Context_Ptr        Ptr;
-      typedef Context_constPtr   constPtr;
-      friend std::ostream & operator<<( std::ostream & str, const Context & obj );
-
-    public:
-      /** Default ctor */
-      Context();
-      /** Dtor */
-      ~Context();
-    };
-    ///////////////////////////////////////////////////////////////////
-
-    /** \relates Context Stream output */
-    extern std::ostream & operator<<( std::ostream & str, const Context & obj );
-
-    /////////////////////////////////////////////////////////////////
-  } // namespace solver
-  ///////////////////////////////////////////////////////////////////
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOLVER_CONTEXT_H
index 19a2100..263f7ed 100644 (file)
@@ -6,15 +6,12 @@ SUBDIRS =
 
 ## ##################################################
 
-include_HEADERS = \
-       SolverFwd.h     \
-       Context.h
+include_HEADERS =
 
 noinst_LTLIBRARIES =   lib@PACKAGE@_solver.la
 
 ## ##################################################
 
-lib@PACKAGE@_solver_la_SOURCES = \
-       Context.cc
+lib@PACKAGE@_solver_la_SOURCES =
 
 ## ##################################################