55 x.
setDoc(
"frePPLe setupmatrixrule");
68 "setupmatrix_default",
69 Object::createString<SetupMatrixDefault>,
true);
80 while (firstRule)
delete firstRule;
84 if (m->getSetupMatrix() ==
this) m->setSetupMatrix(NULL);
129 Rule* result = firstRule;
130 while (result && priority > result->priority)
131 result = result->nextRule;
132 if (result && result->priority != priority) result = NULL;
135 switch (MetaClass::decodeAction(atts))
142 o <<
"Rule with priority " << priority
143 <<
" already exists in setup matrix '" <<
getName() <<
"'";
146 result =
new Rule(
this, priority);
153 o <<
"No rule with priority " << priority
154 <<
" exists in setup matrix '" <<
getName() <<
"'";
163 o <<
"No rule with priority " << priority
164 <<
" exists in setup matrix '" <<
getName() <<
"'";
176 result =
new Rule(
this, priority);
217 if (!matrix)
throw LogicException(
"Can't add a rule to a NULL setupmatrix");
221 PyObject *pyfrom = NULL;
222 PyObject *pyto = NULL;
225 static const char *kwlist[] = {
"priority",
"fromsetup",
"tosetup",
"duration",
"cost", NULL};
226 if (!PyArg_ParseTupleAndKeywords(args, kwdict,
228 const_cast<char**>(kwlist), &prio, &pyfrom, &pyto, &duration, &cost))
241 PythonType::evalException();
248 : cost(0), priority(p), matrix(s), nextRule(NULL), prevRule(NULL)
251 if (!matrix)
throw DataException(
"Can't add a rule to NULL setup matrix");
254 Rule *next = matrix->firstRule, *prev = NULL;
255 while (next && p > next->priority)
258 next = next->nextRule;
262 if (next && next->priority == p)
263 throw DataException(
"Multiple rules with identical priority in setup matrix");
268 if (prev) prev->nextRule =
this;
269 else matrix->firstRule =
this;
270 if (next) next->prevRule =
this;
280 if (nextRule) nextRule->prevRule = prevRule;
281 if (prevRule) prevRule->nextRule = nextRule;
282 else matrix->firstRule = nextRule;
301 setPriority(pElement.
getInt());
334 setPriority(field.
getInt());
355 while (prevRule && priority < prevRule->priority)
357 Rule* next = nextRule;
358 Rule* prev = prevRule;
359 if (prev && prev->prevRule) prev->prevRule->nextRule =
this;
360 else matrix->firstRule =
this;
361 if (prev) prev->nextRule = nextRule;
363 prevRule = prev ? prev->prevRule : NULL;
364 if (next && next->nextRule) next->nextRule->prevRule = prev;
365 if (next) next->prevRule = prev;
366 if (prev) prev->prevRule =
this;
370 while (nextRule && priority > nextRule->priority)
372 Rule* next = nextRule;
373 Rule* prev = prevRule;
374 nextRule = next->nextRule;
375 if (next && next->nextRule) next->nextRule->prevRule =
this;
376 if (prev) prev->nextRule = next;
377 if (next) next->nextRule =
this;
378 if (next) next->prevRule = prev;
383 if ((prevRule && prevRule->priority == priority)
384 || (nextRule && nextRule->priority == priority))
387 o <<
"Duplicate priority " << priority <<
" in setup matrix '"
388 << matrix->getName() <<
"'";
398 x.
setName(
"setupmatrixRuleIterator");
399 x.
setDoc(
"frePPLe iterator for setupmatrix rules");
407 if (currule == matrix->endRules())
return NULL;
408 PyObject *result = &*(currule++);
415 (
const string oldsetup,
const string newsetup)
const
418 if (oldsetup == newsetup)
return NULL;
421 for (
Rule *curRule = firstRule; curRule; curRule = curRule->nextRule)
424 if (!curRule->getFromSetup().empty()
425 && !
matchWildcard(curRule->getFromSetup().c_str(), oldsetup.c_str()))
428 if (!curRule->getToSetup().empty()
429 && !
matchWildcard(curRule->getToSetup().c_str(), newsetup.c_str()))
436 logger <<
"Warning: Conversion from '" << oldsetup <<
"' to '" << newsetup
437 <<
"' undefined in setup matrix '" <<
getName() << endl;