www.pudn.com > Observerwangdxh.zip > CardioMon.cpp
// CardioMon.cpp : implementation of the CCardioMonitor class // #include "stdafx.h" #include "CardioMon.h" #include///////////////////////////////////////////////////////////////////////////// // CCardioMonitor message handlers BEGIN_MESSAGE_MAP(CCardioMonitor, CWnd) //{{AFX_MSG_MAP(CCardioMonitor) //}}AFX_MSG_MAP END_MESSAGE_MAP() CCardioMonitor::CCardioMonitor( CCardioSubject * pCardioSubject ) { // Step 1 - Attach the observer to the subject and initialize class members from // the subject ASSERT( pCardioSubject != NULL ); m_pCardioSubject = pCardioSubject; m_pCardioSubject->Attach( this ); // Step 2 - Initialize class members m_bStarted = FALSE; } CCardioMonitor::~CCardioMonitor() { // Step 1 - Detach the observer from the subject m_pCardioSubject->Detach( this ); } BOOL CCardioMonitor::Start() { // Step 1 - Set m_bStarted to TRUE m_bStarted = TRUE; return TRUE; } VOID CCardioMonitor::Stop() { // Step 1 - Set m_bStarted to FALSE m_bStarted = TRUE; }