File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ namespace ift::encoder {
1414
1515/*
1616 * The conditions under which a patch should be laoded.
17+ *
18+ * The condition is encoded as a monotonic CNF (Conjunctive Normal Form) boolean
19+ * expression:
20+ *
21+ * (s_1_1 OR s_1_2 OR ...) AND (s_2_1 OR ...) ...
1722 */
1823class ActivationCondition {
1924 public:
@@ -101,6 +106,28 @@ class ActivationCondition {
101106 return conditions ().size () == 1 && conditions ().at (0 ).size () == 1 ;
102107 }
103108
109+ // Returns true if the condition is of the form
110+ // a OR b f OR c ... with no conjunction.
111+ bool IsPurelyDisjunctive () const {
112+ return conditions ().size () == 1 ;
113+ }
114+
115+ // Returns true if the condition is of the form
116+ // a AND b AND c ... with no disjunction.
117+ bool IsPurelyConjunctive () const {
118+ if (conditions ().size () == 1 ) {
119+ return false ;
120+ }
121+
122+ for (const auto & segments : conditions ()) {
123+ if (segments.size () > 1 ) {
124+ return false ;
125+ }
126+ }
127+
128+ return true ;
129+ }
130+
104131 // Compute and return the probability that this condition will be activated
105132 // based on the provided individual segment probabilities.
106133 //
You can’t perform that action at this time.
0 commit comments