Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cHeartbeatFile Class Reference

#include <cHeartbeatFile.h>

Inheritance diagram for GrayLib::cHeartbeatFile:
Gray::cFile Gray::CFile Gray::cStream Gray::CObject Gray::cStreamInput Gray::cStreamOutput Gray::cStreamBase Gray::cStreamBase

Public Member Functions

 cHeartbeatFile (cStringF sFilePath="")
 
virtual ~cHeartbeatFile (void)
 
cStringF get_HeartbeatFilePath () const
 
HRESULT GetHeartbeatTimeLast (OUT cTimeInt &rTimeLastBeat) const
 
HRESULT DoBeat (TIMESECD_t tThrottleSeconds=1)
 
 UNITTEST_FRIEND (cHeartbeatFile)
 
- Public Member Functions inherited from Gray::cFile
 cFile ()
 
 cFile (cStringF sFilePath, OF_FLAGS_t nOpenFlags)
 
virtual ~cFile ()
 
virtual bool isValidCheck () const noexcept
 < memory allocation and structure definitions are valid. More...
 
virtual STREAM_SEEKRET_t Seek (STREAM_OFFSET_t lOffset=0, SEEK_ORIGIN_TYPE eSeekOrigin=SEEK_Set) override
 
virtual STREAM_POS_t GetPosition () const override
 
virtual STREAM_POS_t GetLength () const override
 
int Read (void *pData, size_t nDataSize)
 
void Write (const void *pData, size_t nDataSize)
 
cStringF get_FilePath () const
 
cStringF get_FileTitleX () const
 
cStringF get_FileExt () const
 
bool IsFileExt (const FILECHAR_t *pszExt) const
 
OF_FLAGS_t get_Mode () const noexcept
 
OF_FLAGS_t get_ModeFlags () const noexcept
 
bool isModeWrite () const noexcept
 
bool isModeRead () const noexcept
 
virtual bool isFileOpen () const
 
virtual HRESULT OpenX (cStringF sFilePath="", OF_FLAGS_t nOpenFlags=OF_READ|OF_SHARE_DENY_NONE)
 
virtual void Close (void) override
 
HANDLE DetachFileHandle ()
 
HRESULT OpenWait (cStringF sFilePath="", OF_FLAGS_t nOpenFlags=OF_READ|OF_SHARE_DENY_NONE, TIMESYSD_t nWaitTime=100)
 
HRESULT OpenCreate (cStringF sFilePath="", OF_FLAGS_t nOpenFlags=OF_CREATE|OF_WRITE, _SECURITY_ATTRIBUTES *pSa=nullptr)
 
bool SetFileTime (const cTimeFile *lpCreationTime, const cTimeFile *lpAccessTime, const cTimeFile *lpLastWriteTime)
 
bool SetFileTime (cTimeInt timeCreation, cTimeInt timeLastWrite)
 
HRESULT GetFileStatus (OUT cFileStatus &attr) const
 
virtual HRESULT ReadX (void *pData, size_t nDataSize) override
 
virtual HRESULT WriteX (const void *pData, size_t nDataSize) override
 
virtual HRESULT FlushX () override
 
- Public Member Functions inherited from Gray::CFile
virtual ~CFile ()
 
virtual void SetLength (STREAM_SEEKRET_t dwNewLen)
 
HRESULT Write (const void *pData, size_t nDataSize)
 
HRESULT Read (void *pData, size_t nDataSize)
 
- Public Member Functions inherited from Gray::CObject
virtual ~CObject ()
 
virtual void AssertValid () const
 < memory allocation and structure definitions are valid. More...
 
virtual void Serialize (cArchive &a)
 
- Public Member Functions inherited from Gray::cStream
void SeekToBegin ()
 
STREAM_POS_t SeekToEnd ()
 
- Public Member Functions inherited from Gray::cStreamInput
 cStreamInput () noexcept
 
virtual ~cStreamInput ()
 
virtual size_t SetSeekSizeMin (size_t nSizeMin=k_FILE_BLOCK_SIZE)
 
virtual HRESULT ReadX (OUT void *pData, size_t nDataSize)
 
HRESULT ReadAll (OUT cHeapBlock &block, size_t nSizeExtra=0)
 
virtual HRESULT ReadStringLine (OUT char *pszBuffer, StrLen_t iSizeMax)
 
virtual HRESULT ReadStringLine (OUT wchar_t *pszBuffer, StrLen_t iSizeMax)
 
HRESULT ReadT (OUT void *pVal, size_t nSize)
 
template<typename TYPE >
HRESULT ReadT (OUT TYPE &val)
 
template<typename TYPE >
HRESULT ReadTN (OUT TYPE &val)
 
HRESULT ReadSize (OUT size_t &nSize)
 
template<typename TYPE >
HRESULT ReadSizeT (OUT TYPE &n)
 
HRESULT ReadHashCode (OUT UINT32 &nHashCode)
 
HRESULT ReadHashCode (OUT UINT64 &nHashCode)
 
HRESULT ReadN (OUT BYTE *pBuffer, size_t nSizeMax)
 
template<typename _CH >
HRESULT ReadStringN (OUT _CH *pszStr, StrLen_t iSizeMax)
 
virtual HRESULT ReadPeek (void *pData, size_t nDataSize)
 
- Public Member Functions inherited from Gray::cStreamBase
virtual ~cStreamBase ()
 
void SeekToBegin ()
 
STREAM_POS_t SeekToEnd ()
 
- Public Member Functions inherited from Gray::cStreamOutput
 cStreamOutput () noexcept
 
virtual ~cStreamOutput ()
 
HRESULT WriteT (const void *pVal, size_t nDataSize)
 
template<typename TYPE >
HRESULT WriteT (TYPE val)
 
HRESULT WriteSize (size_t nSize)
 
HRESULT WriteHashCode (HASHCODE_t nHashCode)
 
HRESULT WriteN (const void *pBuffer, size_t nSize)
 
template<typename _CH >
HRESULT WriteStringN (const _CH *pszStr)
 
template<typename _CH >
HRESULT WriteCharRepeat (_CH nChar, int nCount=1)
 
virtual HRESULT WriteString (const char *pszStr)
 
virtual HRESULT WriteString (const wchar_t *pszStr)
 
StrLen_t VPrintf (const char *pszFormat, va_list args)
 
StrLen_t VPrintf (const wchar_t *pszFormat, va_list args)
 
StrLen_t _cdecl Printf (const char *pszFormat,...)
 
StrLen_t _cdecl Printf (const wchar_t *pszFormat,...)
 
HRESULT WriteStream (cStreamInput &sInp, STREAM_POS_t nSizeMax=k_FILE_BLOCK_SIZE, IStreamProgressCallback *pProgress=nullptr, TIMESYSD_t nTimeout=0)
 Copy cStreamInput to this stream. More...
 

Public Attributes

const cStringF m_sFilePath
 full path for the heartbeat file. More...
 
cTimeInt m_tLastBeat
 Last recorded heartbeat success. For throttling. More...
 
- Public Attributes inherited from Gray::CFile
cOSHandle m_hFile
 OSHandle for the open file. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Gray::cFile
static HRESULT __stdcall DeletePath (const FILECHAR_t *pszFileName)
 
static HRESULT __stdcall DeletePathX (const FILECHAR_t *pszFilePath, DWORD nFileFlags=0)
 
static HRESULT __stdcall LoadFile (const FILECHAR_t *pszFilePath, OUT cHeapBlock &block, size_t nSizeExtra=0)
 
- Static Public Attributes inherited from Gray::cStreamBase
static const BYTE k_SIZE_MASK = 0x80
 Used for WriteSize() More...
 
static const size_t k_FILE_BLOCK_SIZE = (32 * 1024)
 default arbitrary transfer block size. more than this is NOT more efficient. More...
 
- Protected Member Functions inherited from Gray::cFile
HRESULT OpenSetup (cStringF sFilePath, OF_FLAGS_t uModeFlags)
 
- Protected Member Functions inherited from Gray::CFile
bool isFileOpen () const noexcept
 
HRESULT OpenCreate (cStringF sFilePath="", OF_FLAGS_t nOpenFlags=OF_CREATE|OF_WRITE, _SECURITY_ATTRIBUTES *pSa=nullptr)
 
- Protected Attributes inherited from Gray::cFile
OF_FLAGS_t m_nOpenFlags
 MMSYSTEM uses high bits of 32 bit flags. OF_FLAGS_TYPE_ OF_READ etc. More...
 
- Protected Attributes inherited from Gray::CFile
cStringF m_strFileName
 store a copy of the full file path. MFC defined name. More...
 
- Static Protected Attributes inherited from Gray::cFile
static ITERATE_t sm_iFilesOpen = 0
 global count of all open files for this process. More...
 

Detailed Description

Mark a time stamp in and on a file periodically to show a postmortem when we were last alive. Any other form of non volatile memory might also be sufficient. This might be done in conjunction with cluster heartbeat recording. (Lister services)

Constructor & Destructor Documentation

◆ cHeartbeatFile()

GrayLib::cHeartbeatFile::cHeartbeatFile ( cStringF  sFilePath = "")

◆ ~cHeartbeatFile()

GrayLib::cHeartbeatFile::~cHeartbeatFile ( void  )
virtual

Member Function Documentation

◆ DoBeat()

HRESULT GrayLib::cHeartbeatFile::DoBeat ( TIMESECD_t  tThrottleSeconds = 1)

Call this as often as you see fit. but not too often. Write time stamp into file just to touch the file.

  • tThrottle = Once every X seconds or so should be fine. ignore calls that are too often.

◆ get_HeartbeatFilePath()

cStringF GrayLib::cHeartbeatFile::get_HeartbeatFilePath ( ) const

Default name is "HeartBeat_AppName.bin". Put this in the temp directory space if no directory path provided.

◆ GetHeartbeatTimeLast()

HRESULT GrayLib::cHeartbeatFile::GetHeartbeatTimeLast ( OUT cTimeInt rTimeLastBeat) const

Get the last heartbeat cTimeInt for this file.

◆ UNITTEST_FRIEND()

GrayLib::cHeartbeatFile::UNITTEST_FRIEND ( cHeartbeatFile  )

Member Data Documentation

◆ m_sFilePath

const cStringF GrayLib::cHeartbeatFile::m_sFilePath

full path for the heartbeat file.

◆ m_tLastBeat

cTimeInt GrayLib::cHeartbeatFile::m_tLastBeat

Last recorded heartbeat success. For throttling.


The documentation for this class was generated from the following files: