コード例 #1
0
ファイル: location.cpp プロジェクト: albertca/frePPLe
DECLARE_EXPORT void Location::beginElement(XMLInput& pIn, const Attribute& pAttr)
{
  if (pAttr.isA(Tags::tag_available) || pAttr.isA(Tags::tag_maximum))
    pIn.readto( Calendar::reader(Calendar::metadata,pIn.getAttributes()) );
  else
    HasHierarchy<Location>::beginElement(pIn, pAttr);
}
コード例 #2
0
ファイル: setupmatrix.cpp プロジェクト: ConePerez/frePPLe
DECLARE_EXPORT void SetupMatrix::beginElement(XMLInput& pIn, const Attribute& pAttr)
{
  if (pAttr.isA(Tags::tag_rule)
      && pIn.getParentElement().first.isA(Tags::tag_rules))
    // A new rule
    pIn.readto(createRule(pIn.getAttributes()));
}
コード例 #3
0
ファイル: resourceskill.cpp プロジェクト: albertca/frePPLe
DECLARE_EXPORT void ResourceSkill::beginElement(XMLInput& pIn, const Attribute& pAttr)
{
  if (pAttr.isA (Tags::tag_resource))
    pIn.readto( Resource::reader(Resource::metadata,pIn.getAttributes()) );
  else if (pAttr.isA (Tags::tag_skill))
    pIn.readto( Skill::reader(Skill::metadata,pIn.getAttributes()) );
}
コード例 #4
0
ファイル: item.cpp プロジェクト: albertca/frePPLe
DECLARE_EXPORT void Item::beginElement(XMLInput& pIn, const Attribute& pAttr)
{
  if (pAttr.isA (Tags::tag_operation))
    pIn.readto( Operation::reader(Operation::metadata,pIn.getAttributes()) );
  else
    HasHierarchy<Item>::beginElement(pIn, pAttr);
}
コード例 #5
0
ファイル: skill.cpp プロジェクト: dhl/frePPLe
DECLARE_EXPORT void Skill::beginElement(XMLInput& pIn, const Attribute& pAttr)
{
  if (pAttr.isA(Tags::tag_resourceskill)
      && pIn.getParentElement().first.isA(Tags::tag_resourceskills))
  {
    ResourceSkill *s =
      dynamic_cast<ResourceSkill*>(MetaCategory::ControllerDefault(ResourceSkill::metadata,pIn.getAttributes()));
    if (s) s->setSkill(this);
    pIn.readto(s);
  }
  else
    PythonDictionary::read(pIn, pAttr, getDict());
}
コード例 #6
0
ファイル: actions.cpp プロジェクト: ConePerez/frePPLe
DECLARE_EXPORT PyObject* readXMLfile(PyObject* self, PyObject* args)
{
  // Pick up arguments
  char *filename = NULL;
  int validate(1), validate_only(0);
  PyObject *userexit = NULL;
  int ok = PyArg_ParseTuple(args, "|siiO:readXMLfile",
    &filename, &validate, &validate_only, &userexit);
  if (!ok) return NULL;

  // Execute and catch exceptions
  Py_BEGIN_ALLOW_THREADS   // Free Python interpreter for other threads
  try
  {
    if (!filename)
    {
      // Read from standard input
      xercesc::StdInInputSource in;
      XMLInput p;
      if (userexit) p.setUserExit(userexit);
      if (validate_only!=0)
        // When no root object is passed, only the input validation happens
        p.parse(in, NULL, true);
      else
        p.parse(in, &Plan::instance(), validate!=0);
    }
    else
    {
      XMLInputFile p(filename);
      if (userexit) p.setUserExit(userexit);
      if (validate_only!=0)
        // Read and validate a file
        p.parse(NULL, true);
      else
        // Read, execute and optionally validate a file
        p.parse(&Plan::instance(),validate!=0);
    }
  }
  catch (...)
  {
    Py_BLOCK_THREADS;
    PythonType::evalException();
    return NULL;
  }
  Py_END_ALLOW_THREADS   // Reclaim Python interpreter
  return Py_BuildValue("");
}
コード例 #7
0
ファイル: location.cpp プロジェクト: albertca/frePPLe
DECLARE_EXPORT void Location::endElement(XMLInput& pIn, const Attribute& pAttr, const DataElement& pElement)
{
  if (pAttr.isA(Tags::tag_available))
  {
    CalendarDouble *cal = dynamic_cast<CalendarDouble*>(pIn.getPreviousObject());
    if (cal)
      setAvailable(cal);
    else
    {
      Calendar *c = dynamic_cast<Calendar*>(pIn.getPreviousObject());
      if (!c)
        throw LogicException("Incorrect object type during read operation");
      throw DataException("Calendar '" + c->getName() +
          "' has invalid type for use as location calendar");
    }
  }
  else
  {
    HasDescription::endElement(pIn, pAttr, pElement);
    HasHierarchy<Location>::endElement(pIn, pAttr, pElement);
  }
}
コード例 #8
0
ファイル: item.cpp プロジェクト: albertca/frePPLe
DECLARE_EXPORT void Item::endElement(XMLInput& pIn, const Attribute& pAttr, const DataElement& pElement)
{
  if (pAttr.isA(Tags::tag_operation))
  {
    Operation *o = dynamic_cast<Operation*>(pIn.getPreviousObject());
    if (o) setOperation(o);
    else throw LogicException("Incorrect object type during read operation");
  }
  else if (pAttr.isA(Tags::tag_price))
    setPrice(pElement.getDouble());
  else
  {
    HasDescription::endElement(pIn, pAttr, pElement);
    HasHierarchy<Item>::endElement(pIn, pAttr, pElement);
  }
}
コード例 #9
0
ファイル: resourceskill.cpp プロジェクト: albertca/frePPLe
DECLARE_EXPORT void ResourceSkill::endElement (XMLInput& pIn, const Attribute& pAttr, const DataElement& pElement)
{
  if (pAttr.isA (Tags::tag_resource))
  {
    Resource *r = dynamic_cast<Resource*>(pIn.getPreviousObject());
    if (r) setResource(r);
    else throw LogicException("Incorrect object type during read operation");
  }
  else if (pAttr.isA (Tags::tag_skill))
  {
    Skill *s = dynamic_cast<Skill*>(pIn.getPreviousObject());
    if (s) setSkill(s);
    else throw LogicException("Incorrect object type during read operation");
  }
  else if (pAttr.isA(Tags::tag_priority))
    setPriority(pElement.getInt());
  else if (pAttr.isA(Tags::tag_effective_end))
    setEffectiveEnd(pElement.getDate());
  else if (pAttr.isA(Tags::tag_effective_start))
    setEffectiveStart(pElement.getDate());
  else if (pAttr.isA(Tags::tag_action))
  {
    delete static_cast<Action*>(pIn.getUserArea());
    pIn.setUserArea(
      new Action(MetaClass::decodeAction(pElement.getString().c_str()))
    );
  }
  else if (pIn.isObjectEnd())
  {
    // The resourceskill data is now all read in. See if it makes sense now...
    Action a = pIn.getUserArea() ?
        *static_cast<Action*>(pIn.getUserArea()) :
        ADD_CHANGE;
    delete static_cast<Action*>(pIn.getUserArea());
    try { validate(a); }
    catch (...)
    {
      delete this;
      throw;
    }
  }
}