00001 // Runnable.cpp: implementation of the CRunnable class. 00002 // 00004 00005 #include "Runnable.h" 00006 00008 // Construction/Destruction 00010 00011 CRunnable::CRunnable() 00012 { 00013 00014 } 00015 00016 CRunnable::~CRunnable() 00017 { 00018 00019 } 00020 00021 void CRunnable::SetRunnableName(std::string name) 00022 { 00023 m_sRunnableName = name; 00024 } 00025 00026 void CRunnable::SetComponents(ReactionNetwork *pRxnNetwork, CReactionMover *pRxnMover, CellAverageObserver *pCellObserver) 00027 { 00028 m_pRxnNetwork = pRxnNetwork; 00029 m_pRxnMover = pRxnMover; 00030 m_pCellObserver = pCellObserver; 00031 } 00032 00033 void CRunnable::Run() 00034 { 00035 // zero the observer 00036 m_pCellObserver->ZeroConcentrations(); 00037 // attach the observer to the mover 00038 m_pRxnMover->Attach(m_pCellObserver); 00039 // run the network, averaging over the population 00040 int nCells = m_pCellObserver->GetNumberOfCells(); 00041 int intTime = m_pCellObserver->GetNumberOfTimeSteps(); 00042 for(int i = 0; i < nCells; i++) 00043 { 00044 m_pRxnNetwork->ChemicalReset(); 00045 m_pRxnMover->Move(0.0,0.0,m_pRxnNetwork); 00046 m_pRxnMover->Move(0.0,(double)(intTime) - 1.0, m_pRxnNetwork); 00047 } 00048 // detach the observer 00049 m_pRxnMover->Detach(m_pCellObserver); 00050 // notify observers (a la plotters) 00051 Notify(); 00052 }