COPASI API  4.16.103
CReportDefinitionVector.cpp
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/report/CReportDefinitionVector.cpp,v $
3  $Revision: 1.23 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2011/09/16 12:12:08 $
7  End CVS Header */
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 // ReportDefinitionVector.cpp: implementation of the CReportDefinitionVector class.
24 //
25 //////////////////////////////////////////////////////////////////////
26 
27 #include "copasi.h"
29 #include "CKeyFactory.h"
31 
32 //////////////////////////////////////////////////////////////////////
33 // Construction/Destruction
34 //////////////////////////////////////////////////////////////////////
35 
37  const CCopasiContainer * pParent):
38  CCopasiVectorN< CReportDefinition >(name, pParent),
39  mKey(CCopasiRootContainer::getKeyFactory()->add("CReportDefinitionVector", this))
40 {}
41 
43 {
44  cleanup();
45 }
46 
48 {
50 }
51 
52 const std::string & CReportDefinitionVector::getKey() const
53 {
54  return mKey;
55 }
56 
57 CReportDefinition* CReportDefinitionVector::createReportDefinition(const std::string & name, const std::string & comment)
58 {
59  size_t i;
60 
61  for (i = 0; i < size(); i++)
62  if ((*this)[i]->getObjectName() == name)
63  return NULL; // duplicate name
64 
65  CReportDefinition* pNewReportDef = new CReportDefinition(name, this);
66  pNewReportDef->setComment(comment);
67  pNewReportDef->setObjectName(name);
68 
69  add(pNewReportDef);
70  return pNewReportDef;
71 }
72 
74 {
75  CReportDefinition* pRep =
77  size_t index = this->CCopasiVector<CReportDefinition>::getIndex(pRep);
78 
79  if (index == C_INVALID_INDEX)
80  return false;
81 
83 
84  //pdelete(pRep); //TODO: propably a memory leak, may be not
85 
86  return true;
87 }
bool remove(const std::string &key)
virtual size_t size() const
bool removeReportDefinition(const std::string &key)
CCopasiObject * get(const std::string &key)
#define C_INVALID_INDEX
Definition: copasi.h:222
CReportDefinitionVector(const std::string &name="ReportDefinitions", const CCopasiContainer *pParent=NULL)
virtual const std::string & getKey() const
virtual bool add(const CReportDefinition &src)
void setComment(const std::string &comment)
CReportDefinition * createReportDefinition(const std::string &name, const std::string &comment)
virtual void remove(const size_t &index)
virtual size_t getIndex(const CCopasiObject *pObject) const
static CKeyFactory * getKeyFactory()
bool setObjectName(const std::string &name)