Exemplo n.º 1
0
DECLARE_EXPORT void Problem::writeElement(XMLOutput *o, const Keyword& tag, mode m) const
{
  // We ignore the mode, and always write the complete model
  o->BeginObject(tag);
  o->writeElement(Tags::tag_name, getType().type);
  o->writeElement(Tags::tag_description, getDescription());
  o->writeElement(Tags::tag_start, getDates().getStart());
  o->writeElement(Tags::tag_end, getDates().getEnd());
  o->writeElement(Tags::tag_weight, getWeight());
  o->EndObject(tag);
}
Exemplo n.º 2
0
PyObject* Problem::getattro(const Attribute& attr)
{
  if (attr.isA(Tags::tag_name))
    return PythonObject(getType().type);
  if (attr.isA(Tags::tag_description))
    return PythonObject(getDescription());
  if (attr.isA(Tags::tag_entity))
    return PythonObject(getEntity());
  if (attr.isA(Tags::tag_start))
    return PythonObject(getDates().getStart());
  if (attr.isA(Tags::tag_end))
    return PythonObject(getDates().getEnd());
  if (attr.isA(Tags::tag_weight))
    return PythonObject(getWeight());
  if (attr.isA(Tags::tag_owner))
    return PythonObject(getOwner());
  return NULL;
}
Exemplo n.º 3
0
bool Problem::operator < (const Problem& a) const
{
  // 1. Sort based on entity
  assert(owner == a.owner);

  // 2. Sort based on type
  if (getType() != a.getType()) return getType() < a.getType();

  // 3. Sort based on start date
  return getDates().getStart() < a.getDates().getStart();
}
Exemplo n.º 4
0
int main(int argc, char* argv[]) {
	if (checkArguments(argc) != 0)
		return -1;

	char date[MAXDATESIZE];
	getDates(argv[1], date);

	char direc[sizeof(argv[1]) + sizeof(date) + 2 + 1];
	sprintf(direc, "%s/%s", argv[1], date);
	//direc[strlen(direc) - 1] = 0;

	chdirec(direc);
	//printf("\n%s\n", direc);

	readBCKP(argv[1], direc, argv[2]);
	return EXIT_SUCCESS;
}
Exemplo n.º 5
0
void OperationPlan::updateProblems()
{
  // A flag for each problem type that may need to be created
  bool needsBeforeCurrent(false);
  bool needsBeforeFence(false);
  bool needsPrecedence(false);

  // The following categories of operation plans can't have problems:
  //  - locked opplans
  //  - opplans of hidden operations
  if (!getLocked() && getOperation()->getDetectProblems())
  {
    if (!getOwner() || getOperation() == OperationSetup::setupoperation)
    {
      // Avoid duplicating problems on child and owner operationplans
      // Check if a BeforeCurrent problem is required.
      if (dates.getStart() < Plan::instance().getCurrent())
        needsBeforeCurrent = true;

      // Check if a BeforeFence problem is required.
      // Note that we either detect of beforeCurrent or a beforeFence problem,
      // never both simultaneously.
      else if
      (dates.getStart() < Plan::instance().getCurrent() + oper->getFence())
        needsBeforeFence = true;
    }
    if (nextsubopplan && getDates().getEnd() > nextsubopplan->getDates().getStart())
      needsPrecedence = true;
  }

  // Loop through the existing problems
  for (Problem::const_iterator j = Problem::begin(this, false);
      j!=Problem::end();)
  {
    // Need to increment now and define a pointer to the problem, since the
    // problem can be deleted soon (which invalidates the iterator).
    Problem& curprob = *j;
    ++j;
    // The if-statement keeps the problem detection code concise and
    // concentrated. However, a drawback of this design is that a new problem
    // subclass will also require a new demand subclass. I think such a link
    // is acceptable.
    if (typeid(curprob) == typeid(ProblemBeforeCurrent))
    {
      // if: problem needed and it exists already
      if (needsBeforeCurrent) needsBeforeCurrent = false;
      // else: problem not needed but it exists already
      else delete &curprob;
    }
    else if (typeid(curprob) == typeid(ProblemBeforeFence))
    {
      if (needsBeforeFence) needsBeforeFence = false;
      else delete &curprob;
    }
    else if (typeid(curprob) == typeid(ProblemPrecedence))
    {
      if (needsPrecedence) needsPrecedence = false;
      else delete &curprob;
    }
  }

  // Create the problems that are required but aren't existing yet.
  // There is a little trick involved here... Normally problems are owned
  // by objects of the Plannable class. OperationPlan isn't a subclass of
  // Plannable, so we need a dirty cast.
  if (needsBeforeCurrent) new ProblemBeforeCurrent(this);
  if (needsBeforeFence) new ProblemBeforeFence(this);
  if (needsPrecedence) new ProblemPrecedence(this);
}