- YUMScriptImpl.cc Removed superfluous include of ResObjectFactory.h.
authorMichael Andres <ma@suse.de>
Tue, 29 Nov 2005 09:49:36 +0000 (09:49 +0000)
committerMichael Andres <ma@suse.de>
Tue, 29 Nov 2005 09:49:36 +0000 (09:49 +0000)
  Not just because it is available, but because it's not intended to
  be included directly. It's available via ResObjectImplIf.h, because
  the ResObjectFactory templates won't work, if there are not enough
  includes to instanciate the implementation class. If it can be
  instanciated, ResObjectImplIf.h is somehow included, and the
  Factory is available.

- Added Capability default ctor creating a dummy Capability.

devel/devel.ma/Main.cc
zypp/Capability.cc
zypp/Capability.h
zypp/capability/Makefile.am
zypp/capability/NullCap.cc [new file with mode: 0644]
zypp/capability/NullCap.h [new file with mode: 0644]
zypp/source/yum/YUMScriptImpl.cc

index 12e72ca..f265506 100644 (file)
@@ -9,6 +9,7 @@
 #include <zypp/Arch.h>
 #include <zypp/Edition.h>
 #include <zypp/Rel.h>
+#include <zypp/Capability.h>
 
 using namespace std;
 
@@ -44,15 +45,8 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  DBG << Edition() << endl;
-  DBG << Edition("") << endl;
-
-  DBG << Edition("-","","") << endl;
-
-  chk( "1.2.3-4.5.6" );
-  chk( "3:1.2.3-4.5.6" );
-
-  chk( "3:1.2.3-4.5.6-3" );
+  MIL << Capability() << Capability() << endl;
+  MIL << Capability() << Capability() << endl;
 
   INT << "===[END]============================================" << endl;
   return 0;
index f9f607b..4d5a409 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "zypp/Capability.h"
 #include "zypp/capability/CapabilityImpl.h"
+#include "zypp/capability/NullCap.h"
 
 #include "zypp/SolverContext.h"
 
@@ -27,6 +28,15 @@ namespace zypp
   //   METHOD NAME : Capability::Capability
   //   METHOD TYPE : Ctor
   //
+  Capability::Capability()
+  : _pimpl( capability::NullCap::instance() )
+  {}
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Capability::Capability
+  //   METHOD TYPE : Ctor
+  //
   Capability::Capability( Impl_Ptr impl_r )
   : _pimpl( impl_r )
   {}
index 4057fd8..a0f477f 100644 (file)
@@ -39,10 +39,34 @@ namespace zypp
   //
   /** Resolvable capabilitiy.
    *
+   * Capability is created by a Factory class. Only a default ctor
+   * creating a dummy capability is provided.
+   * \code
+   *   Capability cap;
+   *   try
+   *     {
+   *       cap = CapFactory().parse( ResTraits<Patch>::_kind,
+   *                                 parsed.name,
+   *                                 parsed.op,
+   *                                 Edition( parsed.ver,
+   *                                          parsed.rel,
+   *                                          parsed.epoch ) );
+   *     }
+   *   catch ( const Exception & excpt_r )
+   *     {
+   *       ERR << excpt_r << endl;
+   *       ... Or maybe just WAR, or ?
+   *     }
+   * \endcode
    * \see CapFactory: Factory creating Capability.
    *
    * \invariant Nonzero \c _pimpl
    * \invariant Unified \c _pimpl asserted by CapFactory
+   *
+   * \todo Need a trival return from matches. E.g. Conditional
+   * cpabilities must be able to indicate that they should be
+   * treated as if they were not present at all, if the precondition
+   * does no apply. Same for the defaut Capability.
   */
   class Capability
   {
@@ -67,6 +91,9 @@ namespace zypp
     /** Factory */
     typedef CapFactory Factory;
 
+    /** DefaultCtor creating a dummy Capability. */
+    Capability();
+
     /** Dtor */
     virtual ~Capability();
 
index 80d80ef..5978ddb 100644 (file)
@@ -12,6 +12,7 @@ include_HEADERS = \
        ConditionalCap.h\
        FileCap.h       \
        NamedCap.h      \
+       NullCap.h       \
        OrCap.h         \
        VersionedCap.h
 
@@ -24,6 +25,7 @@ lib@PACKAGE@_capability_la_SOURCES = \
        \
        FileCap.cc      \
        NamedCap.cc     \
+       NullCap.cc      \
        VersionedCap.cc
 
 ## ##################################################
diff --git a/zypp/capability/NullCap.cc b/zypp/capability/NullCap.cc
new file mode 100644 (file)
index 0000000..2f97ce1
--- /dev/null
@@ -0,0 +1,57 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/capability/NullCap.cc
+ *
+*/
+#include "zypp/capability/NullCap.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace capability
+  { /////////////////////////////////////////////////////////////////
+
+    const CapabilityImpl::Kind NullCap::_kind( "NullCap" );
+
+    CapabilityImpl_Ptr NullCap::_instance;
+
+    ///////////////////////////////////////////////////////////////////
+
+    NullCap::NullCap()
+    : CapabilityImpl( Resolvable::Kind() ) // Resolvable::Kind ANY
+    {}
+
+    CapabilityImpl_Ptr NullCap::instance()
+    {
+      if ( ! _instance )
+        _instance = new NullCap;
+      return _instance;
+    }
+
+    const CapabilityImpl::Kind & NullCap::kind() const
+    { return _kind; }
+
+    std::string NullCap::asString() const
+    { return std::string(); }
+
+    bool NullCap::matches( Resolvable::constPtr resolvable_r,
+                           const SolverContext & colverContext_r ) const
+    {
+      return false;
+    }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace capability
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/capability/NullCap.h b/zypp/capability/NullCap.h
new file mode 100644 (file)
index 0000000..f7d3deb
--- /dev/null
@@ -0,0 +1,74 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/capability/NullCap.h
+ *
+*/
+#ifndef ZYPP_CAPABILITY_NAMEDCAP_H
+#define ZYPP_CAPABILITY_NAMEDCAP_H
+
+#include "zypp/capability/CapabilityImpl.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace capability
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : NullCap
+    //
+    /** A dummy Capability.
+     *
+     * It's a singleton, so you can't construct one. Call \ref instance to
+     * get a CapabilityImpl_Ptr to the NullCap.
+     *
+     * \todo implement matches().
+    */
+    class NullCap : public CapabilityImpl
+    {
+    public:
+      /** Get a Ptr to the NULLCap. */
+      static CapabilityImpl_Ptr instance();
+
+    private:
+      /** Private Ctor.
+       * Call \ref instance to get a CapabilityImpl_Ptr to the NullCap.
+       *
+       * \todo Resolvable::Kind ANY would be desirable.
+      */
+      NullCap();
+
+    public:
+      /**  */
+      virtual const Kind & kind() const;
+
+      /**  */
+      virtual std::string asString() const;
+
+      /**  */
+      virtual bool matches( Resolvable::constPtr resolvable_r,
+                            const SolverContext & colverContext_r ) const;
+
+    private:
+      /**  */
+      static const Kind _kind;
+      /**  */
+      static CapabilityImpl_Ptr _instance;
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace capability
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CAPABILITY_NAMEDCAP_H
index f4cdfca..531b6d9 100644 (file)
@@ -12,7 +12,6 @@
 #include "zypp/source/yum/YUMScriptImpl.h"
 #include "zypp/Arch.h"
 #include "zypp/Edition.h"
-#include <zypp/detail/ResObjectFactory.h>
 
 
 using namespace std;