COPASI API  4.16.103
CDataEntity.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/layoutUI/CDataEntity.cpp,v $
3 // $Revision: 1.15 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2012/04/23 21:10:43 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 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 #include <algorithm>
24 
25 #include "CDataEntity.h"
26 
28 {
29  mTime = 0.0;
30 }
31 
33 {
34  mTime = t;
35 }
36 
38  mTime(src.mTime),
39  mSpeciesValueMap(src.mSpeciesValueMap),
40  mOrigValueMap(src.mOrigValueMap)
41 {}
42 
43 void CDataEntity::putValueForSpecies(std::string nodeKey, C_FLOAT64 value)
44 {
45  mSpeciesValueMap.erase(nodeKey); // delete old value
46  mSpeciesValueMap.insert(std::pair<std::string, C_FLOAT64>
47  (nodeKey, value));
48 }
49 
50 void CDataEntity::putOrigValueForSpecies(std::string nodeKey, C_FLOAT64 value)
51 {
52  mOrigValueMap.erase(nodeKey); // delete old value
53  mOrigValueMap.insert(std::pair<std::string, C_FLOAT64>
54  (nodeKey, value));
55 }
56 
57 // return concentration value for a certain reactant, specified by a key, returns -MAX C_FLOAT64, if key is not present in map
59 {
60  std::map<std::string, C_FLOAT64>::iterator it;
61 
62  it = mSpeciesValueMap.find(nodeKey);
63 
64  if (it != mSpeciesValueMap.end())
65  return (*it).second;
66  else
68 }
69 
71 {
72  std::map<std::string, C_FLOAT64>::iterator it;
73  it = mOrigValueMap.find(nodeKey);
74 
75  if (it != mOrigValueMap.end())
76  return (*it).second;
77  else
79 }
80 
81 std::ostream & operator<<(std::ostream &os, const CDataEntity & de)
82 {
83  os << "time: " << de.mTime << " size: " << std::endl;
84  std::map<std::string, C_FLOAT64>::const_iterator it1;
85  std::map<std::string, C_FLOAT64>::const_iterator it2;
86 
87  for (it1 = de.mSpeciesValueMap.begin() ; it1 != de.mSpeciesValueMap.end() ; it1++)
88  {
89  it2 = de.mOrigValueMap.find((*it1).first);
90 
91  if (it2 != de.mOrigValueMap.end())
92  os << (*it1).first << " : " << (*it1).second << " orig: " << (*it2).second << std::endl;
93  else
94  os << (*it1).first << " : " << (*it1).second << " orig: not found" << std::endl;
95  }
96 
97  //for (int i=0;i<gn.mConnectedCurveIndices.size();i++)
98  // os << gn.mConnectedCurveIndices[i] << std::endl;;
99 
100  return os;
101 }
std::map< std::string, C_FLOAT64 > mOrigValueMap
Definition: CDataEntity.h:36
C_FLOAT64 getValueForSpecies(std::string nodeKey)
Definition: CDataEntity.cpp:58
C_FLOAT64 getOrigValueForSpecies(std::string nodeKey)
Definition: CDataEntity.cpp:70
std::map< std::string, C_FLOAT64 > mSpeciesValueMap
Definition: CDataEntity.h:35
void putOrigValueForSpecies(std::string nodeKey, C_FLOAT64 value)
Definition: CDataEntity.cpp:50
std::ostream & operator<<(std::ostream &os, const CDataEntity &de)
Definition: CDataEntity.cpp:81
C_FLOAT64 mTime
Definition: CDataEntity.h:34
void putValueForSpecies(std::string nodeKey, C_FLOAT64 value)
Definition: CDataEntity.cpp:43
#define C_FLOAT64
Definition: copasi.h:92
#define max(a, b)
Definition: f2c.h:176