Exemplo n.º 1
0
C_INT32 CFunctionDB::load(CReadConfig &configbuffer)
{
  CFunction Function;
  CFunction * pFunction = NULL;

  C_INT32 Size = 0;
  C_INT32 Fail = 0;

  configbuffer.getVariable("TotalUDKinetics", "C_INT32", &Size,
                           CReadConfig::LOOP);

  for (C_INT32 i = 0; i < Size; i++)
    {
      Function.load(configbuffer);

      switch (Function.getType())
        {
          case CEvaluationTree::Function:
            pFunction = new CFunction(Function);
            break;

          case CEvaluationTree::MassAction:
            pFunction = new CMassAction(Function);
            break;

          case CEvaluationTree::PreDefined:
          case CEvaluationTree::UserDefined:
            pFunction = new CKinFunction(Function,
                                         &configbuffer);
            break;

          default:
            fatalError();
            break;
        }

      pFunction->compile();

      if (!mLoadedFunctions.add(pFunction, true))
        {
          pdelete(pFunction);

          // We ignore:
          // CCopasiVector (2): Object '%s' allready exists.
          if ((MCCopasiVector + 2) != CCopasiMessage::peekLastMessage().getNumber())
            return Fail = 1;

          // Remove the ignored meesage.
          CCopasiMessage::getLastMessage();
        }
    }

  return Fail;
}
Exemplo n.º 2
0
bool FunctionWidget1::saveToFunction()
{
  CFunction* func = dynamic_cast<CFunction*>(CCopasiRootContainer::getKeyFactory()->get(mKey));

  if (!func) return false;

  //radio buttons
  TriLogic tmpl;

  if (RadioButton1->isChecked() == true)
    {
      tmpl = TriTrue;
    }
  else if (RadioButton2->isChecked() == true)
    {
      tmpl = TriFalse;
    }
  else
    {
      tmpl = TriUnspecified;
    }

  if (tmpl != func->isReversible())
    {
      func->setReversible(tmpl);
      flagChanged = true;
    }

  if (flagChanged)
    {
      copyFunctionContentsToFunction(mpFunction, func);

      protectedNotify(ListViews::FUNCTION, ListViews::CHANGE, mKey);

      if (mpDataModel != NULL)
        {
          mpDataModel->changed();
        }

      flagChanged = false;
    }

  func->compile();

  return true;
}