Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / solver / detail / SolutionAction.h
index 563fc66..84b49db 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  *
  * Easy-to use interface to the ZYPP dependency resolver
  *
@@ -20,6 +20,7 @@
 
 #include "zypp/solver/detail/Types.h"
 #include "zypp/solver/detail/Resolver.h"
+#include "zypp/solver/detail/SolverQueueItem.h"
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -36,67 +37,104 @@ namespace zypp
         **/
        class SolutionAction : public base::ReferenceCounted
        {
+       protected:
+           SolutionAction ();
        public:
-         SolutionAction();
-         virtual ~SolutionAction();
-
-         // ---------------------------------- I/O
+           virtual ~SolutionAction();
 
-         friend std::ostream& operator<<(std::ostream&, const SolutionAction & action);
-         friend std::ostream& operator<<(std::ostream&, const SolutionActionList & actionlist);
-         friend std::ostream& operator<<(std::ostream&, const CSolutionActionList & actionlist);
+           // ---------------------------------- I/O
+           virtual std::ostream & dumpOn( std::ostream & str ) const;
+           friend std::ostream& operator<<(std::ostream & str, const SolutionAction & action)
+               { return action.dumpOn (str); }
+           friend std::ostream& operator<<(std::ostream & str, const SolutionActionList & actionlist);
+           friend std::ostream& operator<<(std::ostream & str, const CSolutionActionList & actionlist);
 
-         // ---------------------------------- methods
+           // ---------------------------------- methods
            /**
             * Execute this action.
             * Returns 'true' on success, 'false' on error.
             **/
-           virtual bool execute() = 0;
+           virtual bool execute (Resolver & resolver) const = 0;
        };
 
 
        /**
         * A problem solution action that performs a transaction
-        * (installs, updates, removes, ...)  one resolvable
+        * (installs, removes, keep ...)  one resolvable
         * (package, patch, pattern, product).
         **/
        typedef enum
        {
-           // TO DO: use some already existing enum (?)
            KEEP,
            INSTALL,
-           UPDATE,
-           REMOVE
+           REMOVE,
+           UNLOCK,
+           LOCK,
+           REMOVE_EXTRA_REQUIRE,
+           REMOVE_EXTRA_CONFLICT,
+           ADD_SOLVE_QUEUE_ITEM,
+           REMOVE_SOLVE_QUEUE_ITEM,
        } TransactionKind;
-       
+
+
        class TransactionSolutionAction: public SolutionAction
        {
        public:
            TransactionSolutionAction( PoolItem item,
                                       TransactionKind action )
-               : SolutionAction(), _item( item ), _action( action ) {}
+               : SolutionAction(),
+                 _item( item ), _action( action ) {}
 
-         // ---------------------------------- I/O
+           TransactionSolutionAction( Capability capability,
+                                      TransactionKind action )
+               : SolutionAction(),
+                 _capability( capability ), _action( action ) {}
+
+
+           TransactionSolutionAction( SolverQueueItem_Ptr item,
+                                      TransactionKind action )
+               : SolutionAction(),
+                 _solverQueueItem( item ), _action( action ) {}
+
+           TransactionSolutionAction( TransactionKind action )
+               : SolutionAction(),
+                 _item(), _action( action ) {}
 
-         friend std::ostream& operator<<(std::ostream&, const TransactionSolutionAction & action);
+         // ---------------------------------- I/O
+         virtual std::ostream & dumpOn( std::ostream & str ) const;
+         friend std::ostream& operator<<(std::ostream& str, const TransactionSolutionAction & action)
+               { return action.dumpOn (str); }
 
          // ---------------------------------- accessors
 
-         PoolItem item() const { return _item; }
-         TransactionKind action() const { return _action;     }
+         const PoolItem item() const { return _item; }
+         const Capability capability() const { return _capability; }
+         TransactionKind action() const { return _action; }
 
          // ---------------------------------- methods
-           virtual bool execute();
-
+           virtual bool execute(Resolver & resolver) const;
 
        protected:
 
            PoolItem _item;
-           TransactionKind _action;
+           Capability _capability;
+           SolverQueueItem_Ptr _solverQueueItem;
+
+           const TransactionKind _action;
        };
 
 
        /**
+        * Type of ignoring; currently only WEAK
+        **/
+
+       typedef enum
+       {
+           WEAK
+       } InjectSolutionKind;
+
+
+       /**
         * A problem solution action that injects an artificial "provides" to
         * the pool to satisfy open requirements or remove the conflict of
         * concerning resolvable
@@ -106,24 +144,27 @@ namespace zypp
        class InjectSolutionAction: public SolutionAction
        {
        public:
-           
-           InjectSolutionAction( const Capability & capability, const Dep & kind )
-               : SolutionAction(), _capability( capability ), _kind( kind ) {}
 
-         // ---------------------------------- I/O
+           InjectSolutionAction( PoolItem item,
+                                 const InjectSolutionKind & kind)
+               : SolutionAction(),
+                 _item( item ),
+                 _kind( kind ) {}
 
-         friend std::ostream& operator<<(std::ostream&, const InjectSolutionAction & action);
+         // ---------------------------------- I/O
+         virtual std::ostream & dumpOn( std::ostream & str ) const;
+         friend std::ostream& operator<<(std::ostream& str, const InjectSolutionAction & action)
+               { return action.dumpOn (str); }
 
          // ---------------------------------- accessors
-           const Capability & capability() const { return _capability; };
+           const PoolItem item() const { return _item; }
 
          // ---------------------------------- methods
-           virtual bool execute();
+           virtual bool execute(Resolver & resolver) const;
 
        protected:
-
-           const Capability & _capability;
-           const Dep & _kind;
+           PoolItem _item;
+           const InjectSolutionKind _kind;
        };