COPASI API  4.16.103
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
CScanItem Class Referenceabstract

#include <CScanMethod.h>

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

Public Member Functions

size_t getNumSteps () const
 
const CCopasiObjectgetObject () const
 
bool isFinished () const
 
virtual bool isNesting () const
 
virtual bool isValidScanItem (const bool &continueFromCurrentState)
 
void reset ()
 
void restoreValue () const
 
virtual void step ()=0
 
void storeValue ()
 
virtual ~CScanItem ()
 

Static Public Member Functions

static CScanItemcreateScanItemFromParameterGroup (CCopasiParameterGroup *si, CRandom *rg, const bool &continueFromCurrentState)
 

Protected Member Functions

 CScanItem (CCopasiParameterGroup *si, const bool &continueFromCurrentState)
 

Protected Attributes

bool mFlagFinished
 
size_t mIndex
 
bool mIsStateVariable
 
size_t mNumSteps
 
CCopasiObjectmpInitialObject
 
CCopasiObjectmpObject
 
C_FLOAT64 mStoreValue
 

Private Member Functions

 CScanItem ()
 

Detailed Description

Definition at line 36 of file CScanMethod.h.

Constructor & Destructor Documentation

virtual CScanItem::~CScanItem ( )
inlinevirtual

Definition at line 72 of file CScanMethod.h.

72 {};
CScanItem::CScanItem ( CCopasiParameterGroup si,
const bool &  continueFromCurrentState 
)
protected

Definition at line 83 of file CScanMethod.cpp.

References CModel::getCorrespondingTransientObject(), CCopasiDataModel::getDataObject(), CCopasiObject::getObjectAncestor(), CCopasiObject::getObjectDataModel(), CCopasiParameterGroup::getValue(), CModel::isStateVariable(), CCopasiObject::isValueDbl(), mIsStateVariable, mNumSteps, mpInitialObject, mpObject, CCopasiParameter::Value::pCN, and CCopasiParameter::Value::pUINT.

84  :
85  mNumSteps(0),
86  mpObject(NULL),
87  mpInitialObject(NULL),
88  mStoreValue(0.0),
89  mIndex(0),
90  mFlagFinished(false),
91  mIsStateVariable(false)
92 {
93  assert(si != NULL);
94 
95  mNumSteps = * si->getValue("Number of steps").pUINT;
96 
97  std::string tmpString = * si->getValue("Object").pCN;
98  CCopasiDataModel* pDataModel = si->getObjectDataModel();
99  assert(pDataModel != NULL);
100  CCopasiObject * tmpObject = pDataModel->getDataObject(tmpString);
101 
102  if (tmpObject == NULL || !tmpObject->isValueDbl())
103  {
104  return;
105  }
106 
107  mpInitialObject = tmpObject;
108 
109  if (continueFromCurrentState)
110  {
111  // Determine whether the object is the initial value of a state variable;
112  const CModel * pModel = static_cast< CModel * >(mpInitialObject->getObjectAncestor("Model"));
113 
114  if (pModel != NULL)
115  {
116  mIsStateVariable = pModel->isStateVariable(tmpObject);
117 
118  if (!mIsStateVariable)
119  {
120  // We need to find the object for the transient value if it exists so that we can update while continuing.
121  mpObject = pModel->getCorrespondingTransientObject(tmpObject);
122  }
123  }
124  }
125  else
126  {
128  }
129 }
CCopasiDataModel * getObjectDataModel()
CCopasiContainer * getObjectAncestor(const std::string &type) const
CCopasiObject * getDataObject(const CCopasiObjectName &CN) const
CCopasiObject * getCorrespondingTransientObject(const CCopasiObject *pObject) const
Definition: CModel.cpp:4032
CCopasiObject * mpInitialObject
Definition: CScanMethod.h:42
bool mIsStateVariable
Definition: CScanMethod.h:50
CRegisteredObjectName * pCN
C_FLOAT64 mStoreValue
Definition: CScanMethod.h:44
size_t mNumSteps
Definition: CScanMethod.h:39
bool mFlagFinished
Definition: CScanMethod.h:48
unsigned C_INT32 * pUINT
size_t mIndex
Definition: CScanMethod.h:46
bool isValueDbl() const
const CCopasiParameter::Value & getValue(const std::string &name) const
Definition: CModel.h:50
CCopasiObject * mpObject
Definition: CScanMethod.h:41
bool isStateVariable(const CCopasiObject *pObject) const
Definition: CModel.cpp:3983
CScanItem::CScanItem ( )
private

Definition at line 73 of file CScanMethod.cpp.

73  :
74  mNumSteps(0),
75  mpObject(NULL),
76  mpInitialObject(NULL),
77  mStoreValue(0.0),
78  mIndex(0),
79  mFlagFinished(false),
80  mIsStateVariable(false)
81 {}
CCopasiObject * mpInitialObject
Definition: CScanMethod.h:42
bool mIsStateVariable
Definition: CScanMethod.h:50
C_FLOAT64 mStoreValue
Definition: CScanMethod.h:44
size_t mNumSteps
Definition: CScanMethod.h:39
bool mFlagFinished
Definition: CScanMethod.h:48
size_t mIndex
Definition: CScanMethod.h:46
CCopasiObject * mpObject
Definition: CScanMethod.h:41

Member Function Documentation

CScanItem * CScanItem::createScanItemFromParameterGroup ( CCopasiParameterGroup si,
CRandom rg,
const bool &  continueFromCurrentState 
)
static

CScanMethod class. This class describes the Scan method

Created for COPASI by Rohan Luktuke 2002

Definition at line 48 of file CScanMethod.cpp.

References CCopasiParameterGroup::getValue(), CCopasiParameter::Value::pUINT, CScanProblem::SCAN_LINEAR, CScanProblem::SCAN_RANDOM, and CScanProblem::SCAN_REPEAT.

Referenced by CScanMethod::init(), and CScanMethod::isValidProblem().

51 {
52  if (!si) return NULL;
53 
54  CScanProblem::Type type = *(CScanProblem::Type*)(si->getValue("Type").pUINT);
55 
56  CScanItem* tmp = NULL;
57 
58  if (type == CScanProblem::SCAN_REPEAT)
59  tmp = new CScanItemRepeat(si, continueFromCurrentState);
60 
61  if (type == CScanProblem::SCAN_LINEAR)
62  tmp = new CScanItemLinear(si, continueFromCurrentState);
63 
64  if (type == CScanProblem::SCAN_RANDOM)
65  tmp = new CScanItemRandom(si, rg, continueFromCurrentState);
66 
67  /* if (type == CScanProblem::SCAN_BREAK)
68  tmp = new CScanItemBreak(si, st);*/
69 
70  return tmp;
71 }
unsigned C_INT32 * pUINT
const CCopasiParameter::Value & getValue(const std::string &name) const
size_t CScanItem::getNumSteps ( ) const

Definition at line 131 of file CScanMethod.cpp.

References mNumSteps.

Referenced by CScanMethod::init().

131 {return mNumSteps;};
size_t mNumSteps
Definition: CScanMethod.h:39
const CCopasiObject * CScanItem::getObject ( ) const

Retrieve the initial object which is scanned.

Returns
const CCopasiObject * object

Definition at line 176 of file CScanMethod.cpp.

References mpObject.

Referenced by CScanMethod::init().

177 {
178  return mpObject;
179 }
CCopasiObject * mpObject
Definition: CScanMethod.h:41
bool CScanItem::isFinished ( ) const

Definition at line 155 of file CScanMethod.cpp.

References mFlagFinished.

Referenced by CScanMethod::loop().

155 {return mFlagFinished;};
bool mFlagFinished
Definition: CScanMethod.h:48
virtual bool CScanItem::isNesting ( ) const
inlinevirtual

Reimplemented in CScanItemRandom.

Definition at line 70 of file CScanMethod.h.

Referenced by CScanMethod::loop().

70 {return true;};
bool CScanItem::isValidScanItem ( const bool &  continueFromCurrentState)
virtual

perform checks. This is used in the method::isValidProblem() method. It returns false for an invalid ScanItem and generates a CCopasiMessage

Parameters
constbool & continueFromCurrentState

Reimplemented in CScanItemLinear, and CScanItemRepeat.

Definition at line 157 of file CScanMethod.cpp.

References CCopasiMessage::ERROR, CCopasiObject::getObjectDisplayName(), MCScan, mIsStateVariable, mpInitialObject, mpObject, and CCopasiMessage::WARNING.

Referenced by CScanMethod::isValidProblem(), and CScanItemLinear::isValidScanItem().

158 {
159  if (continueFromCurrentState &&
161  mpObject == NULL)
162  {
164  return true;
165  }
166 
167  if (mpInitialObject == NULL)
168  {
169  CCopasiMessage(CCopasiMessage::ERROR, "Invalid or missing scan parameter.");
170  return false;
171  }
172 
173  return true;
174 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
CCopasiObject * mpInitialObject
Definition: CScanMethod.h:42
bool mIsStateVariable
Definition: CScanMethod.h:50
#define MCScan
CCopasiObject * mpObject
Definition: CScanMethod.h:41
void CScanItem::reset ( )

Definition at line 148 of file CScanMethod.cpp.

References mFlagFinished, mIndex, and step().

Referenced by CScanMethod::loop().

149 {
150  mIndex = 0;
151  mFlagFinished = false;
152  this->step(); //purely virtual
153 }
bool mFlagFinished
Definition: CScanMethod.h:48
size_t mIndex
Definition: CScanMethod.h:46
virtual void step()=0
void CScanItem::restoreValue ( ) const

Definition at line 133 of file CScanMethod.cpp.

References mpObject, mStoreValue, and CCopasiObject::setObjectValue().

134 {
135  if (mpObject)
137 };
void setObjectValue(const C_FLOAT64 &value)
C_FLOAT64 mStoreValue
Definition: CScanMethod.h:44
CCopasiObject * mpObject
Definition: CScanMethod.h:41
virtual void CScanItem::step ( )
pure virtual

Implemented in CScanItemRandom, CScanItemLinear, and CScanItemRepeat.

Referenced by CScanMethod::loop(), and reset().

void CScanItem::storeValue ( )

Definition at line 139 of file CScanMethod.cpp.

References C_FLOAT64, CCopasiObject::getValuePointer(), CCopasiObject::isValueDbl(), mpObject, and mStoreValue.

140 {
141  if (mpObject)
142  {
143  assert(mpObject->isValueDbl());
145  }
146 };
C_FLOAT64 mStoreValue
Definition: CScanMethod.h:44
#define C_FLOAT64
Definition: copasi.h:92
bool isValueDbl() const
virtual void * getValuePointer() const
CCopasiObject * mpObject
Definition: CScanMethod.h:41

Member Data Documentation

bool CScanItem::mFlagFinished
protected
size_t CScanItem::mIndex
protected
bool CScanItem::mIsStateVariable
protected

Definition at line 50 of file CScanMethod.h.

Referenced by CScanItem(), and isValidScanItem().

size_t CScanItem::mNumSteps
protected
CCopasiObject* CScanItem::mpInitialObject
protected
CCopasiObject* CScanItem::mpObject
protected
C_FLOAT64 CScanItem::mStoreValue
protected

Definition at line 44 of file CScanMethod.h.

Referenced by restoreValue(), and storeValue().


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