COPASI API  4.16.103
CReportDefinition.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/report/CReportDefinition.cpp,v $
3 // $Revision: 1.47 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2012/04/20 12:08:24 $
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 /**
24  * CReportDefinition class.
25  * This class describes the Report Definition
26  *
27  * Created for Copasi by Mudita Singhal
28  */
29 
30 #include "copasi.h"
31 
32 #include "CKeyFactory.h"
33 #include "CReportDefinition.h"
34 #include "CReport.h"
35 
38 
39 //////////////////////////////////////////////////
40 //
41 //class CReportDefinition
42 //
43 //////////////////////////////////////////////////
44 CReportDefinition::CReportDefinition(const std::string & name,
45  const CCopasiContainer * pParent):
46  CCopasiObject(name, pParent, "ReportDefinition"),
47  mKey(CCopasiRootContainer::getKeyFactory()->add("Report", this)),
48  mComment(""),
49  mTaskType(CCopasiTask::timeCourse),
50  mSeparator("\t"),
51  mTable(true),
52  mbTitle(true),
53  mPrecision(6)
54 {}
55 
57  const CCopasiContainer * pParent):
58  CCopasiObject(src, pParent),
59  mKey(CCopasiRootContainer::getKeyFactory()->add("Report", this)),
60  mComment(src.mComment),
61  mTaskType(src.mTaskType),
62  mSeparator(src.mSeparator),
63  mTable(src.mTable),
64  mbTitle(src.mbTitle),
65  mPrecision(src.mPrecision),
66  mHeaderVector(src.mHeaderVector),
67  mBodyVector(src.mBodyVector),
68  mFooterVector(src.mFooterVector),
69  mTableVector(src.mTableVector)
70 {}
71 
73 {cleanup();}
74 
76 {
78  mHeaderVector.clear();
79  mBodyVector.clear();
80  mFooterVector.clear();
81  mTableVector.clear();
82 }
83 
84 bool CReportDefinition::preCompileTable(const std::vector< CCopasiContainer * > & listOfContainer)
85 {
86  bool success = true;
87 
88  mHeaderVector.clear();
89  mBodyVector.clear();
90  mFooterVector.clear();
91 
92  std::vector<CRegisteredObjectName>::const_iterator it = mTableVector.begin();
93  std::vector<CRegisteredObjectName>::const_iterator end = mTableVector.end();
94 
95  CCopasiDataModel* pDataModel = getObjectDataModel();
96  CCopasiObject * pObject;
97 
98  for (; it != end; ++it)
99  {
100  pObject = pDataModel->ObjectFromName(listOfContainer, *it);
101 
102  if (pObject != NULL)
103  {
104  addTableElement(pObject);
105  }
106  else
107  {
109  }
110  }
111 
112  return success;
113 }
114 
115 std::vector<CRegisteredObjectName>* CReportDefinition::getBodyAddr()
116 {return &mBodyVector;}
117 
118 std::vector<CRegisteredObjectName>* CReportDefinition::getHeaderAddr()
119 {return &mHeaderVector;}
120 
121 std::vector<CRegisteredObjectName>* CReportDefinition::getFooterAddr()
122 {return &mFooterVector;}
123 
124 std::vector<CRegisteredObjectName>* CReportDefinition::getTableAddr()
125 {return &mTableVector;}
126 
128 {mTaskType = taskType; return true;}
129 
131 {return mTaskType;}
132 
135 
137 {return mSeparator;}
138 
140 {return mbTitle;}
141 
143 {mbTitle = title;}
144 
146 {return mTable;}
147 
149 {mTable = table;}
150 
151 void CReportDefinition::setPrecision(const unsigned C_INT32 & precision)
152 {mPrecision = precision;}
153 
154 const unsigned C_INT32 & CReportDefinition::getPrecision() const
155 {return mPrecision;}
156 
157 const std::string & CReportDefinition::getKey() const
158 {return mKey;}
159 
161 {
162  bool isFirst = false;
163 
164  if ((mHeaderVector.size() == 0) && (mBodyVector.size() == 0))
165  isFirst = true;
166 
167  CCopasiObjectName SeparatorCN(mSeparator.getCN());
168  CCopasiObjectName Title;
169 
170  if (!pObject) return;
171 
172  // Add separator
173  if (!isFirst)
174  {
175  if (mbTitle)
176  mHeaderVector.push_back(SeparatorCN);
177 
178  mBodyVector.push_back(SeparatorCN);
179  }
180 
181  // Determine column title
182  if (pObject->getObjectParent())
183  {
184  Title = pObject->getCN() + ",Property=DisplayName";
185  }
186  else
187  Title =
189 
190  if (mbTitle)
191  mHeaderVector.push_back(Title);
192 
193  mBodyVector.push_back(pObject->getCN());
194 
195  return;
196 }
CCopasiDataModel * getObjectDataModel()
bool remove(const std::string &key)
virtual CCopasiObjectName getCN() const
bool setTaskType(const CCopasiTask::Type &taskType)
const std::string & getObjectName() const
std::vector< CRegisteredObjectName > mHeaderVector
void setTitle(bool title)
std::vector< CRegisteredObjectName > mFooterVector
const CCopasiTask::Type & getTaskType() const
const CCopasiReportSeparator & getSeparator() const
CCopasiTask::Type mTaskType
void setSeparator(const CCopasiReportSeparator &Separator)
#define C_INT32
Definition: copasi.h:90
std::vector< CRegisteredObjectName > mTableVector
const unsigned C_INT32 & getPrecision() const
void setIsTable(bool table)
#define MCCopasiTask
std::vector< CRegisteredObjectName > * getTableAddr()
std::vector< CRegisteredObjectName > * getFooterAddr()
std::vector< CRegisteredObjectName > mBodyVector
virtual const std::string & getKey() const
CReportDefinition(const std::string &name="NoName", const CCopasiContainer *pParent=NULL)
CCopasiReportSeparator mSeparator
static CKeyFactory * getKeyFactory()
void setPrecision(const unsigned C_INT32 &precision)
std::vector< CRegisteredObjectName > * getBodyAddr()
void addTableElement(const CCopasiObject *pObject)
unsigned C_INT32 mPrecision
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
std::vector< CRegisteredObjectName > * getHeaderAddr()
bool preCompileTable(const std::vector< CCopasiContainer * > &listOfContainer=CCopasiContainer::EmptyList)
CCopasiContainer * getObjectParent() const