⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notifyslave.h

📁 VHPD1394 V1.15驅動程序源碼
💻 H
字号:
/************************************************************************
 *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
 *  PURPOSE.
 ************************************************************************/

/************************************************************************
 *
 *  Module:       NotifySlave.h
 *  Long name:    CNotifySlave class definition
 *  Description:  Class that monitors a portion of the local node's
 *                IEEE 1394 address space and notifies the caller
 *                on accesses to the address space.
 *
 *  Runtime Env.: Win32
 *  Author(s):    Frank Senf
 *  Company:      Thesycon GmbH, Ilmenau
 ************************************************************************/

#if !defined(_NotifySlave_h_)
#define _NotifySlave_h_


// get base class definition
#include "CVhpdNotifySlave.h"


//
// CNotifySlave class
// The class is derived from the CVhpdNotifySlave class contained in the
// VHPDLib C++ class library.
// Thus, it has an embedded worker thread that monitors access on a portion
// of the local node's IEEE 1394 address space.
// The class mainly implements the ProcessNotification function defined
// by the base class.
//
class CNotifySlave : public CVhpdNotifySlave {

public:
  // Construction
  CNotifySlave();   // standard constructor
  // destructor
  ~CNotifySlave();

  // ----------------
  // interface
  
  // store the given event objects to local members
  // the event objects will be used for synchronization of notification
  // processing
  void
  SetNotifyEvents(
    HANDLE hNotifyEvt,
    HANDLE hNotifyCompletedEvt
    ) { m_NotifyEvt = hNotifyEvt; m_NotifyCompletedEvt = hNotifyCompletedEvt; }

  // return a pointer to of current address space access description
  // returns NULL if there is no current access
  VHPD_ADRRNG_NOTIFICATION*
  GetCurrentAccess() { return m_CurrentNotification; }

  // return current number of buffers completed with error
  unsigned long
  GetErrorCount() { return m_BufferError; }

  // return status code of last buffer completed with error
  unsigned long
  GetLastError() { return m_LastError; }

  // returns true if the thread is about to terminate
  bool
  ThreadExited() { return m_ThreadExited; }

  // ----------------
  // CVhpdThread overloaded functions

  // function is called before the worker thread terminates itself
  // NOTE: It is called in the context of the worker thread.
  virtual
  void
  OnThreadExit();

  // overloaded CVhpdThread::TerminateThread() function
  // NOTE 1: called in the context of the main thread
  // NOTE 2: TerminateThread() is overloaded to ensure that the
  // thread will exit. This is done by trying to terminate the
  // thread until it really terminates. For future version of VHPDLib
  // this will be implemented by the base class
  virtual
  void 
  TerminateThread();

// implementation
protected:

  // ----------------
  // CVhpdNotifySlave overloaded functions

  // function is called if access to the monitored address space is detected
  // buffer memory attached to the provided Buf descriptor contains a
  // VHPD_ADRRNG_NOTIFICATION structure that describes the current access
  // returns FALSE if address space monitoring should be stopped, TRUE to continue
  virtual
  BOOL
  ProcessNotification(CVhpdBuf* Buf);
  
  // function is called if a buffer is completed with error by the driver
  virtual
  void
  BufErrorHandler(CVhpdBuf* Buf);

  // --------------
  // member variables

  // pointer to description of current address space access
  // NULL if no current description
  VHPD_ADRRNG_NOTIFICATION* m_CurrentNotification;

  // event object the worker thread will set if an access to the monitored
  // memory space is detected
  // must be provided by the caller
  HANDLE m_NotifyEvt;
  // event object the worker thread will wait on after signalizing an
  // memory space access to the caller
  // will be set by the caller if notification processing is finished
  // must be provided by the caller
  HANDLE m_NotifyCompletedEvt;

  // flag is set to true if OnThreadExit is called
  bool m_ThreadExited;

  // error handling
  // counter increases every time a buffer is completed with an error status
  unsigned long m_BufferError;
  // last error received from the Buf->mStatus member, only valid if
  // m_BufferError != 0
  unsigned long m_LastError;


}; // class CNotifySlave


#endif // !defined(_NotifySlave_h_)

/*************************** EOF **************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -