diff --git a/copasi/xml/CCopasiXMLInterface.cpp b/copasi/xml/CCopasiXMLInterface.cpp index cb55955a92..62458b65d5 100644 --- a/copasi/xml/CCopasiXMLInterface.cpp +++ b/copasi/xml/CCopasiXMLInterface.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2020 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -463,7 +463,7 @@ bool CCopasiXMLInterface::saveParameter(const CCopasiParameter & parameter) break; case CCopasiParameter::Type::CN: - Attributes.add("value", parameter.getValue< CCommonName >()); + Attributes.add("value", parameter.getValue< CRegisteredCommonName >()); if (!saveElement("Parameter", Attributes)) success = false; diff --git a/copasi/xml/parser/ParameterHandler.cpp b/copasi/xml/parser/ParameterHandler.cpp index cb1b6b6343..141c5009f0 100644 --- a/copasi/xml/parser/ParameterHandler.cpp +++ b/copasi/xml/parser/ParameterHandler.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2020 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -18,6 +18,8 @@ #include "ParameterHandler.h" #include "CXMLParser.h" +#include "copasi/CopasiDataModel/CDataModel.h" +#include "copasi/core/CRegisteredCommonName.h" #include "copasi/utilities/CCopasiParameter.h" /** @@ -47,7 +49,6 @@ CXMLHandler * ParameterHandler::processStart(const XML_Char * pszName, std::string sValue(""); bool UnmappedKey = false; - void * pValue = NULL; CCopasiParameter::Type type; C_FLOAT64 d; @@ -69,26 +70,28 @@ CXMLHandler * ParameterHandler::processStart(const XML_Char * pszName, sValue = cValue; } + mpData->pCurrentParameter = new CCopasiParameter(name, type); + switch (type) { case CCopasiParameter::Type::DOUBLE: d = CCopasiXMLInterface::DBL(sValue.c_str()); - pValue = &d; + mpData->pCurrentParameter->setValue(d); break; case CCopasiParameter::Type::UDOUBLE: d = CCopasiXMLInterface::DBL(sValue.c_str()); - pValue = &d; + mpData->pCurrentParameter->setValue(d); break; case CCopasiParameter::Type::INT: i = strToInt(sValue.c_str()); - pValue = &i; + mpData->pCurrentParameter->setValue(i); break; case CCopasiParameter::Type::UINT: ui = strToUnsignedInt(sValue.c_str()); - pValue = &ui; + mpData->pCurrentParameter->setValue(ui); break; case CCopasiParameter::Type::BOOL: @@ -102,19 +105,17 @@ CXMLHandler * ParameterHandler::processStart(const XML_Char * pszName, b = true; } - pValue = &b; + mpData->pCurrentParameter->setValue(b); break; case CCopasiParameter::Type::STRING: case CCopasiParameter::Type::FILE: - case CCopasiParameter::Type::CN: - pValue = &sValue; + mpData->pCurrentParameter->setValue(sValue); break; case CCopasiParameter::Type::KEY: { - if (sValue != "" && - CKeyFactory::isValidKey(sValue)) + if (sValue != "" && CKeyFactory::isValidKey(sValue)) { CDataObject * pObject = mpData->mKeyMap.get(sValue); @@ -128,20 +129,21 @@ CXMLHandler * ParameterHandler::processStart(const XML_Char * pszName, } } - pValue = &sValue; + mpData->pCurrentParameter->setValue(sValue); } break; + case CCopasiParameter::Type::CN: + mpData->pCurrentParameter->setValue(CRegisteredCommonName(sValue, mpData->pDataModel)); + break; + default: if (cType != NULL) // otherwise missing attribute will have been logged CCopasiMessage(CCopasiMessage::ERROR, MCXML + 16, name.c_str(), cType, mpParser->getCurrentLineNumber()); - pValue = NULL; break; } - mpData->pCurrentParameter = new CCopasiParameter(name, type, pValue); - if (UnmappedKey) { mpData->UnmappedKeyParameters.push_back(mpData->pCurrentParameter->getKey()); diff --git a/copasi/xml/parser/TaskHandler.cpp b/copasi/xml/parser/TaskHandler.cpp index 5588ce206d..a6551b0162 100644 --- a/copasi/xml/parser/TaskHandler.cpp +++ b/copasi/xml/parser/TaskHandler.cpp @@ -26,6 +26,7 @@ #include "copasi/utilities/CTaskFactory.h" #include "copasi/model/CModel.h" #include "copasi/function/CExpression.h" +#include "copasi/CopasiDataModel/CDataModel.h" /** * Replace Task with the name type of the handler and implement the @@ -241,7 +242,7 @@ bool TaskHandler::processEnd(const XML_Char * pszName) continue; pGroup->addParameter("Role", CCopasiParameter::Type::UINT, entry.second.first); - pGroup->addParameter("Object CN", CCopasiParameter::Type::CN, CRegisteredCommonName(entry.second.second, pGroup)); + pGroup->addParameter("Object CN", CCopasiParameter::Type::CN, CRegisteredCommonName(entry.second.second, mpData->pDataModel)); } } }