You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.3 KiB
C

1 month ago
/**
* @file WSubject.h
* @brief Ŀ<EFBFBD><EFBFBD>۲<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>
* @author ɳĮ<EFBFBD><EFBFBD>ѻ
* @time 2010-01-18
*/
#pragma once
#include <vector>
namespace wuya
{
class WObserver;
typedef std::vector<WObserver*> ObserverVector;
class AFX_EXT_CLASS WSubject
{
public:
WSubject(void);
virtual ~WSubject(void);
/** @brief <20><><EFBFBD><EFBFBD>Observer */
virtual void Attach(WObserver* pObserver);
/** @brief ȡ<><C8A1>Observer<65><72><EFBFBD><EFBFBD> */
virtual void Detach(WObserver* pObserver);
/**
* @brief ֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Observer<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
virtual void Notify(ULONGLONG ullTime);
/**
* @brief <EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>й۲<EFBFBD><EFBFBD>߹۲<EFBFBD>Ŀ<EFBFBD><EFBFBD>
*/
BOOL HasObserver();
/** @brief <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD>֪ͨ<CDA8>۲<EFBFBD><DBB2><EFBFBD> */
void SetNotify(BOOL bNotify);
BOOL GetNotify();
/** @brief ʱ<><CAB1><EFBFBD><EFBFBD> */
ULONGLONG GetTimeStampSubject() const;
void SetTimeStampSubject(ULONGLONG ullTime);
private:
ObserverVector m_vectorpObserver;
ULONGLONG m_ullTimeSubject; ///< ʱ<><CAB1><EFBFBD><EFBFBD>
BOOL m_bNotify; ///< <20>Ƿ<EFBFBD>֪ͨ<CDA8>۲<EFBFBD><DBB2>߸<EFBFBD><DFB8><EFBFBD>
};
inline void WSubject::SetNotify(BOOL bNotify)
{
this->m_bNotify = bNotify;
}
inline BOOL WSubject::GetNotify()
{
return m_bNotify;
}
inline ULONGLONG WSubject::GetTimeStampSubject() const
{
return m_ullTimeSubject;
}
inline void WSubject::SetTimeStampSubject(ULONGLONG ullTime)
{
this->m_ullTimeSubject = ullTime;
}
}