summaryrefslogtreecommitdiff
path: root/include/qhy/unlockimagequeue.h
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2019-03-14 15:52:30 -0700
committerAndy Wortman <ixineeringeverywhere@gmail.com>2019-03-14 15:52:30 -0700
commit9a607474bdd66dd716635cfed7f2c832c39b4523 (patch)
treec5f65b4cecd6376a3b99646679f9714d5f9213a2 /include/qhy/unlockimagequeue.h
parentac7604616ab2e44ad12a9d8d5dd90dec15feb5cc (diff)
add qhy headers.........
Diffstat (limited to 'include/qhy/unlockimagequeue.h')
-rw-r--r--include/qhy/unlockimagequeue.h56
1 files changed, 56 insertions, 0 deletions
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