Enabled use of ResTraits. Currently they define the
authorMichael Andres <ma@suse.de>
Thu, 17 Nov 2005 10:01:26 +0000 (10:01 +0000)
committerMichael Andres <ma@suse.de>
Thu, 17 Nov 2005 10:01:26 +0000 (10:01 +0000)
Resolvables ResKind() value.

15 files changed:
test/devel.ma/Main.cc
test/devel.ma/Makefile.am
zypp/Capability.cc
zypp/Capability.h
zypp/Message.cc
zypp/Package.cc
zypp/Patch.cc
zypp/Product.cc
zypp/Resolvable.h
zypp/ResolvableFwd.h [deleted file]
zypp/Script.cc
zypp/Selection.cc
zypp/capability/CapabilityImpl.h
zypp/capability/NamedCap.h
zypp/detail/ResObjectImplIf.h

index a22e5b1..7cfdece 100644 (file)
@@ -3,15 +3,14 @@
 #include <functional>
 #include <algorithm>
 #include <zypp/base/Logger.h>
-#include <zypp/base/PtrTypes.h>
-#include "main.h"
-//#include "main2.h"
+#include <zypp/Message.h>
+#include <zypp/Package.h>
 
 #define TAG INT << __PRETTY_FUNCTION__ << std::endl
 
 using namespace std;
 
-inline void OUT( Resolvable::constPtr p )
+inline void OUT( zypp::Resolvable::constPtr p )
 {
   if ( p )
     MIL << *p << endl;
@@ -19,23 +18,73 @@ inline void OUT( Resolvable::constPtr p )
     MIL << "NULL" << endl;
 }
 
-inline void OUT( Package::constPtr p )
+
+namespace zypp
 {
-  if ( p ) {
-    MIL << *p << ' ' << p->packagedata() << endl;
+  namespace detail {
+    ResObjectImplIf::~ResObjectImplIf()
+    {}
   }
-  else
-    MIL << "NULL" << endl;
-}
-inline void OUT( Package::Ptr p )
-{
-  OUT( Package::constPtr( p ) );
-}
 
 
-struct PI : public PackageImpl
+// connect resolvables interface and implementation.
+template<class _Res>
+  class ResImplConnect : public _Res
+  {
+  public:
+    typedef ResImplConnect                  Self;
+    typedef typename _Res::Impl             Impl;
+    typedef base::shared_ptr<Impl>          ImplPtr;
+    typedef base::intrusive_ptr<Self>       Ptr;
+    typedef base::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,
+                    ImplPtr impl_r )
+    : _Res( name_r, edition_r, arch_r )
+    , _impl( impl_r )
+    { _impl->_backRef = this; }
+    virtual ~ResImplConnect() {}
+  private:
+    ImplPtr _impl;
+    virtual Impl &       pimpl()       { return *_impl; }
+    virtual const Impl & pimpl() const { return *_impl; }
+  };
+
+
+template<class _Impl>
+  typename _Impl::ResType::Ptr
+  makeResolvable( const std::string & name_r,
+                  const Edition & edition_r,
+                  const Arch & arch_r,
+                  base::shared_ptr<_Impl> & impl_r )
+  {
+    impl_r.reset( new _Impl );
+    return new ResImplConnect<typename _Impl::ResType>( name_r,
+                                                        edition_r,
+                                                        arch_r,
+                                                        impl_r );
+  }
+template<class _Impl>
+  typename _Impl::ResType::Ptr
+  makeResolvable( base::shared_ptr<_Impl> & impl_r )
+  {
+    impl_r.reset( new _Impl );
+    return new ResImplConnect<typename _Impl::ResType>( "n",
+                                                        Edition("v","r"),
+                                                        Arch(),
+                                                        impl_r );
+  }
+
+}//ns
+
+struct PI : public zypp::detail::MessageImplIf
 {
-  virtual string packagedata() const { return "PI::packagedata"; }
+  virtual std::string text() const { return "message text"; }
+  virtual std::string type() const { return "message type"; }
+  virtual ~PI(){}
 };
 
 
@@ -51,6 +100,12 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
+  zypp::base::shared_ptr<PI> pi;
+  OUT( zypp::makeResolvable( pi ) );
+
+
+
+#if 0
   /* NVRA */
   zypp::base::shared_ptr<PI> pi;
   Package::Ptr p( makeResolvable( /*NVRA*/ pi ) );
@@ -58,6 +113,7 @@ int main( int argc, char * argv[] )
 
   p = makeResolvable( /*NVRA*/ pi );
   OUT( p );
+#endif
 
   INT << "===[END]============================================" << endl;
   return 0;
index d4291f8..45abf23 100644 (file)
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 ## ##################################################
 
-noinst_PROGRAMS =      Main Main.debug PtrTest Main2
+noinst_PROGRAMS =      Main Main.debug PtrTest
 
 ## ##################################################
 
@@ -15,8 +15,7 @@ LDADD =               $(top_srcdir)/zypp/lib@PACKAGE@.la
 
 ## ##################################################
 
-Main_SOURCES =                 Main.cc main.cc
-Main2_SOURCES =        main.cc Main.cc
+Main_SOURCES =                 Main.cc
 
 Main_debug_SOURCES =   $(Main_SOURCES)
 Main_debug_LDFLAGS =   -static
index ccf554f..2813488 100644 (file)
@@ -53,11 +53,11 @@ namespace zypp
   std::string Capability::asString() const
   { return _pimpl->asString(); }
 
-  bool Capability::matches( constResolvablePtr resolvable_r,
+  bool Capability::matches( Resolvable::constPtr resolvable_r,
                             const SolverContext & solverContext_r ) const
   { return _pimpl->matches( resolvable_r, solverContext_r ); }
 
-  bool Capability::matches( constResolvablePtr resolvable_r ) const
+  bool Capability::matches( Resolvable::constPtr resolvable_r ) const
   { return _pimpl->matches( resolvable_r, SolverContext() ); }
 
   /******************************************************************
index b6d2f49..8d1f92e 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "zypp/base/PtrTypes.h"
 
-#include "zypp/ResolvableFwd.h"
+#include "zypp/Resolvable.h"
 #include "zypp/SolverContextFwd.h"
 
 ///////////////////////////////////////////////////////////////////
@@ -66,10 +66,10 @@ namespace zypp
     /**  */
     std::string asString() const;
     /**  */
-    bool matches( constResolvablePtr resolvable_r,
+    bool matches( Resolvable::constPtr resolvable_r,
                   const SolverContext & colverContext_r ) const;
     /**  */
-    bool matches( constResolvablePtr resolvable_r ) const;
+    bool matches( Resolvable::constPtr resolvable_r ) const;
 
   private:
     /** Pointer to implementation */
index b35468d..c9aec36 100644 (file)
@@ -25,7 +25,7 @@ namespace zypp
   Message::Message( const std::string & name_r,
                     const Edition & edition_r,
                     const Arch & arch_r )
-  : ResObject( ResKind("Message"), name_r, edition_r, arch_r )
+  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index bcf77b9..1d298db 100644 (file)
@@ -25,7 +25,7 @@ namespace zypp
   Package::Package( const std::string & name_r,
                     const Edition & edition_r,
                     const Arch & arch_r )
-  : ResObject( ResKind("Package"), name_r, edition_r, arch_r )
+  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index a5561bb..71cc2e2 100644 (file)
@@ -25,7 +25,7 @@ namespace zypp
   Patch::Patch( const std::string & name_r,
                 const Edition & edition_r,
                 const Arch & arch_r )
-  : ResObject( ResKind("Patch"), name_r, edition_r, arch_r )
+  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 5eb0997..8cb18d2 100644 (file)
@@ -27,7 +27,7 @@ namespace zypp
   Product::Product( const std::string & name_r,
                     const Edition & edition_r,
                     const Arch & arch_r )
-  : ResObject( ResKind("Product"), name_r, edition_r, arch_r )
+  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 615ef73..39feb80 100644 (file)
@@ -17,7 +17,8 @@
 
 #include "zypp/base/ReferenceCounted.h"
 #include "zypp/base/NonCopyable.h"
-#include <zypp/base/PtrTypes.h>
+#include "zypp/base/PtrTypes.h"
+#include "zypp/ResTraits.h"
 
 #include "zypp/ResKind.h"
 #include "zypp/Edition.h"
@@ -76,6 +77,11 @@ namespace zypp
   };
   ///////////////////////////////////////////////////////////////////
 
+
+
+
+  ///////////////////////////////////////////////////////////////////
+
   /** Required by base::intrusive_ptr to add a reference. */
   inline void intrusive_ptr_add_ref( const Resolvable * ptr_r )
   { base::ReferenceCounted::add_ref( ptr_r ); }
diff --git a/zypp/ResolvableFwd.h b/zypp/ResolvableFwd.h
deleted file mode 100644 (file)
index e8cbbf4..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/ResolvableFwd.h
- *
-*/
-#ifndef ZYPP_RESOLVABLEFWD_H
-#define ZYPP_RESOLVABLEFWD_H
-
-#include "zypp/base/PtrTypes.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  class ResKind;
-  class Edition;
-  class Arch;
-  class Dependencies;
-
-  DEFINE_PTR_TYPE(Resolvable)
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_RESOLVABLEFWD_H
index 432f802..d8ead2c 100644 (file)
@@ -25,7 +25,7 @@ namespace zypp
   Script::Script( const std::string & name_r,
                   const Edition & edition_r,
                   const Arch & arch_r )
-  : ResObject( ResKind("Script"), name_r, edition_r, arch_r )
+  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 431e165..fb95c98 100644 (file)
@@ -27,7 +27,7 @@ namespace zypp
   Selection::Selection( const std::string & name_r,
                         const Edition & edition_r,
                         const Arch & arch_r )
-  : ResObject( ResKind("Selection"), name_r, edition_r, arch_r )
+  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 933944b..c9d3471 100644 (file)
@@ -15,7 +15,7 @@
 #include "zypp/base/ReferenceCounted.h"
 #include "zypp/base/NonCopyable.h"
 
-#include "zypp/ResolvableFwd.h"
+#include "zypp/Resolvable.h"
 #include "zypp/SolverContextFwd.h"
 #include "zypp/ResKind.h"
 
@@ -50,7 +50,7 @@ namespace zypp
       /**  */
       virtual std::string asString() const = 0;
       /**  */
-      virtual bool matches( constResolvablePtr resolvable_r,
+      virtual bool matches( Resolvable::constPtr resolvable_r,
                             const SolverContext & colverContext_r ) const = 0;
 
     private:
index 14f92f7..72c7c17 100644 (file)
@@ -42,7 +42,7 @@ namespace zypp
       virtual std::string asString() const
       { return _name; }
       /**  */
-      virtual bool matches( constResolvablePtr resolvable_r,
+      virtual bool matches( Resolvable::constPtr resolvable_r,
                             const SolverContext & colverContext_r ) const
       { return false; }
     private:
index f2fd97c..a55b713 100644 (file)
@@ -20,6 +20,8 @@ namespace zypp
 { /////////////////////////////////////////////////////////////////
 
   class Resolvable;
+  template<class _Res>
+    class ResImplConnect;
   typedef std::string            line;
   typedef std::list<std::string> text;