示例#1
0
/*
 * The functions determins wether the given UnitDefinition contains only
 * units from the list given as the second argument.
 * @param const UnitDefinition& uDef
 * @param const ListOf& unitList
 * @return bool containsOnlyGivenUnits
 */
LIBSBML_EXTERN
bool UnitConversionFactory::containsOnlyGivenUnits(const UnitDefinition& uDef, const ListOf& unitList)
{
    bool result = true;
    UnitDefinition* pTmpUdef = UnitConversionFactory::convertToSI(uDef);

    if (pTmpUdef)
    {
        unsigned int i;
        unsigned int maxUnits = pTmpUdef->getNumUnits();

        for (i = 0; i < maxUnits; ++i)
        {
            Unit* pU = pTmpUdef->getUnit(i);
            UnitKind_t kind = pU->getKind();
            unsigned int j;
            unsigned int maxUnits2 = unitList.size();
            bool found = false;

            for (j = 0; j < maxUnits2; ++j)
            {
                const Unit* pU2 = dynamic_cast<const Unit*>(unitList.get(j));

                if (!pU2) break;

                if (pU2->getKind() == kind)
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                result = false;
                break;
            }
        }

        delete pTmpUdef;
    }
    else
    {
        result = false;
    }

    return result;
}
示例#2
0
//static
void SBMLDocumentLoader::readListOfLayouts(CListOfLayouts & lol,
    const ListOf & sbmlList,
    const std::map<CCopasiObject*, SBase*> & copasimodelmap)
{
  unsigned C_INT32 i, iMax;
#ifdef USE_CRENDER_EXTENSION
  // read the global render information
  const ListOfLayouts* pLoL = dynamic_cast<const ListOfLayouts*>(&sbmlList);
  assert(pLoL != NULL);
  RenderListOfLayoutsPlugin* rlolPlugin = (RenderListOfLayoutsPlugin*) pLoL ->getPlugin("render");

  if (rlolPlugin == NULL)
    {
      const_cast<SBMLDocument *>(pLoL->getSBMLDocument())->enablePackage(RenderExtension::getXmlnsL3V1V1(), "render", true);
      rlolPlugin = (RenderListOfLayoutsPlugin*) pLoL ->getPlugin("render");
    }

  iMax = rlolPlugin->getNumGlobalRenderInformationObjects();
  std::map<std::string, std::string> idToKeyMap;
  CLGlobalRenderInformation* pGRI = NULL;

  /*
  std::map<std::string,std::string> colorIdToKeyMap;
  std::map<std::string,std::string> gradientIdToKeyMap;
  std::map<std::string,std::string> lineEndingIdToKeyMap;
  std::map<std::string,std::map<std::string,std::string> > colorIdToKeyMapMap;
  std::map<std::string,std::map<std::string,std::string> > gradientIdToKeyMapMap;
  std::map<std::string,std::map<std::string,std::string> > lineEndingIdToKeyMapMap;
  */
  for (i = 0; i < iMax; ++i)
    {
      //colorIdToKeyMap.clear();
      //gradientIdToKeyMap.clear();
      //lineEndingIdToKeyMap.clear();
      //pGRI=new CLGlobalRenderInformation(*pLoL->getRenderInformation(i),colorIdToKeyMap,gradientIdToKeyMap,lineEndingIdToKeyMap,&lol);
      pGRI = new CLGlobalRenderInformation(*rlolPlugin->getRenderInformation(i), &lol);

      if (rlolPlugin->getRenderInformation(i)->isSetId())
        idToKeyMap.insert(std::pair<std::string, std::string>(rlolPlugin->getRenderInformation(i)->getId(), pGRI->getKey()));
      else
        idToKeyMap.insert(std::pair<std::string, std::string>(pGRI->getKey(), pGRI->getKey()));

      //colorIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pGRI->getKey(),colorIdToKeyMap));
      //gradientIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pGRI->getKey(),gradientIdToKeyMap));
      //lineEndingIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pGRI->getKey(),lineEndingIdToKeyMap));
      lol.addGlobalRenderInformation(pGRI);
    }

  // fix the references
  SBMLDocumentLoader::convertRenderInformationReferencesIds<CLGlobalRenderInformation>(lol.getListOfGlobalRenderInformationObjects(), idToKeyMap);
  // fix the color ids, gradient ids and line ending ids.
  /*
  std::map<std::string,std::map<std::string,std::string> >::const_iterator mapPos;
  std::map<std::string,std::map<std::string,std::string> > expandedColorIdToKeyMapMap, expandedGradientIdToKeyMapMap, expandedLineEndingIdToKeyMapMap;
  std::map<std::string,std::map<std::string,std::string> > tmpMap1,tmpMap2,tmpMap3;
  for(i=0;i < iMax; ++i)
  {
      pGRI=dynamic_cast<CLGlobalRenderInformation*>(lol.getRenderInformation(i));
      assert(pGRI != NULL);

      std::set<std::string> chain;
      SBMLDocumentLoader::expandIdToKeyMaps<CLGlobalRenderInformation>(pGRI,
                         lol.getListOfGlobalRenderInformationObjects(),
                         expandedColorIdToKeyMapMap,
                         expandedGradientIdToKeyMapMap,
                         expandedLineEndingIdToKeyMapMap,
                         colorIdToKeyMapMap,
                         gradientIdToKeyMapMap,
                         lineEndingIdToKeyMapMap,
                         chain,
                         tmpMap1,
                         tmpMap2,
                         tmpMap3
                  );
      SBMLDocumentLoader::convertPropertyKeys<CLGlobalRenderInformation>(pGRI,expandedColorIdToKeyMapMap[pGRI->getKey()],expandedGradientIdToKeyMapMap[pGRI->getKey()],expandedLineEndingIdToKeyMapMap[pGRI->getKey()]);
  }
      */
#endif /* USE_CRENDER_EXTENSION */
  //convert the map as used by the CLxxx constructors
  std::map<std::string, std::string> modelmap;

  std::string s1, s2;
  std::map<CCopasiObject*, SBase*>::const_iterator it;
  std::map<CCopasiObject*, SBase*>::const_iterator itEnd = copasimodelmap.end();

  for (it = copasimodelmap.begin(); it != itEnd; ++it)
    {
      s1 = SBMLUtils::getIdFromSBase(it->second);

      if (it->first)
        s2 = it->first->getKey();
      else
        s2 = "";

      if ((s1 != "") && (s2 != ""))
        modelmap[s1] = s2;
    }

  //iterate through list of layouts
  iMax = sbmlList.size();

  for (i = 0; i < iMax; ++i)
    {
      std::map<std::string, std::string> layoutmap;
      const Layout* tmp
        = dynamic_cast<const Layout*>(sbmlList.get(i));

      if (tmp)
        {
#ifdef USE_CRENDER_EXTENSION
          //CLayout * pLayout = createLayout(*tmp, modelmap, layoutmap,idToKeyMap,expandedColorIdToKeyMapMap,expandedGradientIdToKeyMapMap,expandedLineEndingIdToKeyMapMap);
          CLayout * pLayout = createLayout(*tmp, modelmap, layoutmap, idToKeyMap);
#else
          CLayout * pLayout = createLayout(*tmp, modelmap, layoutmap);
#endif /* USE_CRENDER_EXTENSION */
          lol.addLayout(pLayout, layoutmap);
        }
    }

  //TODO: the layout object should be added to the copasimodelmap. However,
  //if this is done, the object also need to be removed if necessary in the
  //sbml exporter (see comment in CListOfLayouts::exportToSBML()).
}
示例#3
0
//static
void SBMLUtils::collectIds(Model* pModel, std::map<std::string, const SBase*>& ids, std::map<std::string, const SBase*>& metaIds)
{
  if (pModel != NULL)
    {
      // the model itself
      SBase* pSBase = NULL;
      std::string id;

      if (pModel->isSetId())
        {
          id = pModel->getId();

          if (ids.find(id) == ids.end())
            {
              ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
            }
          else
            {
              CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
            }
        }

      if (pModel->isSetMetaId())
        {
          id = pModel->getMetaId();

          if (metaIds.find(id) == metaIds.end())
            {
              metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
            }
          else
            {
              CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
            }
        }

      // ListOfFunctionDefinitions
      pSBase = pModel->getListOfFunctionDefinitions();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // all FunctionDefinitions
          unsigned int i, iMax = pModel->getListOfFunctionDefinitions()->size();

          for (i = 0; i < iMax; ++i)
            {
              pSBase = pModel->getListOfFunctionDefinitions()->get(i);

              if (pSBase->isSetId())
                {
                  id = pSBase->getId();

                  if (ids.find(id) == ids.end())
                    {
                      ids.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                    }
                }

              if (pSBase->isSetMetaId())
                {
                  id = pSBase->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }
            }
        }

      // ListOfUnitDefinition
      pSBase = pModel->getListOfUnitDefinitions();

      if (pSBase != NULL)
        {
          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // all UnitDefinitions
          // for each UnitDefinition: ListOfUnits, each Unit in ListOfUnits
          unsigned int i, iMax = pModel->getListOfUnitDefinitions()->size();

          for (i = 0; i < iMax; ++i)
            {
              /* UnitDefinitions have their ids in a different namespace
                 so we only consider meta ids.
                 */
              UnitDefinition* pUDef = pModel->getUnitDefinition(i);
              assert(pUDef != NULL);

              if (pUDef->isSetMetaId())
                {
                  id = pUDef->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pUDef));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }

              ListOf* pList = pUDef->getListOfUnits();

              if (pList != NULL)
                {
                  if (pList->isSetMetaId())
                    {
                      id = pList->getMetaId();

                      if (metaIds.find(id) == metaIds.end())
                        {
                          metaIds.insert(std::pair<const std::string, const SBase*>(id, pList));
                        }
                      else
                        {
                          CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                        }
                    }

                  unsigned j, jMax = pList->size();

                  for (j = 0; j < jMax; ++j)
                    {
                      pSBase = pList->get(j);
                      assert(pSBase != NULL);

                      if (pSBase->isSetMetaId())
                        {
                          id = pSBase->getMetaId();

                          if (metaIds.find(id) == metaIds.end())
                            {
                              metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                            }
                          else
                            {
                              CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                            }
                        }
                    }
                }
            }
        }

      // ListOfCompartmentTypes
      pSBase = pModel->getListOfCompartmentTypes();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // each compartment type
          unsigned int i, iMax = pModel->getListOfCompartmentTypes()->size();

          for (i = 0; i < iMax; ++i)
            {
              pSBase = pModel->getCompartmentType(i);
              assert(pSBase != NULL);

              if (pSBase->isSetId())
                {
                  id = pSBase->getId();

                  if (ids.find(id) == ids.end())
                    {
                      ids.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                    }
                }

              if (pSBase->isSetMetaId())
                {
                  id = pSBase->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }
            }
        }

      // ListOfSpeciesTypes
      pSBase = pModel->getListOfSpeciesTypes();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // each species type
          unsigned int i, iMax = pModel->getListOfSpeciesTypes()->size();

          for (i = 0; i < iMax; ++i)
            {
              pSBase = pModel->getSpeciesType(i);
              assert(pSBase != NULL);

              if (pSBase->isSetId())
                {
                  id = pSBase->getId();

                  if (ids.find(id) == ids.end())
                    {
                      ids.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                    }
                }

              if (pSBase->isSetMetaId())
                {
                  id = pSBase->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }
            }
        }

      // ListOfCompartments
      pSBase = pModel->getListOfCompartments();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // all compartments
          unsigned int i, iMax = pModel->getListOfCompartments()->size();

          for (i = 0; i < iMax; ++i)
            {
              pSBase = pModel->getCompartment(i);
              assert(pSBase != NULL);

              if (pSBase->isSetId())
                {
                  id = pSBase->getId();

                  if (ids.find(id) == ids.end())
                    {
                      ids.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                    }
                }

              if (pSBase->isSetMetaId())
                {
                  id = pSBase->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }
            }
        }

      // ListOfSpecies
      pSBase = pModel->getListOfSpecies();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // all species
          unsigned int i, iMax = pModel->getListOfSpecies()->size();

          for (i = 0; i < iMax; ++i)
            {
              pSBase = pModel->getSpecies(i);
              assert(pSBase != NULL);

              if (pSBase->isSetId())
                {
                  id = pSBase->getId();

                  if (ids.find(id) == ids.end())
                    {
                      ids.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                    }
                }

              if (pSBase->isSetMetaId())
                {
                  id = pSBase->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }
            }
        }

      // ListOfParameters
      pSBase = pModel->getListOfParameters();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // each parameter
          unsigned int i, iMax = pModel->getListOfParameters()->size();

          for (i = 0; i < iMax; ++i)
            {
              pSBase = pModel->getParameter(i);
              assert(pSBase != NULL);

              if (pSBase->isSetId())
                {
                  id = pSBase->getId();

                  if (ids.find(id) == ids.end())
                    {
                      ids.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                    }
                }

              if (pSBase->isSetMetaId())
                {
                  id = pSBase->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }
            }
        }

      // ListOfInitialAssignments
      pSBase = pModel->getListOfInitialAssignments();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // each initial assignment
          unsigned int i, iMax = pModel->getListOfInitialAssignments()->size();

          for (i = 0; i < iMax; ++i)
            {
              pSBase = pModel->getInitialAssignment(i);
              assert(pSBase != NULL);

              // initial assignments have no ids
              if (pSBase->isSetMetaId())
                {
                  id = pSBase->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }
            }
        }

      // ListOfRules
      pSBase = pModel->getListOfRules();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // each rule
          unsigned int i, iMax = pModel->getListOfRules()->size();

          for (i = 0; i < iMax; ++i)
            {
              pSBase = pModel->getRule(i);
              assert(pSBase != NULL);

              // rules don't have ids
              if (pSBase->isSetMetaId())
                {
                  id = pSBase->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }
            }
        }

      // ListOfConstraints
      pSBase = pModel->getListOfConstraints();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // each constraint
          unsigned int i, iMax = pModel->getListOfConstraints()->size();

          for (i = 0; i < iMax; ++i)
            {
              pSBase = pModel->getConstraint(i);
              assert(pSBase != NULL);

              // constraints don't have ids
              if (pSBase->isSetMetaId())
                {
                  id = pSBase->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }
            }
        }

      // ListOfReactions
      pSBase = pModel->getListOfReactions();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // all reactions
          unsigned int i, iMax = pModel->getListOfReactions()->size();

          for (i = 0; i < iMax; ++i)
            {
              Reaction* pReaction = pModel->getReaction(i);
              assert(pReaction != NULL);

              if (pReaction->isSetId())
                {
                  id = pReaction->getId();

                  if (ids.find(id) == ids.end())
                    {
                      ids.insert(std::pair<const std::string, const SBase*>(id, pReaction));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                    }
                }

              if (pReaction->isSetMetaId())
                {
                  id = pReaction->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pReaction));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }

              // for each reaction: ListOfSubstrates, each substrate, ListOfProducts, each
              // Product, ListOfModifieres, each modifier, KineticLaw, ListOfparameters,
              // each parameter
              if (pReaction->getListOfReactants() != NULL)
                {
                  pSBase = pReaction->getListOfReactants();

                  if (pSBase->isSetMetaId())
                    {
                      id = pSBase->getMetaId();

                      if (metaIds.find(id) == metaIds.end())
                        {
                          metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                        }
                      else
                        {
                          CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                        }
                    }

                  unsigned int j, jMax = pReaction->getListOfReactants()->size();

                  for (j = 0; j < jMax; ++j)
                    {
                      pSBase = pReaction->getReactant(j);
                      assert(pSBase != NULL);

                      // since L2V2 species references can have ids
                      if (pSBase->isSetId())
                        {
                          id = pSBase->getId();

                          if (ids.find(id) == ids.end())
                            {
                              ids.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                            }
                          else
                            {
                              CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                            }
                        }

                      if (pSBase->isSetMetaId())
                        {
                          id = pSBase->getMetaId();

                          if (metaIds.find(id) == metaIds.end())
                            {
                              metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                            }
                          else
                            {
                              CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                            }
                        }
                    }
                }

              if (pReaction->getListOfProducts() != NULL)
                {
                  pSBase = pReaction->getListOfProducts();

                  if (pSBase->isSetMetaId())
                    {
                      id = pSBase->getMetaId();

                      if (metaIds.find(id) == metaIds.end())
                        {
                          metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                        }
                      else
                        {
                          CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                        }
                    }

                  unsigned int j, jMax = pReaction->getListOfProducts()->size();

                  for (j = 0; j < jMax; ++j)
                    {
                      pSBase = pReaction->getProduct(j);
                      assert(pSBase != NULL);

                      // since L2V2 species references can have ids
                      if (pSBase->isSetId())
                        {
                          id = pSBase->getId();

                          if (ids.find(id) == ids.end())
                            {
                              ids.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                            }
                          else
                            {
                              CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                            }
                        }

                      if (pSBase->isSetMetaId())
                        {
                          id = pSBase->getMetaId();

                          if (metaIds.find(id) == metaIds.end())
                            {
                              metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                            }
                          else
                            {
                              CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                            }
                        }
                    }
                }

              if (pReaction->getListOfModifiers() != NULL)
                {
                  pSBase = pReaction->getListOfModifiers();

                  if (pSBase->isSetMetaId())
                    {
                      id = pSBase->getMetaId();

                      if (metaIds.find(id) == metaIds.end())
                        {
                          metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                        }
                      else
                        {
                          CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                        }
                    }

                  unsigned int j, jMax = pReaction->getListOfModifiers()->size();

                  for (j = 0; j < jMax; ++j)
                    {
                      pSBase = pReaction->getModifier(j);
                      assert(pSBase != NULL);

                      // since L2V2 species references can have ids
                      if (pSBase->isSetId())
                        {
                          id = pSBase->getId();

                          if (ids.find(id) == ids.end())
                            {
                              ids.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                            }
                          else
                            {
                              CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                            }
                        }

                      if (pSBase->isSetMetaId())
                        {
                          id = pSBase->getMetaId();

                          if (metaIds.find(id) == metaIds.end())
                            {
                              metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                            }
                          else
                            {
                              CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                            }
                        }
                    }
                }

              KineticLaw* pKLaw = pReaction->getKineticLaw();

              if (pKLaw != NULL)
                {
                  if (pKLaw->isSetMetaId())
                    {
                      id = pKLaw->getMetaId();

                      if (metaIds.find(id) == metaIds.end())
                        {
                          metaIds.insert(std::pair<const std::string, const SBase*>(id, pKLaw));
                        }
                      else
                        {
                          CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                        }
                    }

                  pSBase = pKLaw->getListOfParameters();

                  if (pSBase != NULL)
                    {
                      if (pSBase->isSetMetaId())
                        {
                          id = pSBase->getMetaId();

                          if (metaIds.find(id) == metaIds.end())
                            {
                              metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                            }
                          else
                            {
                              CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                            }
                        }

                      unsigned int j, jMax = pKLaw->getListOfParameters()->size();

                      for (j = 0; j < jMax; ++j)
                        {
                          pSBase = pKLaw->getParameter(j);
                          assert(pSBase != NULL);

                          // local parameters have their ids in a
                          // different namespace
                          if (pSBase->isSetMetaId())
                            {
                              id = pSBase->getMetaId();

                              if (metaIds.find(id) == metaIds.end())
                                {
                                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                                }
                              else
                                {
                                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                                }
                            }
                        }
                    }
                }
            }
        }

      // ListOfEvents
      pSBase = pModel->getListOfEvents();

      if (pSBase != NULL)
        {
          if (pSBase->isSetId())
            {
              id = pSBase->getId();

              if (ids.find(id) == ids.end())
                {
                  ids.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                }
            }

          if (pSBase->isSetMetaId())
            {
              id = pSBase->getMetaId();

              if (metaIds.find(id) == metaIds.end())
                {
                  metaIds.insert(std::pair<const std::string, const SBase*>(id, pModel));
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                }
            }

          // each event
          unsigned int i, iMax = pModel->getListOfEvents()->size();

          for (i = 0; i < iMax; ++i)
            {
              Event* pEvent = pModel->getEvent(i);
              assert(pEvent != NULL);

              if (pEvent->isSetId())
                {
                  id = pEvent->getId();

                  if (ids.find(id) == ids.end())
                    {
                      ids.insert(std::pair<const std::string, const SBase*>(id, pEvent));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::EXCEPTION, MCSBML + 68, id.c_str());
                    }
                }

              if (pEvent->isSetMetaId())
                {
                  id = pEvent->getMetaId();

                  if (metaIds.find(id) == metaIds.end())
                    {
                      metaIds.insert(std::pair<const std::string, const SBase*>(id, pEvent));
                    }
                  else
                    {
                      CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                    }
                }

              // in each event Trigger,Delay,ListOfEventAssignments, each event assignment
              if (pEvent->isSetTrigger())
                {
                  pSBase = pEvent->getTrigger();
                  assert(pSBase != NULL);

                  if (pSBase->isSetMetaId())
                    {
                      id = pSBase->getMetaId();

                      if (metaIds.find(id) == metaIds.end())
                        {
                          metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                        }
                      else
                        {
                          CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                        }
                    }
                }

              if (pEvent->isSetDelay())
                {
                  pSBase = pEvent->getDelay();
                  assert(pSBase != NULL);

                  if (pSBase->isSetMetaId())
                    {
                      id = pSBase->getMetaId();

                      if (metaIds.find(id) == metaIds.end())
                        {
                          metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                        }
                      else
                        {
                          CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                        }
                    }
                }

              if (pEvent->getListOfEventAssignments() != NULL)
                {
                  pSBase = pEvent->getListOfEventAssignments();

                  if (pSBase->isSetMetaId())
                    {
                      id = pSBase->getMetaId();

                      if (metaIds.find(id) == metaIds.end())
                        {
                          metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                        }
                      else
                        {
                          CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                        }
                    }

                  unsigned int j, jMax = pEvent->getListOfEventAssignments()->size();

                  for (j = 0; j < jMax; ++j)
                    {
                      pSBase = pEvent->getEventAssignment(j);
                      assert(pSBase != NULL);

                      if (pSBase->isSetMetaId())
                        {
                          id = pSBase->getMetaId();

                          if (metaIds.find(id) == metaIds.end())
                            {
                              metaIds.insert(std::pair<const std::string, const SBase*>(id, pSBase));
                            }
                          else
                            {
                              CCopasiMessage(CCopasiMessage::WARNING, MCSBML + 67, id.c_str());
                            }
                        }
                    }
                }
            }
        }
    }
}