Click here to Skip to main content
15,868,016 members
Articles / Desktop Programming / MFC

Notifying the Document

Rate me:
Please Sign up or sign in to vote.
4.36/5 (11 votes)
12 Jul 2006CPOL6 min read 63.2K   1.2K   35  
An article on delivering objects to the document in a document/view architecture, using the WM_NOTIFY message.
// NotifierAppDoc.h : interface of the CNotifierAppDoc class
//


#pragma once

//class DocumentProxy ; 

#define DEFAULT_STOP_TIMEOUT	500

typedef enum
{
	PTO_UNINITIALIZED=0,
	PTO_INITIALIZED=1,
	PTO_RUNNING=2,
	PTO_PAUSED=4,
} PTOSTATE ; // PulseThread Object State

typedef enum
{
	PTS_EMPTY=0,
	PTS_SIGNAL,
	PTS_STOP,
	PTS_COUNT
} PTSIGNAL; // PulseThread Signal Type

class signal_fifo
{
public:
	static void Create( signal_fifo ** signals ) ; 
	static void Destroy( signal_fifo ** signals ) ;
	virtual PTSIGNAL Pop()= 0 ;
	virtual void Push( PTSIGNAL Signal ) = 0 ;
	virtual size_t Size() = 0 ;
	virtual HANDLE & Event() = 0 ;

	virtual ~signal_fifo() {}
};



class CNotifierAppDoc : public CDocument
{
protected: // create from serialization only
	CNotifierAppDoc();
	DECLARE_DYNCREATE(CNotifierAppDoc)

// Attributes
public:
	void RequestInformation() ;
	void RequestError() ; 

// Operations
public:

// Overrides
	public:
	virtual BOOL OnNewDocument();
	virtual void Serialize(CArchive& ar);

// Implementation
public:
	virtual ~CNotifierAppDoc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	CWinThread			*	m_InformationThread ; 
	signal_fifo	*			m_InformationDeque ;
	static UINT InformationThread( void * p ) ;
	void OnInformationThread( int index ) ;

	CWinThread			*	m_ErrorThread ; 
	signal_fifo	*			m_ErrorDeque ;
	static UINT ErrorThread( void * p ) ;
	void OnErrorThread( int index ) ;

protected:
	BOOL					m_IsInitialized ; 

// Generated message map functions
protected:
	DECLARE_MESSAGE_MAP()
public:
	virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
};


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions