rules.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2007-2009, Novell Inc.
00003  *
00004  * This program is licensed under the BSD license, read LICENSE.BSD
00005  * for further information
00006  */
00007 
00008 /*
00009  * rules.h
00010  *
00011  */
00012 
00013 #ifndef SATSOLVER_RULES_H
00014 #define SATSOLVER_RULES_H
00015 
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019 
00020 /* ----------------------------------------------
00021  * Rule
00022  *
00023  *   providerN(B) == Package Id of package providing tag B
00024  *   N = 1, 2, 3, in case of multiple providers
00025  *
00026  * A requires B : !A | provider1(B) | provider2(B)
00027  *
00028  * A conflicts B : (!A | !provider1(B)) & (!A | !provider2(B)) ...
00029  *
00030  * 'not' is encoded as a negative Id
00031  *
00032  * Binary rule: p = first literal, d = 0, w2 = second literal, w1 = p
00033  *
00034  * There are a lot of rules, so the struct is kept as small as
00035  * possible. Do not add new members unless there is no other way.
00036  */
00037 
00038 typedef struct _Rule {
00039   Id p;         /* first literal in rule */
00040   Id d;         /* Id offset into 'list of providers terminated by 0' as used by whatprovides; pool->whatprovides + d */
00041                 /* in case of binary rules, d == 0, w1 == p, w2 == other literal */
00042                 /* in case of disabled rules: ~d, aka -d - 1 */
00043   Id w1, w2;    /* watches, literals not-yet-decided */
00044                 /* if !w2, assertion, not rule */
00045   Id n1, n2;    /* next rules in linked list, corresponding to w1, w2 */
00046 } Rule;
00047 
00048 
00049 typedef enum {
00050   SOLVER_RULE_UNKNOWN = 0,
00051   SOLVER_RULE_RPM = 0x100,
00052   SOLVER_RULE_RPM_NOT_INSTALLABLE,
00053   SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP,
00054   SOLVER_RULE_RPM_PACKAGE_REQUIRES,
00055   SOLVER_RULE_RPM_SELF_CONFLICT,
00056   SOLVER_RULE_RPM_PACKAGE_CONFLICT,
00057   SOLVER_RULE_RPM_SAME_NAME,
00058   SOLVER_RULE_RPM_PACKAGE_OBSOLETES,
00059   SOLVER_RULE_RPM_IMPLICIT_OBSOLETES,
00060   SOLVER_RULE_UPDATE = 0x200,
00061   SOLVER_RULE_FEATURE = 0x300,
00062   SOLVER_RULE_JOB = 0x400,
00063   SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP,
00064   SOLVER_RULE_DISTUPGRADE = 0x500,
00065   SOLVER_RULE_INFARCH = 0x600,
00066   SOLVER_RULE_CHOICE = 0x700,
00067   SOLVER_RULE_LEARNT = 0x800
00068 } SolverRuleinfo;
00069 
00070 #define SOLVER_RULE_TYPEMASK    0xff00
00071 
00072 struct _Solver;
00073 
00074 /*-------------------------------------------------------------------
00075  * disable rule
00076  */
00077 
00078 static inline void
00079 solver_disablerule(struct _Solver *solv, Rule *r)
00080 {
00081   if (r->d >= 0)
00082     r->d = -r->d - 1;
00083 }
00084 
00085 /*-------------------------------------------------------------------
00086  * enable rule
00087  */
00088 
00089 static inline void
00090 solver_enablerule(struct _Solver *solv, Rule *r)
00091 {
00092   if (r->d < 0)
00093     r->d = -r->d - 1;
00094 }
00095 
00096 Rule *solver_addrule(struct _Solver *solv, Id p, Id d);
00097 void solver_unifyrules(struct _Solver *solv);
00098 int solver_samerule(struct _Solver *solv, Rule *r1, Rule *r2);
00099 
00100 /* rpm rules */
00101 void solver_addrpmrulesforsolvable(struct _Solver *solv, Solvable *s, Map *m);
00102 void solver_addrpmrulesforweak(struct _Solver *solv, Map *m);
00103 void solver_addrpmrulesforupdaters(struct _Solver *solv, Solvable *s, Map *m, int allow_all);
00104 
00105 /* update/feature rules */
00106 void solver_addupdaterule(struct _Solver *solv, Solvable *s, int allow_all);
00107 
00108 /* infarch rules */
00109 void solver_addinfarchrules(struct _Solver *solv, Map *addedmap);
00110 
00111 /* dup rules */
00112 void solver_createdupmaps(struct _Solver *solv);
00113 void solver_freedupmaps(struct _Solver *solv);
00114 void solver_addduprules(struct _Solver *solv, Map *addedmap);
00115 
00116 /* policy rule disabling/reenabling */
00117 void solver_disablepolicyrules(struct _Solver *solv);
00118 void solver_reenablepolicyrules(struct _Solver *solv, int jobidx);
00119 
00120 /* rule info */
00121 int solver_allruleinfos(struct _Solver *solv, Id rid, Queue *rq);
00122 SolverRuleinfo solver_ruleinfo(struct _Solver *solv, Id rid, Id *fromp, Id *top, Id *depp);
00123 
00124 
00125 #ifdef __cplusplus
00126 }
00127 #endif
00128 
00129 #endif
00130 

doxygen