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_RPM_INSTALLEDPKG_OBSOLETES,
00061   SOLVER_RULE_UPDATE = 0x200,
00062   SOLVER_RULE_FEATURE = 0x300,
00063   SOLVER_RULE_JOB = 0x400,
00064   SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP,
00065   SOLVER_RULE_DISTUPGRADE = 0x500,
00066   SOLVER_RULE_INFARCH = 0x600,
00067   SOLVER_RULE_CHOICE = 0x700,
00068   SOLVER_RULE_LEARNT = 0x800
00069 } SolverRuleinfo;
00070 
00071 #define SOLVER_RULE_TYPEMASK    0xff00
00072 
00073 struct _Solver;
00074 
00075 /*-------------------------------------------------------------------
00076  * disable rule
00077  */
00078 
00079 static inline void
00080 solver_disablerule(struct _Solver *solv, Rule *r)
00081 {
00082   if (r->d >= 0)
00083     r->d = -r->d - 1;
00084 }
00085 
00086 /*-------------------------------------------------------------------
00087  * enable rule
00088  */
00089 
00090 static inline void
00091 solver_enablerule(struct _Solver *solv, Rule *r)
00092 {
00093   if (r->d < 0)
00094     r->d = -r->d - 1;
00095 }
00096 
00097 Rule *solver_addrule(struct _Solver *solv, Id p, Id d);
00098 void solver_unifyrules(struct _Solver *solv);
00099 int solver_samerule(struct _Solver *solv, Rule *r1, Rule *r2);
00100 
00101 /* rpm rules */
00102 void solver_addrpmrulesforsolvable(struct _Solver *solv, Solvable *s, Map *m);
00103 void solver_addrpmrulesforweak(struct _Solver *solv, Map *m);
00104 void solver_addrpmrulesforupdaters(struct _Solver *solv, Solvable *s, Map *m, int allow_all);
00105 
00106 /* update/feature rules */
00107 void solver_addupdaterule(struct _Solver *solv, Solvable *s, int allow_all);
00108 
00109 /* infarch rules */
00110 void solver_addinfarchrules(struct _Solver *solv, Map *addedmap);
00111 
00112 /* dup rules */
00113 void solver_createdupmaps(struct _Solver *solv);
00114 void solver_freedupmaps(struct _Solver *solv);
00115 void solver_addduprules(struct _Solver *solv, Map *addedmap);
00116 
00117 /* policy rule disabling/reenabling */
00118 void solver_disablepolicyrules(struct _Solver *solv);
00119 void solver_reenablepolicyrules(struct _Solver *solv, int jobidx);
00120 
00121 /* rule info */
00122 int solver_allruleinfos(struct _Solver *solv, Id rid, Queue *rq);
00123 SolverRuleinfo solver_ruleinfo(struct _Solver *solv, Id rid, Id *fromp, Id *top, Id *depp);
00124 
00125 /* misc functions */
00126 void solver_addchoicerules(struct _Solver *solv);
00127 void solver_disablechoicerules(struct _Solver *solv, Rule *r);
00128 
00129 #ifdef __cplusplus
00130 }
00131 #endif
00132 
00133 #endif
00134 
Generated on Mon Dec 12 11:44:12 2011 for satsolver by  doxygen 1.6.3