From fa1bb24f1f8aaf8e598a3bc53d90922e445fe59a Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 14 Mar 2019 15:52:30 -0700 Subject: add qhy headers......... --- include/qhy/unlockimagequeue.h | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 include/qhy/unlockimagequeue.h (limited to 'include/qhy/unlockimagequeue.h') diff --git a/include/qhy/unlockimagequeue.h b/include/qhy/unlockimagequeue.h new file mode 100644 index 0000000..35aef29 --- /dev/null +++ b/include/qhy/unlockimagequeue.h @@ -0,0 +1,56 @@ +/* + QHYCCD SDK + + Copyright (c) 2014 QHYCCD. + All Rights Reserved. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 + Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + The full GNU General Public License is included in this distribution in the + file called LICENSE. + */ +#ifndef _UNLOCK_QUEUE_H +#define _UNLOCK_QUEUE_H + +class UnlockImageQueue { +public: + UnlockImageQueue(); + virtual ~UnlockImageQueue(); + + bool Initialize(int nSize); + unsigned int Put(const unsigned char *pBuffer, unsigned int nLen); + unsigned int Get(unsigned char *pBuffer, unsigned int nLen); + inline void Clean() { + m_nIn = 0; + m_nOut = 0; + } + inline unsigned int GetDataLen() const { + return m_nIn - m_nOut; + } + +private: + inline bool is_power_of_2(unsigned long n) { + return (n != 0 && ((n & (n - 1)) == 0)); + }; + + inline unsigned long roundup_power_of_two(unsigned long val); +private: + unsigned char *m_pBuffer; /* the buffer holding the data */ + unsigned int m_nSize; /* the size of the allocated buffer */ + unsigned int m_nIn; /* data is added at offset (in % size) */ + unsigned int m_nOut; /* data is extracted from offset (out % size) */ +}; + +#endif -- cgit v1.1