COPASI API  4.16.103
Public Member Functions | Public Attributes | List of all members
CModelExpansion::SetOfModelElements Class Reference

#include <CModelExpansion.h>

Collaboration diagram for CModelExpansion::SetOfModelElements:
Collaboration graph
[legend]

Public Member Functions

void addCompartment (const CCompartment *x)
 
void addEvent (const CEvent *x)
 
void addGlobalQuantity (const CModelValue *x)
 
void addMetab (const CMetab *x)
 
bool addObject (const CCopasiObject *x)
 
void addReaction (const CReaction *x)
 
bool contains (const CCopasiObject *x) const
 
bool contains (const std::string &key) const
 
void fillComplete (const CModel *pModel)
 
void fillDependencies (const CModel *pModel)
 

Public Attributes

std::set< const CCompartment * > mCompartments
 
std::set< const CEvent * > mEvents
 
std::set< const CModelValue * > mGlobalQuantities
 
std::set< const CMetab * > mMetabs
 
std::set< const CReaction * > mReactions
 

Detailed Description

This class describes a set of model elements that are supposed to be duplicated. The second element in each of the pairs is used temporarily to hold the copy.

Definition at line 50 of file CModelExpansion.h.

Member Function Documentation

void CModelExpansion::SetOfModelElements::addCompartment ( const CCompartment x)

Definition at line 21 of file CModelExpansion.cpp.

References mCompartments.

Referenced by CQSpeciesDetail::copy(), ReactionsWidget1::copy(), CModelExpansion::simpleCall(), and CQExpandModelData::slotOK().

22 {
23  mCompartments.insert(x);
24 }
std::set< const CCompartment * > mCompartments
void CModelExpansion::SetOfModelElements::addEvent ( const CEvent x)

Definition at line 41 of file CModelExpansion.cpp.

42 {
43  mEvents.insert(x);
44 }
std::set< const CEvent * > mEvents
void CModelExpansion::SetOfModelElements::addGlobalQuantity ( const CModelValue x)

Definition at line 36 of file CModelExpansion.cpp.

37 {
38  mGlobalQuantities.insert(x);
39 }
std::set< const CModelValue * > mGlobalQuantities
void CModelExpansion::SetOfModelElements::addMetab ( const CMetab x)

Definition at line 26 of file CModelExpansion.cpp.

Referenced by CQSpeciesDetail::copy(), CQCompartment::copy(), and ReactionsWidget1::copy().

27 {
28  mMetabs.insert(x);
29 }
std::set< const CMetab * > mMetabs
bool CModelExpansion::SetOfModelElements::addObject ( const CCopasiObject x)

Definition at line 46 of file CModelExpansion.cpp.

Referenced by CQCompartment::copy(), and CModelExpansion::existDependentEntities().

47 {
48  if (dynamic_cast<const CCompartment*>(x))
49  {
50  addCompartment(dynamic_cast<const CCompartment*>(x));
51  return true;
52  }
53 
54  if (dynamic_cast<const CMetab*>(x))
55  {
56  addMetab(dynamic_cast<const CMetab*>(x));
57  return true;
58  }
59 
60  if (dynamic_cast<const CReaction*>(x))
61  {
62  addReaction(dynamic_cast<const CReaction*>(x));
63  return true;
64  }
65 
66  if (dynamic_cast<const CModelValue*>(x))
67  {
68  addGlobalQuantity(dynamic_cast<const CModelValue*>(x));
69  return true;
70  }
71 
72  if (dynamic_cast<const CEvent*>(x))
73  {
74  addEvent(dynamic_cast<const CEvent*>(x));
75  return true;
76  }
77 
78  return false;
79 }
void addReaction(const CReaction *x)
void addGlobalQuantity(const CModelValue *x)
void addCompartment(const CCompartment *x)
void CModelExpansion::SetOfModelElements::addReaction ( const CReaction x)

Definition at line 31 of file CModelExpansion.cpp.

Referenced by CQCompartment::copy(), and ReactionsWidget1::copy().

32 {
33  mReactions.insert(x);
34 }
std::set< const CReaction * > mReactions
bool CModelExpansion::SetOfModelElements::contains ( const CCopasiObject x) const

Checks whether an object is present in this set

Definition at line 81 of file CModelExpansion.cpp.

Referenced by CModelExpansion::duplicateEvent(), CModelExpansion::duplicateMetab(), CModelExpansion::duplicateReaction(), CModelExpansion::expressionContainsObject(), and CModelExpansion::updateExpression().

82 {
83  if (mCompartments.find(static_cast<const CCompartment*>(x)) != mCompartments.end())
84  return true;
85 
86  if (mMetabs.find(static_cast<const CMetab*>(x)) != mMetabs.end())
87  return true;
88 
89  if (mReactions.find(static_cast<const CReaction*>(x)) != mReactions.end())
90  return true;
91 
92  if (mGlobalQuantities.find(static_cast<const CModelValue*>(x)) != mGlobalQuantities.end())
93  return true;
94 
95  if (mEvents.find(static_cast<const CEvent*>(x)) != mEvents.end())
96  return true;
97 
98  return false;
99 }
std::set< const CEvent * > mEvents
std::set< const CCompartment * > mCompartments
std::set< const CModelValue * > mGlobalQuantities
std::set< const CMetab * > mMetabs
std::set< const CReaction * > mReactions
bool CModelExpansion::SetOfModelElements::contains ( const std::string &  key) const

Definition at line 101 of file CModelExpansion.cpp.

References CKeyFactory::get(), and CCopasiRootContainer::getKeyFactory().

102 {
104 
105  if (tmp)
106  return contains(tmp);
107  else
108  return false;
109 }
CCopasiObject * get(const std::string &key)
bool contains(const CCopasiObject *x) const
static CKeyFactory * getKeyFactory()
void CModelExpansion::SetOfModelElements::fillComplete ( const CModel pModel)

enters all the objects from pModel

Definition at line 184 of file CModelExpansion.cpp.

References CModel::getCompartments(), CModel::getEvents(), CModel::getMetabolites(), CModel::getModelValues(), CModel::getReactions(), and CCopasiVector< T >::size().

Referenced by CModelExpansion::copyCompleteModel().

185 {
186  if (!pModel)
187  return;
188 
189  size_t i;
190 
191  for (i = 0; i < pModel->getCompartments().size(); ++i)
192  addCompartment(pModel->getCompartments()[i]);
193 
194  for (i = 0; i < pModel->getMetabolites().size(); ++i)
195  addMetab(pModel->getMetabolites()[i]);
196 
197  for (i = 0; i < pModel->getReactions().size(); ++i)
198  addReaction(pModel->getReactions()[i]);
199 
200  for (i = 0; i < pModel->getModelValues().size(); ++i)
201  addGlobalQuantity(pModel->getModelValues()[i]);
202 
203  for (i = 0; i < pModel->getEvents().size(); ++i)
204  addEvent(pModel->getEvents()[i]);
205 }
CCopasiVectorN< CEvent > & getEvents()
Definition: CModel.cpp:1110
void addReaction(const CReaction *x)
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
virtual size_t size() const
void addGlobalQuantity(const CModelValue *x)
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
void addCompartment(const CCompartment *x)
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
void CModelExpansion::SetOfModelElements::fillDependencies ( const CModel pModel)

Determines which other object have to be duplicated based on those already present.

Definition at line 111 of file CModelExpansion.cpp.

References CModel::appendDependentModelObjects().

Referenced by CQCompartment::copy(), CModelExpansion::existDependentEntities(), CModelExpansion::simpleCall(), and CQExpandModelData::slotOK().

112 {
113  if (!pModel) return;
114 
115  //create a combined set of all elements we know are to be copied
116  std::set< const CCopasiObject * > combinedSet;
117 
118  std::set<const CCompartment*>::const_iterator itComp;
119 
120  for (itComp = mCompartments.begin(); itComp != mCompartments.end(); ++itComp)
121  {
122  std::set< const CCopasiObject * > tmp = (*itComp)->getDeletedObjects();
123  combinedSet.insert(tmp.begin(), tmp.end());
124  }
125 
126  std::set<const CMetab*>::const_iterator itMetab;
127 
128  for (itMetab = mMetabs.begin(); itMetab != mMetabs.end(); ++itMetab)
129  {
130  std::set< const CCopasiObject * > tmp = (*itMetab)->getDeletedObjects();
131  combinedSet.insert(tmp.begin(), tmp.end());
132  }
133 
134  std::set<const CReaction*>::const_iterator itReac;
135 
136  for (itReac = mReactions.begin(); itReac != mReactions.end(); ++itReac)
137  {
138  std::set< const CCopasiObject * > tmp = (*itReac)->getDeletedObjects();
139  combinedSet.insert(tmp.begin(), tmp.end());
140  }
141 
142  std::set<const CModelValue*>::const_iterator itQuant;
143 
144  for (itQuant = mGlobalQuantities.begin(); itQuant != mGlobalQuantities.end(); ++itQuant)
145  {
146  std::set< const CCopasiObject * > tmp = (*itQuant)->getDeletedObjects();
147  combinedSet.insert(tmp.begin(), tmp.end());
148  }
149 
150  /* Events do not contain any relevant objects.
151  std::set<const CEvent*>::const_iterator itEvent;
152 
153  for (itEvent = mEvents.begin(); itEvent != mEvents.end(); ++itEvent)
154  {
155  std::set< const CCopasiObject * > tmp = (*itEvent)->getDeletedObjects();
156  combinedSet.insert(tmp.begin(), tmp.end());
157  }
158  */
159 
160  //ask the model for the dependencies
161 
162  std::set< const CCopasiObject * > reacs, metabs, comps, values, events;
163  pModel->appendDependentModelObjects(combinedSet, reacs, metabs, comps, values, events);
164 
165  //incorporate the results into the local sets
166  std::set< const CCopasiObject * >::const_iterator it;
167 
168  for (it = reacs.begin(); it != reacs.end(); ++it)
169  addReaction(dynamic_cast<const CReaction*>(*it));
170 
171  for (it = metabs.begin(); it != metabs.end(); ++it)
172  addMetab(dynamic_cast<const CMetab*>(*it));
173 
174  for (it = comps.begin(); it != comps.end(); ++it)
175  addCompartment(dynamic_cast<const CCompartment*>(*it));
176 
177  for (it = values.begin(); it != values.end(); ++it)
178  addGlobalQuantity(dynamic_cast<const CModelValue*>(*it));
179 
180  for (it = events.begin(); it != events.end(); ++it)
181  addEvent(dynamic_cast<const CEvent*>(*it));
182 }
void addReaction(const CReaction *x)
std::set< const CCompartment * > mCompartments
void addGlobalQuantity(const CModelValue *x)
bool appendDependentModelObjects(const std::set< const CCopasiObject * > &candidates, std::set< const CCopasiObject * > &dependentReactions, std::set< const CCopasiObject * > &dependentMetabolites, std::set< const CCopasiObject * > &dependentCompartments, std::set< const CCopasiObject * > &dependentModelValues, std::set< const CCopasiObject * > &dependentEvents) const
Definition: CModel.cpp:2364
void addCompartment(const CCompartment *x)
std::set< const CModelValue * > mGlobalQuantities
std::set< const CMetab * > mMetabs
std::set< const CReaction * > mReactions

Member Data Documentation

std::set<const CCompartment*> CModelExpansion::SetOfModelElements::mCompartments
std::set<const CEvent*> CModelExpansion::SetOfModelElements::mEvents
std::set<const CModelValue*> CModelExpansion::SetOfModelElements::mGlobalQuantities
std::set<const CMetab*> CModelExpansion::SetOfModelElements::mMetabs
std::set<const CReaction*> CModelExpansion::SetOfModelElements::mReactions

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