refactor a bit
[platform/upstream/libsolv.git] / src / transaction.h
index 2e0a130..36b0c6f 100644 (file)
  *
  */
 
-#ifndef SATSOLVER_TRANSACTION_H
-#define SATSOLVER_TRANSACTION_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifndef LIBSOLV_TRANSACTION_H
+#define LIBSOLV_TRANSACTION_H
 
 #include "pooltypes.h"
 #include "queue.h"
 #include "bitmap.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct _Pool;
+struct _DUChanges;
 struct _TransactionOrderdata;
 
 typedef struct _Transaction {
@@ -29,12 +30,14 @@ typedef struct _Transaction {
 
   Queue steps;                 /* the transaction steps */
 
+#ifdef LIBSOLV_INTERNAL
   Queue transaction_info;
   Id *transaction_installed;
   Map transactsmap;
-  Map noobsmap;
+  Map multiversionmap;
 
   struct _TransactionOrderdata *orderdata;
+#endif
 
 } Transaction;
 
@@ -61,7 +64,7 @@ typedef struct _Transaction {
 
 #define SOLVER_TRANSACTION_MAXTYPE             0x3f
 
-/* show modes */
+/* modes */
 #define SOLVER_TRANSACTION_SHOW_ACTIVE         (1 << 0)
 #define SOLVER_TRANSACTION_SHOW_ALL            (1 << 1)
 #define SOLVER_TRANSACTION_SHOW_OBSOLETES      (1 << 2)
@@ -72,25 +75,58 @@ typedef struct _Transaction {
 
 #define SOLVER_TRANSACTION_RPM_ONLY            (1 << 7)
 
+#define SOLVER_TRANSACTION_KEEP_PSEUDO         (1 << 8)
+
+#define SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE  (1 << 9)
+
 /* extra classifications */
 #define SOLVER_TRANSACTION_ARCHCHANGE          0x100
 #define SOLVER_TRANSACTION_VENDORCHANGE                0x101
 
-extern void transaction_init(Transaction *trans, struct _Pool *pool);
+/* order flags */
+#define SOLVER_TRANSACTION_KEEP_ORDERDATA      (1 << 0)
+
+extern Transaction *transaction_create(struct _Pool *pool);
+extern Transaction *transaction_create_decisionq(struct _Pool *pool, Queue *decisionq, Map *multiversionmap);
+extern Transaction *transaction_create_clone(Transaction *srctrans);
 extern void transaction_free(Transaction *trans);
-extern void transaction_calculate(Transaction *trans, Queue *decisionq, Map *noobsmap);
-extern void transaction_all_obs_pkgs(Transaction *trans, Id p, Queue *pkgs);
+extern void transaction_free_orderdata(Transaction *trans);
+
+/* if p is installed, returns with pkg(s) obsolete p */
+/* if p is not installed, returns with pkg(s) we obsolete */
 extern Id   transaction_obs_pkg(Transaction *trans, Id p);
+extern void transaction_all_obs_pkgs(Transaction *trans, Id p, Queue *pkgs);
+
+/* return step type of a transaction element */
 extern Id   transaction_type(Transaction *trans, Id p, int mode);
-extern void transaction_classify(Transaction *trans, Queue *classes, int mode);
-extern void transaction_classify_pkgs(Transaction *trans, Queue *pkgs, int mode, Id class, Id from, Id to);
 
+/* return sorted collection of all step types */
+/* classify_pkgs can be used to return all packages of a type */
+extern void transaction_classify(Transaction *trans, int mode, Queue *classes);
+extern void transaction_classify_pkgs(Transaction *trans, int mode, Id type, Id from, Id to, Queue *pkgs);
+
+/* return all packages that will be installed after the transaction is run*/
+/* The new packages are put at the head of the queue, the number of new
+   packages is returned */
+extern int transaction_installedresult(Transaction *trans, Queue *installedq);
+
+int transaction_calc_installsizechange(Transaction *trans);
+void transaction_calc_duchanges(Transaction *trans, struct _DUChanges *mps, int nmps);
+
+/* order a transaction */
 extern void transaction_order(Transaction *trans, int flags);
-extern int  transaction_order_add_choices(Transaction *trans, Queue *choices, Id chosen);
+
+/* roll your own order funcion:
+ * add pkgs free for installation to queue choices after chosen was
+ * installed. start with chosen = 0
+ * needs an ordered transaction created with SOLVER_TRANSACTION_KEEP_ORDERDATA */
+extern int  transaction_order_add_choices(Transaction *trans, Id chosen, Queue *choices);
+/* add obsoleted packages into transaction steps */
+extern void transaction_add_obsoleted(Transaction *trans);
+
+/* debug function, report problems found in the order */
 extern void transaction_check_order(Transaction *trans);
 
-/* order flags */
-#define SOLVER_TRANSACTION_KEEP_ORDERDATA      (1 << 0)
 
 #ifdef __cplusplus
 }