margintestertotalfreespace.h
来自「C++封装的视频采集代码」· C头文件 代码 · 共 141 行
H
141 行
#ifndef MarginTesterTotalFreeSpace_H#define MarginTesterTotalFreeSpace_H#include "CircularBufferSpaceInfo.h"namespace oxsemi{ namespace circular_buffer { /** * @class MarginTesterTotalFreeSpace * is a simple policy class that determinds how the Thresholds of space in * a buffer class are tested against a Threshold value. * This implemntation will test the total remaining space in the buffer * against the Threshold, and is best suited to use where data is written, or * read accross the wrap-around boundry of the circular buffer. */ class MarginTesterTotalFreeSpace { public: /** * @ctor. * @param iThreshold is an unsigned long the describes the new Threshold * to be used by the object. */ MarginTesterTotalFreeSpace( unsigned long iThreshold = 0 ) : miThreshold_( iThreshold ) {}; /** * IsAboveThreshold tests the space info data against the Threshold held * by this object. The policy reports if the Threshold was violated. * @param spaceInfo is a reference to a CircularBufferSpaceInfo that# * holds information about the state of the circular buffer. * @return a boolean that is true if the implementation decides that * the buffer Threshold has been exceeded. */ bool IsAboveThreshold( const CircularBufferSpaceInfo& spaceInfo ) const; /** * SetBufferDetails setter function. * @param iStartAddress is an unsigned long the describes the circular * buffer base address. * @param iLength is an unsigned long the describes the buffer length */ void SetBufferDetails( unsigned long iStartAddress, unsigned long iLength ) {}; /** * SetThreshold setter function. * @param iThreshold is an unsigned long the describes the new Threshold * to be used by the object. */ void SetThreshold( unsigned long iThreshold ); /** * SetThreshold getter function. * @return an unsigned long that describes the Threshold used by the * object. */ unsigned long GetThreshold() const; private: // storage for the Threshold value that is tested against unsigned long miThreshold_; }; // end class MarginTesterTotalFreeSpace // ===================================================================== // ===================================================================== // ===================================================================== // ===================================================================== /** * IsAboveThreshold tests the space info data against the Threshold held * by this object. The policy reports if the Threshold was violated. * @param spaceInfo is a reference to a CircularBufferSpaceInfo that# * holds information about the state of the circular buffer. * @return a boolean that is true if the implementation decides that * the buffer Threshold has been exceeded. */ inline bool MarginTesterTotalFreeSpace::IsAboveThreshold( const CircularBufferSpaceInfo& spaceInfo ) const // {{{ { // this implementation tests the total space left in the circular buffer // against the Threshold. bool bAboveThreshold = ( spaceInfo.GetFirstAvailableSection().GetLength() + spaceInfo.GetSecondAvailableSection().GetLength() ) >= miThreshold_;//TRACE("$[%lu+%lu]:: %s (%lu)$n\n", spaceInfo.GetFirstAvailableSection().GetLength(), spaceInfo.GetSecondAvailableSection().GetLength(), bAboveThreshold ? "above" : "below", miThreshold_); return bAboveThreshold; } // }}} /** * SetThreshold getter function. * @return an unsigned long that describes the Threshold used by the * object. */ inline unsigned long MarginTesterTotalFreeSpace::GetThreshold() const // {{{ { return miThreshold_; } // }}} /** * SetThreshold setter function. * @param iThreshold is an unsigned long the describes the new Threshold * to be used by the object. */ inline void MarginTesterTotalFreeSpace::SetThreshold( unsigned long iThreshold ) // {{{ { miThreshold_ = iThreshold; } // }}} } // end namespace circular_buffer} // end namespace oxsemi#endif // __MarginTesterTotalFreeSpace_H__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?