COPASI API  4.16.103
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
CModelParameterGroup Class Reference

#include <CModelParameterGroup.h>

Inheritance diagram for CModelParameterGroup:
Inheritance graph
[legend]
Collaboration diagram for CModelParameterGroup:
Collaboration graph
[legend]

Public Types

typedef std::vector
< CModelParameter * >
::const_iterator 
const_iterator
 
typedef std::vector
< CModelParameter * >
::iterator 
iterator
 
- Public Types inherited from CModelParameter
enum  CompareResult {
  Obsolete, Missing, Modified, Conflict,
  Identical
}
 
enum  Framework { Concentration = 0, ParticleNumbers }
 
enum  Type {
  Model, Compartment, Species, ModelValue,
  ReactionParameter, Reaction, Group, Set,
  unknown
}
 

Public Member Functions

CModelParameteradd (const CModelParameter::Type &type)
 
void add (CModelParameter *pModelParameter)
 
iterator begin ()
 
const_iterator begin () const
 
void clear ()
 
 CModelParameterGroup (CModelParameterGroup *pParent, const CModelParameter::Type &type=CModelParameter::Group)
 
 CModelParameterGroup (const CModelParameterGroup &src, CModelParameterGroup *pParent, const bool &createMissing)
 
virtual void compile ()
 
virtual const CompareResultdiff (const CModelParameter &other, const CModelParameter::Framework &framework, const bool &createMissing=false)
 
iterator end ()
 
const_iterator end () const
 
virtual const CModelParametergetChild (const size_t &index) const
 
CModelParametergetModelParameter (const std::string &cn) const
 
CModelParametergetModelParameter (const std::string &name, const CModelParameter::Type &type) const
 
virtual size_t getNumChildren () const
 
virtual bool refreshFromModel (const bool &modifyExistence)
 
void remove (CModelParameter *pModelParameter)
 
void remove (const size_t &index)
 
size_t size () const
 
virtual bool updateModel ()
 
virtual ~CModelParameterGroup ()
 
- Public Member Functions inherited from CModelParameter
 CModelParameter (CModelParameterGroup *pParent, const CModelParameter::Type &type)
 
 CModelParameter (const CModelParameter &src, CModelParameterGroup *pParent)
 
const CCopasiObjectNamegetCN () const
 
const CompareResultgetCompareResult () const
 
size_t getIndex () const
 
std::string getInitialExpression () const
 
const CExpressiongetInitialExpressionPtr () const
 
CModelgetModel () const
 
virtual std::string getName () const
 
CCopasiObjectgetObject () const
 
CModelParameterGroupgetParent () const
 
CModelParameterSetgetSet () const
 
const CModelEntity::StatusgetSimulationType () const
 
const TypegetType () const
 
const std::string getUnit (const Framework &framework) const
 
virtual const double & getValue (const Framework &framework) const
 
bool isInitialExpressionValid () const
 
bool isReadOnly () const
 
virtual void setCN (const CCopasiObjectName &cn)
 
void setCompareResult (const CompareResult &compareResult)
 
void setInitialExpression (const std::string &initialExpression)
 
void setParent (CModelParameterGroup *pParent)
 
bool setSimulationType (const CModelEntity::Status &simulationType)
 
virtual void setValue (const double &value, const Framework &framework)
 
virtual ~CModelParameter ()
 

Protected Member Functions

void assignGroupContent (const CModelParameterGroup &src, const bool &createMissing)
 
CModelParametercopy (const CModelParameter &src, const bool &createMissing)
 

Private Attributes

std::vector< CModelParameter * > mModelParameters
 

Additional Inherited Members

- Static Public Attributes inherited from CModelParameter
static const char * TypeNames []
 
- Static Protected Member Functions inherited from CModelParameter
static std::string nameFromCN (const CCopasiObjectName &cn)
 
- Protected Attributes inherited from CModelParameter
CRegisteredObjectName mCN
 
CompareResult mCompareResult
 
bool mIsInitialExpressionValid
 
CExpressionmpInitialExpression
 
CCopasiObjectmpObject
 
CModelParameterGroupmpParent
 
CModelEntity::Status mSimulationType
 
Type mType
 
double mValue
 

Detailed Description

Definition at line 17 of file CModelParameterGroup.h.

Member Typedef Documentation

Definition at line 21 of file CModelParameterGroup.h.

Definition at line 20 of file CModelParameterGroup.h.

Constructor & Destructor Documentation

CModelParameterGroup::CModelParameterGroup ( CModelParameterGroup pParent,
const CModelParameter::Type type = CModelParameter::Group 
)

Constructor

Parameters
CModelParameterGroup* pParent
constCModelParameter::Type & type (default: CModelParameter::Group)

Definition at line 11 of file CModelParameterGroup.cpp.

Referenced by add(), and copy().

11  :
12  CModelParameter(pParent, type),
14 {}
std::vector< CModelParameter * > mModelParameters
CModelParameterGroup::CModelParameterGroup ( const CModelParameterGroup src,
CModelParameterGroup pParent,
const bool &  createMissing 
)

Copy constructor

Parameters
constCModelParameterGroup & src
CModelParameterGroup* pParent
constbool & createMissing

Definition at line 16 of file CModelParameterGroup.cpp.

References assignGroupContent().

18  :
19  CModelParameter(src, pParent),
21 {
22  assignGroupContent(src, createMissing);
23 }
std::vector< CModelParameter * > mModelParameters
void assignGroupContent(const CModelParameterGroup &src, const bool &createMissing)
CModelParameterGroup::~CModelParameterGroup ( )
virtual

Destructor

Definition at line 26 of file CModelParameterGroup.cpp.

References clear().

27 {
28  clear();
29 }

Member Function Documentation

CModelParameter * CModelParameterGroup::add ( const CModelParameter::Type type)

Add parameter of the given type to the group and return a pointer to it

Parameters
constCModelParameter::Type & type
Returns
CModelParameter * pParameter

Definition at line 95 of file CModelParameterGroup.cpp.

References CModelParameter::CModelParameter(), CModelParameterGroup(), CModelParameter::Compartment, CModelParameter::Group, CModelParameter::Model, CModelParameter::ModelValue, CModelParameter::Reaction, CModelParameter::ReactionParameter, and CModelParameter::Species.

Referenced by CModelParameterSet::createFromModel().

96 {
97  CModelParameter * pModelParameter = NULL;
98 
99  switch (type)
100  {
101  case Compartment:
102  pModelParameter = new CModelParameterCompartment(this);
103  break;
104 
105  case Species:
106  pModelParameter = new CModelParameterSpecies(this);
107  break;
108 
109  case ReactionParameter:
110  pModelParameter = new CModelParameterReactionParameter(this, type);
111  break;
112 
113  case Model:
114  case ModelValue:
115  pModelParameter = new CModelParameter(this, type);
116  break;
117 
118  case Reaction:
119  case Group:
120  pModelParameter = new CModelParameterGroup(this, type);
121  break;
122 
123  default:
124  return pModelParameter;
125  break;
126  }
127 
128  add(pModelParameter);
129 
130  return pModelParameter;
131 }
CModelParameterGroup(CModelParameterGroup *pParent, const CModelParameter::Type &type=CModelParameter::Group)
CModelParameter * add(const CModelParameter::Type &type)
void CModelParameterGroup::add ( CModelParameter pModelParameter)

Add the given parameter to the group. Note, the parent of the parameter is not updated

Parameters
CModelParameter* pModelParameter

Definition at line 133 of file CModelParameterGroup.cpp.

References mModelParameters.

134 {
135  mModelParameters.push_back(pModelParameter);
136 }
std::vector< CModelParameter * > mModelParameters
void CModelParameterGroup::assignGroupContent ( const CModelParameterGroup src,
const bool &  createMissing 
)
protected

Assign the content of the source group to this, i.e., copy all contained parameters.

Parameters
constCModelParameterGroup & src
constbool & createMissing

Definition at line 31 of file CModelParameterGroup.cpp.

References begin(), clear(), copy(), end(), and CModelParameter::Missing.

Referenced by CModelParameterSet::assignSetContent(), and CModelParameterGroup().

33 {
34  clear();
35 
36  const_iterator itSrc = src.begin();
37  const_iterator endSrc = src.end();
38 
39  for (; itSrc != endSrc; ++itSrc)
40  {
41  if (createMissing ||
42  (*itSrc)->getCompareResult() != Missing)
43  {
44  copy(**itSrc, createMissing);
45  }
46  }
47 }
CModelParameter * copy(const CModelParameter &src, const bool &createMissing)
std::vector< CModelParameter * >::const_iterator const_iterator
CModelParameterGroup::iterator CModelParameterGroup::begin ( )

Retrieve the iterator pointing to the first contained parameter.

Returns
iterator begin

Definition at line 169 of file CModelParameterGroup.cpp.

References mModelParameters.

Referenced by applyValueToParameterSet(), assignGroupContent(), CQParameterOverviewWidget::buildSelectionList(), clear(), compile(), diff(), CModelParameter::getIndex(), getModelParameter(), CQParameterOverviewDM::getRow(), CQParameterOverviewDM::index(), refreshFromModel(), remove(), CCopasiXML::saveModel(), and updateModel().

170 {
171  return mModelParameters.begin();
172 }
std::vector< CModelParameter * > mModelParameters
CModelParameterGroup::const_iterator CModelParameterGroup::begin ( ) const

Retrieve the const_iterator pointing to the first contained parameter.

Returns
const_iterator begin

Definition at line 179 of file CModelParameterGroup.cpp.

References mModelParameters.

180 {
181  return mModelParameters.begin();
182 }
std::vector< CModelParameter * > mModelParameters
void CModelParameterGroup::clear ( )

Clear the contained parameters and delete them.

Definition at line 202 of file CModelParameterGroup.cpp.

References begin(), end(), mModelParameters, and pdelete.

Referenced by assignGroupContent(), CModelParameterSet::createFromModel(), and ~CModelParameterGroup().

203 {
204  // Clear existing model parameters.
205  iterator it = begin();
206  iterator End = end();
207 
208  for (; it != End; ++it)
209  {
210  (*it)->setParent(NULL);
211  pdelete(*it);
212  }
213 
214  mModelParameters.clear();
215 }
#define pdelete(p)
Definition: copasi.h:215
std::vector< CModelParameter * >::iterator iterator
std::vector< CModelParameter * > mModelParameters
void CModelParameterGroup::compile ( )
virtual

Compile the parameter

Reimplemented from CModelParameter.

Definition at line 189 of file CModelParameterGroup.cpp.

References begin(), CModelParameter::compile(), and end().

Referenced by CModelParameterSet::assignSetContent(), CModelParameterSet::CModelParameterSet(), CModelParameterSet::createFromModel(), CQParameterOverviewWidget::enterProtected(), and CModelParameterSet::updateModel().

190 {
192 
193  iterator it = begin();
194  iterator End = end();
195 
196  for (; it != End; ++it)
197  {
198  (*it)->compile();
199  }
200 }
std::vector< CModelParameter * >::iterator iterator
virtual void compile()
CModelParameter * CModelParameterGroup::copy ( const CModelParameter src,
const bool &  createMissing 
)
protected

Copy the existing parameter and add it to the group

Parameters
constCModelParameter & src
constbool & createMissing
Returns
CModelParameter * pCopy

Copy the existing parameter and add it to the group

Parameters
constCModelParameter & src
Returns
CModelParameter * pCopy

Definition at line 54 of file CModelParameterGroup.cpp.

References CModelParameter::CModelParameter(), CModelParameterGroup(), CModelParameter::Compartment, CModelParameter::getType(), CModelParameter::Group, mModelParameters, CModelParameter::Model, CModelParameter::ModelValue, CModelParameter::Reaction, CModelParameter::ReactionParameter, and CModelParameter::Species.

Referenced by assignGroupContent(), and diff().

56 {
57  CModelParameter * pCopy = NULL;
58 
59  switch (src.getType())
60  {
61  case Compartment:
62  pCopy = new CModelParameterCompartment(*static_cast< const CModelParameterCompartment * >(&src), this);
63  break;
64 
65  case Species:
66  pCopy = new CModelParameterSpecies(*static_cast< const CModelParameterSpecies * >(&src), this);
67  break;
68 
69  case ReactionParameter:
70  pCopy = new CModelParameterReactionParameter(*static_cast< const CModelParameterReactionParameter * >(&src), this);
71  break;
72 
73  case Model:
74  case ModelValue:
75  pCopy = new CModelParameter(src, this);
76  break;
77 
78  case Reaction:
79  case Group:
80  pCopy = new CModelParameterGroup(*static_cast< const CModelParameterGroup * >(&src), this, createMissing);
81  break;
82 
83  default:
84  break;
85  }
86 
87  if (pCopy)
88  {
89  mModelParameters.push_back(pCopy);
90  }
91 
92  return pCopy;
93 }
CModelParameterGroup(CModelParameterGroup *pParent, const CModelParameter::Type &type=CModelParameter::Group)
std::vector< CModelParameter * > mModelParameters
const Type & getType() const
const CModelParameter::CompareResult & CModelParameterGroup::diff ( const CModelParameter other,
const CModelParameter::Framework framework,
const bool &  createMissing = false 
)
virtual

Compare the parameter to an other

Parameters
constCModelParameter & other
constCModelParameter::Framework & framework
constbool & createMissing = false

Reimplemented from CModelParameter.

Definition at line 218 of file CModelParameterGroup.cpp.

References begin(), copy(), end(), CModelParameter::getType(), CModelParameter::Group, CModelParameter::Identical, CModelParameter::mCompareResult, CModelParameter::Missing, CModelParameter::Modified, CModelParameter::Obsolete, CModelParameter::Reaction, CModelParameter::Set, and CModelParameter::setCompareResult().

Referenced by CModelParameterSet::compareWithModel(), and CQParameterOverviewWidget::leave().

221 {
222  // We can only work on reactions, groups or sets.
223  assert(other.getType() == Reaction ||
224  other.getType() == Group ||
225  other.getType() == Set);
226 
227  if (mCompareResult == Missing ||
229  {
230  return mCompareResult;
231  }
232 
234 
235  const CModelParameterGroup * pOther = dynamic_cast< const CModelParameterGroup * >(&other);
236 
237  const_iterator itConst = pOther->begin();
238  const_iterator endConst = pOther->end();
239 
240  std::map< CCopasiObjectName, CModelParameter * > Map;
241 
242  for (; itConst != endConst; ++itConst)
243  {
244  Map[(*itConst)->getCN()] = *itConst;
245  }
246 
247  iterator itThis = begin();
248  iterator endThis = end();
249 
250  for (; itThis != endThis; ++itThis)
251  {
252  std::map< CCopasiObjectName, CModelParameter * >::const_iterator itOther = Map.find((*itThis)->getCN());
253 
254  if (itOther == Map.end())
255  {
256  (*itThis)->setCompareResult(Obsolete);
258 
259  continue;
260  }
261 
262  if ((*itThis)->diff(*itOther->second, framework, createMissing) != Identical)
263  {
265  }
266 
267  Map.erase(itOther->first);
268  }
269 
270  if (createMissing)
271  {
272  std::map< CCopasiObjectName, CModelParameter * >::const_iterator itMissing = Map.begin();
273  std::map< CCopasiObjectName, CModelParameter * >::const_iterator endMissing = Map.end();
274 
275  for (; itMissing != endMissing; ++itMissing)
276  {
277  CModelParameter * pMissing = copy(*itMissing->second, createMissing);
278 
279  if (pMissing != NULL)
280  {
281  pMissing->setCompareResult(Missing);
282  }
283 
285  }
286  }
287  else if (Map.size() > 0)
288  {
289  std::map< CCopasiObjectName, CModelParameter * >::const_iterator itMissing = Map.begin();
290  std::map< CCopasiObjectName, CModelParameter * >::const_iterator endMissing = Map.end();
291 
292  for (; itMissing != endMissing; ++itMissing)
293  {
294  if (itMissing->second->getCompareResult() != CModelParameter::Missing)
295  {
297  break;
298  }
299  }
300  }
301 
302  return mCompareResult;
303 }
std::vector< CModelParameter * >::iterator iterator
void setCompareResult(const CompareResult &compareResult)
CModelParameter * copy(const CModelParameter &src, const bool &createMissing)
CompareResult mCompareResult
std::vector< CModelParameter * >::const_iterator const_iterator
const Type & getType() const
CModelParameterGroup::iterator CModelParameterGroup::end ( )

Retrieve the iterator pointing past the last contained parameter.

Returns
iterator end

Definition at line 174 of file CModelParameterGroup.cpp.

References mModelParameters.

Referenced by applyValueToParameterSet(), assignGroupContent(), CQParameterOverviewWidget::buildSelectionList(), clear(), compile(), diff(), CModelParameter::getIndex(), getModelParameter(), CQParameterOverviewDM::getRow(), refreshFromModel(), remove(), CCopasiXML::saveModel(), and updateModel().

175 {
176  return mModelParameters.end();
177 }
std::vector< CModelParameter * > mModelParameters
CModelParameterGroup::const_iterator CModelParameterGroup::end ( ) const

Retrieve the const_iterator pointing past the last contained parameter.

Returns
const_iterator end

Definition at line 184 of file CModelParameterGroup.cpp.

References mModelParameters.

185 {
186  return mModelParameters.end();
187 }
std::vector< CModelParameter * > mModelParameters
const CModelParameter * CModelParameterGroup::getChild ( const size_t &  index) const
virtual

Reimplemented from CModelParameter.

Definition at line 427 of file CModelParameterGroup.cpp.

References mModelParameters, and size().

428 {
429  if (index < size())
430  {
431  return mModelParameters[index];
432  }
433 
434  return NULL;
435 }
std::vector< CModelParameter * > mModelParameters
CModelParameter * CModelParameterGroup::getModelParameter ( const std::string &  cn) const

Retrieve a pointer to the parameter with the given CN

Parameters
conststd::string & cn
Returns
CModelParameter * pModelParameter

Definition at line 370 of file CModelParameterGroup.cpp.

References begin(), end(), getModelParameter(), CModelParameter::Group, CModelParameter::Reaction, and CModelParameter::Set.

Referenced by CQParameterOverviewDM::assignmentData(), CQParameterOverviewWidget::buildSelectionList(), CModelParameterSpecies::compile(), CModelParameterReactionParameter::compile(), getModelParameter(), CModelParameter::refreshFromModel(), and CQParameterOverviewDM::setData().

371 {
372  CModelParameter * pModelParameter = NULL;
373 
374  const_iterator it = begin();
375  const_iterator End = end();
376 
377  for (; it != End && pModelParameter == NULL; ++it)
378  {
379  if (cn == (*it)->getCN())
380  {
381  pModelParameter = *it;
382  }
383  else if ((*it)->getType() == CModelParameter::Reaction ||
384  (*it)->getType() == CModelParameter::Group ||
385  (*it)->getType() == CModelParameter::Set)
386  {
387  pModelParameter = static_cast< const CModelParameterGroup * >(*it)->getModelParameter(cn);
388  }
389  }
390 
391  return pModelParameter;
392 }
CModelParameter * getModelParameter(const std::string &cn) const
std::vector< CModelParameter * >::const_iterator const_iterator
CModelParameter * CModelParameterGroup::getModelParameter ( const std::string &  name,
const CModelParameter::Type type 
) const

Retrieve a pointer to the parameter with the given name and type

Parameters
conststd::string & name
constCModelParameter::Type & type
Returns
CModelParameter * pModelParameter

Definition at line 394 of file CModelParameterGroup.cpp.

References begin(), end(), getModelParameter(), CModelParameter::Group, CModelParameter::Reaction, and CModelParameter::Set.

396 {
397  CModelParameter * pModelParameter = NULL;
398 
399  const_iterator it = begin();
400  const_iterator End = end();
401 
402  for (; it != End && pModelParameter == NULL; ++it)
403  {
404  if (type == (*it)->getType() &&
405  name == (*it)->getName())
406  {
407  pModelParameter = *it;
408  }
409  else if ((*it)->getType() == CModelParameter::Reaction ||
410  (*it)->getType() == CModelParameter::Group ||
411  (*it)->getType() == CModelParameter::Set)
412  {
413  pModelParameter = static_cast< const CModelParameterGroup * >(*it)->getModelParameter(name, type);
414  }
415  }
416 
417  return pModelParameter;
418 }
CModelParameter * getModelParameter(const std::string &cn) const
std::vector< CModelParameter * >::const_iterator const_iterator
size_t CModelParameterGroup::getNumChildren ( ) const
virtual

Reimplemented from CModelParameter.

Definition at line 421 of file CModelParameterGroup.cpp.

References size().

422 {
423  return size();
424 }
bool CModelParameterGroup::refreshFromModel ( const bool &  modifyExistence)
virtual

Refresh the parameter from the corresponding model object

Parameters
constbool & modifyExistence

Reimplemented from CModelParameter.

Definition at line 322 of file CModelParameterGroup.cpp.

References begin(), end(), CModelParameter::Identical, CModelParameter::mCompareResult, CModelParameter::Missing, and CModelParameter::Obsolete.

Referenced by CModel::refreshActiveParameterSet(), and CCopasiDataModel::saveModel().

323 {
324  bool success = true;
325 
326  if (modifyExistence)
327  {
329  {
330  delete this;
331 
332  return true;
333  }
334 
336  {
338  }
339  }
340 
341  iterator it = begin();
342  iterator End = end();
343 
344  std::vector< CModelParameter * > ToBeDeleted;
345 
346  for (; it != End; ++it)
347  {
348  if (modifyExistence &&
349  (*it)->getCompareResult() == CModelParameter::Obsolete)
350  {
351  ToBeDeleted.push_back(*it);
352  }
353  else
354  {
355  success &= (*it)->refreshFromModel(modifyExistence);
356  }
357  }
358 
359  std::vector< CModelParameter * >::iterator itDelete = ToBeDeleted.begin();
360  std::vector< CModelParameter * >::iterator endDelete = ToBeDeleted.end();
361 
362  for (; itDelete != endDelete; ++itDelete)
363  {
364  success &= (*itDelete)->refreshFromModel(modifyExistence);
365  }
366 
367  return success;
368 }
std::vector< CModelParameter * >::iterator iterator
CompareResult mCompareResult
void CModelParameterGroup::remove ( CModelParameter pModelParameter)

Remove the given parameter from the group. Note, the parameter is not deleted.

Parameters
CModelParameter* pModelParameter

Definition at line 138 of file CModelParameterGroup.cpp.

References begin(), end(), and mModelParameters.

Referenced by CModelParameter::~CModelParameter().

139 {
140  iterator it = begin();
141  iterator End = end();
142 
143  for (; it != End; ++it)
144  {
145  if (*it == pModelParameter)
146  {
147  mModelParameters.erase(it);
148  break;
149  }
150  }
151 }
std::vector< CModelParameter * >::iterator iterator
std::vector< CModelParameter * > mModelParameters
void CModelParameterGroup::remove ( const size_t &  index)

Remove the indexed parameter from the group and delete it

Parameters
constsize_t & index

Definition at line 153 of file CModelParameterGroup.cpp.

References mModelParameters, and pdelete.

154 {
155  if (index < mModelParameters.size())
156  {
157  iterator it = mModelParameters.begin() + index;
158  pdelete(*it);
159 
160  mModelParameters.erase(it);
161  }
162 }
#define pdelete(p)
Definition: copasi.h:215
std::vector< CModelParameter * >::iterator iterator
std::vector< CModelParameter * > mModelParameters
size_t CModelParameterGroup::size ( ) const

Retrieve the size of the group

Returns
size_t size

Definition at line 164 of file CModelParameterGroup.cpp.

References mModelParameters.

Referenced by getChild(), getNumChildren(), and CQParameterOverviewDM::index().

165 {
166  return mModelParameters.size();
167 }
std::vector< CModelParameter * > mModelParameters
bool CModelParameterGroup::updateModel ( )
virtual

Update the corresponding model object with the current parameter settings

Reimplemented from CModelParameter.

Reimplemented in CModelParameterSet.

Definition at line 306 of file CModelParameterGroup.cpp.

References begin(), and end().

Referenced by CModelParameterSet::updateModel().

307 {
308  bool success = true;
309 
310  iterator it = begin();
311  iterator End = end();
312 
313  for (; it != End; ++it)
314  {
315  success &= (*it)->updateModel();
316  }
317 
318  return success;
319 }
std::vector< CModelParameter * >::iterator iterator

Member Data Documentation

std::vector< CModelParameter * > CModelParameterGroup::mModelParameters
private

A vector of pointer to the contained parameters.

Definition at line 179 of file CModelParameterGroup.h.

Referenced by add(), begin(), clear(), copy(), end(), getChild(), remove(), and size().


The documentation for this class was generated from the following files: