LIBSBML_EXTERN
void 
copySBaseAttributes(const SBase& source,SBase& target)
{
    target.setMetaId(source.getMetaId());
//    target.setId(source.getId());
//    target.setName(source.getName());
    target.setSBMLDocument(const_cast<SBMLDocument*>(source.getSBMLDocument()));
    target.setSBOTerm(source.getSBOTerm());
    if(source.isSetAnnotation())
    {
      target.setAnnotation(new XMLNode(*const_cast<SBase&>(source).getAnnotation()));
    }
    if(source.isSetNotes())
    {
      target.setNotes(new XMLNode(*const_cast<SBase&>(source).getNotes()));
    }
    if (source.getSBMLNamespaces())
    {
      target.setSBMLNamespaces(source.getSBMLNamespaces());
    }
    List* pCVTerms=target.getCVTerms();
    // first delete all the old CVTerms
    if(pCVTerms)
    {
      while(pCVTerms->getSize()>0)
      {
        CVTerm* object=static_cast<CVTerm*>(pCVTerms->remove(0));
        delete object;
      }
      // add the cloned CVTerms from source
      if(source.getCVTerms()!=NULL)
      {
          unsigned int i=0,iMax=source.getCVTerms()->getSize();
          while(i<iMax)
          {
              target.addCVTerm(static_cast<CVTerm*>(static_cast<CVTerm*>(source.getCVTerms()->get(i))->clone()));
              ++i;
          }
      }
    }
}
Exemple #2
0
// tests whether we are importing global render information
void test000098::test_export_notes()
{
  CPPUNIT_ASSERT(pDataModel != NULL);
  std::istringstream iss(test000098::CPS_MODEL_1);
  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
  std::string s;

  try
    {
      s = pDataModel->exportSBMLToString(NULL, 2, 1);
    }
  catch (...)
    {
      CPPUNIT_ASSERT(false);
    }

  CPPUNIT_ASSERT(!s.empty());
  SBMLReader reader;
  SBMLDocument* pSBMLDocument = NULL;

  try
    {
      pSBMLDocument = reader.readSBMLFromString(s);
    }
  catch (...)
    {
      CPPUNIT_ASSERT(false);
    }

  CPPUNIT_ASSERT(pSBMLDocument != NULL);
  Model* pModel = pSBMLDocument->getModel();
  CPPUNIT_ASSERT(pModel != NULL);
  CPPUNIT_ASSERT(pModel->isSetNotes() == true);
  std::string notes = pModel->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on model") != std::string::npos);

  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
  CPPUNIT_ASSERT(pModel->getNumSpecies() == 1);
  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
  CPPUNIT_ASSERT(pModel->getNumReactions() == 1);
  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
  // compartment
  SBase* pObject = pModel->getCompartment(0);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
  notes = pObject->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on compartment") != std::string::npos);
  // species
  pObject = pModel->getSpecies(0);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
  notes = pObject->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on species") != std::string::npos);
  // parameter
  pObject = pModel->getParameter(0);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
  notes = pObject->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on parameter") != std::string::npos);
  // reaction
  pObject = pModel->getReaction(0);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
  notes = pObject->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on reaction") != std::string::npos);
  // event
  pObject = pModel->getEvent(0);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
  notes = pObject->getNotesString();
  CPPUNIT_ASSERT(!notes.empty());
  CPPUNIT_ASSERT(notes.find("Simple note on event") != std::string::npos);
}