COPASI API  4.16.103
COscillationTask.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/oscillation/COscillationTask.cpp,v $
3 // $Revision: 1.2 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/03/07 19:32:04 $
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 #include "copasi.h"
20 
21 #include "COscillationTask.h"
22 #include "COscillationProblem.h"
23 #include "COscillationMethod.h"
24 //#include "report/CKeyFactory.h"
25 #include "report/CReport.h"
26 
27 #include "model/CModel.h"
28 #include "model/CState.h"
29 
30 const unsigned int COscillationTask::ValidMethods[] =
31 {
32  CCopasiMethod::oscillationIntegrate,
34 };
35 
37  const CCopasiContainer * pParent):
38  CCopasiTask(type, pParent)
39 {
40  mpProblem = new COscillationProblem(type, this);
42  this->add(mpMethod, true);
44 }
45 
47  const CCopasiContainer * pParent):
48  CCopasiTask(src, pParent)
49 {
52  this->add(mpMethod, true);
54 }
55 
57 {cleanup();}
58 
60 
62 {
63  bool success = CCopasiTask::setCallBack(pCallBack);
64 
65  if (!mpProblem->setCallBack(pCallBack)) success = false;
66 
67  if (!mpMethod->setCallBack(pCallBack)) success = false;
68 
69  return success;
70 }
71 
73  COutputHandler * pOutputHandler,
74  std::ostream * pOstream)
75 {
76  COscillationProblem * pProblem = dynamic_cast<COscillationProblem *>(mpProblem);
77  COscillationMethod * pMethod = dynamic_cast<COscillationMethod *>(mpMethod);
78 
79  if (!pProblem || !pMethod) return false;
80 
81  //initialize reporting
82  bool success = true;
83 
84  if (!CCopasiTask::initialize(of, pOutputHandler, pOstream)) success = false;
85 
86  //if (!mReport.open(pOstream)) success = false;
87  //if (!mReport.compile()) success = false;
88 
89  if (!pProblem->initialize()) success = false;
90 
91  pMethod->setProblem(pProblem);
92  // if (!pMethod->initialize()) return false;
93 
94  return success;
95 }
96 
97 bool COscillationTask::process(const bool & /* useInitialValues */)
98 {
99  COscillationProblem * pProblem = dynamic_cast<COscillationProblem *>(mpProblem);
100  COscillationMethod * pMethod = dynamic_cast<COscillationMethod *>(mpMethod);
101 
102  if (!pProblem || !pMethod) return false;
103 
105 
107 
108  bool success = pMethod->run();
109 
111 
112  return success;
113 }
114 
115 bool COscillationTask::setMethodType(const int & type)
116 {
118 
119  if (mpMethod->getSubType() == Type) return true;
120 
121  pdelete(mpMethod);
122 
123  mpMethod = createMethod(Type);
124  this->add(mpMethod, true);
125 
126  return true;
127 }
128 
129 // virtual
131 {
133 
135 }
virtual bool setCallBack(CProcessReport *pCallBack)
CCopasiMethod * mpMethod
Definition: CCopasiTask.h:239
#define pdelete(p)
Definition: copasi.h:215
static unsigned C_INT32 ValidMethods[]
virtual bool initialize(const OutputFlag &of, COutputHandler *pOutputHandler, std::ostream *pOstream)
virtual bool setCallBack(CProcessReport *pCallBack)
virtual bool setMethodType(const int &type)
void setProblem(COscillationProblem *problem)
virtual bool setCallBack(CProcessReport *pCallBack)
virtual bool initialize(const OutputFlag &of, COutputHandler *pOutputHandler, std::ostream *pOstream)
virtual void output(const COutputInterface::Activity &activity)
const CCopasiMethod::SubType & getSubType() const
virtual bool isValidProblem(const CCopasiProblem *pProblem)
CCopasiProblem * mpProblem
Definition: CCopasiTask.h:234
COscillationTask(const CCopasiTask::Type &type, const CCopasiContainer *pParent)
virtual bool run()=0
virtual bool process(const bool &useInitialValues)
static COscillationMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::oscillationIntegrate)
virtual CCopasiMethod * createMethod(const int &type) const
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
virtual bool setCallBack(CProcessReport *pCallBack)