CModel * CModelParameter::getModel() const { CModelParameterSet * pSet = getSet(); if (pSet != NULL) { return pSet->getModel(); } return NULL; }
// virtual void CModelParameter::setValue(const C_FLOAT64 & value, const Framework & /* framework */) { mValue = value; CModelParameterSet * pSet = getSet(); if (pSet->isActive()) { updateModel(); } }
bool CQParameterSetsDM::removeRows(QModelIndexList rows, const QModelIndex & /* index */) { if (rows.isEmpty()) return false; if (mpListOfParameterSets == NULL) return false; // Build the list of pointers to items to be deleted // before actually deleting any item. QList< CModelParameterSet * > ModelParameterSets; QModelIndexList::const_iterator i; for (i = rows.begin(); i != rows.end(); ++i) { ModelParameterSets.append((*mpListOfParameterSets)[(*i).row()]); } QList< CModelParameterSet * >::const_iterator j; for (j = ModelParameterSets.begin(); j != ModelParameterSets.end(); ++j) { CModelParameterSet * pModelParameterSet = *j; size_t delRow = mpListOfParameterSets->CCopasiVector< CModelParameterSet >::getIndex(pModelParameterSet); if (delRow != C_INVALID_INDEX) { QMessageBox::StandardButton choice = CQMessageBox::confirmDelete(NULL, "layout", FROM_UTF8(pModelParameterSet->getObjectName()), std::set< const CCopasiObject * >()); if (choice == QMessageBox::Ok) removeRow((int) delRow); } } return true; }
CModelParameterSet::CModelParameterSet(const CModelParameterSet & src, const CCopasiContainer * pParent, const bool & createMissing): CCopasiContainer(src, pParent), CModelParameterGroup(src, NULL, createMissing), CAnnotation(src), mKey(CCopasiRootContainer::getKeyFactory()->add("ModelParameterSet", this)), mpModel(NULL) { setObjectParent(pParent); if (mpModel == NULL) { mpModel = src.getModel(); } compile(); }
void CCopasiXMLParser::ModelParameterSetElement::end(const XML_Char *pszName) { switch (mCurrentElement) { case ModelParameterSet: if (strcmp(pszName, "ModelParameterSet")) CCopasiMessage(CCopasiMessage::EXCEPTION, MCXML + 11, pszName, "ModelParameterSet", mParser.getCurrentLineNumber()); mCommon.ModelParameterGroupStack.pop(); mParser.popElementHandler(); mLastKnownElement = START_ELEMENT; /* Tell the parent element we are done. */ mParser.onEndElement(pszName); break; case MiriamAnnotation: if (strcmp(pszName, "MiriamAnnotation")) CCopasiMessage(CCopasiMessage::EXCEPTION, MCXML + 11, pszName, "MiriamAnnotation", mParser.getCurrentLineNumber()); { CModelParameterSet * pModelParameterSet = static_cast< CModelParameterSet * >(mCommon.ModelParameterGroupStack.top()); pModelParameterSet->setMiriamAnnotation(mCommon.CharacterData, pModelParameterSet->getKey(), mKey); } mCommon.CharacterData = ""; break; case Comment: if (strcmp(pszName, "Comment")) CCopasiMessage(CCopasiMessage::EXCEPTION, MCXML + 11, pszName, "Comment", mParser.getCurrentLineNumber()); static_cast< CModelParameterSet * >(mCommon.ModelParameterGroupStack.top())->setNotes(mCommon.CharacterData); mCommon.CharacterData = ""; break; case ListOfUnsupportedAnnotations: if (strcmp(pszName, "ListOfUnsupportedAnnotations")) CCopasiMessage(CCopasiMessage::EXCEPTION, MCXML + 11, pszName, "ListOfUnsupportedAnnotations", mParser.getCurrentLineNumber()); static_cast< CModelParameterSet * >(mCommon.ModelParameterGroupStack.top())->getUnsupportedAnnotations() = mParser.mListOfUnsupportedAnnotationsElement.getUnsupportedAnnotations(); break; case Content: if (strcmp(pszName, "ModelParameterGroup") && strcmp(pszName, "ModelParameter")) { CCopasiMessage(CCopasiMessage::EXCEPTION, MCXML + 11, pszName, "ModelParameterGroup or ModelParameter", mParser.getCurrentLineNumber()); } if (mCommon.pCurrentModelParameter != NULL) { mCommon.ModelParameterGroupStack.top()->add(mCommon.pCurrentModelParameter); mCommon.pCurrentModelParameter = NULL; } // Content may be repeated therefore we set to the previous element which is ListOfUnkownAnnotations. mCurrentElement = mLastKnownElement = ModelParameterSet; break; case UNKNOWN_ELEMENT: mCurrentElement = mLastKnownElement; break; default: CCopasiMessage(CCopasiMessage::EXCEPTION, MCXML + 11, pszName, "???", mParser.getCurrentLineNumber()); break; } return; }
void CCopasiXMLParser::ModelParameterSetElement::start(const XML_Char *pszName, const XML_Char **papszAttrs) { const char * Name; mpCurrentHandler = NULL; mCurrentElement = mLastKnownElement; while (mpCurrentHandler == NULL) { mCurrentElement++; /* We should always be on the next element */ switch (mCurrentElement) { case ModelParameterSet: if (strcmp(pszName, "ModelParameterSet")) CCopasiMessage(CCopasiMessage::EXCEPTION, MCXML + 10, pszName, "ModelParameterSet", mParser.getCurrentLineNumber()); mLastKnownElement = ModelParameterSet; // Element specific code. mKey = mParser.getAttributeValue("key", papszAttrs); Name = mParser.getAttributeValue("name", papszAttrs); { CModelParameterSet * pModelParameterSet = new CModelParameterSet(Name); int index = 1; // We need to resolve naming conflicts. while (!mCommon.pModel->getModelParameterSets().add(pModelParameterSet, true)) { std::ostringstream NewName; NewName << Name << "[" << index++ << "]"; pModelParameterSet->setObjectName(NewName.str()); } mCommon.ModelParameterGroupStack.push(pModelParameterSet); mCommon.KeyMap.addFix(mKey, pModelParameterSet); } return; case MiriamAnnotation: if (!strcmp(pszName, "MiriamAnnotation")) { mpCurrentHandler = &mParser.mMiriamAnnotationElement; mLastKnownElement = mCurrentElement; } break; case Comment: if (!strcmp(pszName, "Comment")) { mpCurrentHandler = &mParser.mCommentElement; mLastKnownElement = mCurrentElement; } break; case ListOfUnsupportedAnnotations: if (!strcmp(pszName, "ListOfUnsupportedAnnotations")) mpCurrentHandler = &mParser.mListOfUnsupportedAnnotationsElement; break; case Content: if (!strcmp(pszName, "ModelParameterGroup")) { /* If we do not have an etc element handler we create one. */ if (!mpModelParameterGroupElement) mpModelParameterGroupElement = new ModelParameterGroupElement(mParser, mCommon); mpCurrentHandler = mpModelParameterGroupElement; } else if (!strcmp(pszName, "ModelParameter")) { /* If we do not have an etc element handler we create one. */ if (!mpModelParameterElement) mpModelParameterElement = new ModelParameterElement(mParser, mCommon); mpCurrentHandler = mpModelParameterElement; } break; default: mCurrentElement = UNKNOWN_ELEMENT; mpCurrentHandler = &mParser.mUnknownElement; break; } } mParser.pushElementHandler(mpCurrentHandler); if (mpCurrentHandler != &mParser.mUnknownElement) { mLastKnownElement = mCurrentElement; } mParser.onStartElement(pszName, papszAttrs); return; }