aboutsummaryrefslogtreecommitdiff
path: root/examples/redis-unstable/deps/hiredis/adapters/qt.h
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:52:54 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:52:54 +0100
commitdcacc00e3750300617ba6e16eb346713f91a783a (patch)
tree38e2d4fb5ed9d119711d4295c6eda4b014af73fd /examples/redis-unstable/deps/hiredis/adapters/qt.h
parent58dac10aeb8f5a041c46bddbeaf4c7966a99b998 (diff)
downloadcrep-dcacc00e3750300617ba6e16eb346713f91a783a.tar.gz
Remove testing data
Diffstat (limited to 'examples/redis-unstable/deps/hiredis/adapters/qt.h')
-rw-r--r--examples/redis-unstable/deps/hiredis/adapters/qt.h135
1 files changed, 0 insertions, 135 deletions
diff --git a/examples/redis-unstable/deps/hiredis/adapters/qt.h b/examples/redis-unstable/deps/hiredis/adapters/qt.h
deleted file mode 100644
index 5cc02e6..0000000
--- a/examples/redis-unstable/deps/hiredis/adapters/qt.h
+++ /dev/null
@@ -1,135 +0,0 @@
1/*-
2 * Copyright (C) 2014 Pietro Cerutti <gahr@gahr.ch>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#ifndef __HIREDIS_QT_H__
27#define __HIREDIS_QT_H__
28#include <QSocketNotifier>
29#include "../async.h"
30
31static void RedisQtAddRead(void *);
32static void RedisQtDelRead(void *);
33static void RedisQtAddWrite(void *);
34static void RedisQtDelWrite(void *);
35static void RedisQtCleanup(void *);
36
37class RedisQtAdapter : public QObject {
38
39 Q_OBJECT
40
41 friend
42 void RedisQtAddRead(void * adapter) {
43 RedisQtAdapter * a = static_cast<RedisQtAdapter *>(adapter);
44 a->addRead();
45 }
46
47 friend
48 void RedisQtDelRead(void * adapter) {
49 RedisQtAdapter * a = static_cast<RedisQtAdapter *>(adapter);
50 a->delRead();
51 }
52
53 friend
54 void RedisQtAddWrite(void * adapter) {
55 RedisQtAdapter * a = static_cast<RedisQtAdapter *>(adapter);
56 a->addWrite();
57 }
58
59 friend
60 void RedisQtDelWrite(void * adapter) {
61 RedisQtAdapter * a = static_cast<RedisQtAdapter *>(adapter);
62 a->delWrite();
63 }
64
65 friend
66 void RedisQtCleanup(void * adapter) {
67 RedisQtAdapter * a = static_cast<RedisQtAdapter *>(adapter);
68 a->cleanup();
69 }
70
71 public:
72 RedisQtAdapter(QObject * parent = 0)
73 : QObject(parent), m_ctx(0), m_read(0), m_write(0) { }
74
75 ~RedisQtAdapter() {
76 if (m_ctx != 0) {
77 m_ctx->ev.data = NULL;
78 }
79 }
80
81 int setContext(redisAsyncContext * ac) {
82 if (ac->ev.data != NULL) {
83 return REDIS_ERR;
84 }
85 m_ctx = ac;
86 m_ctx->ev.data = this;
87 m_ctx->ev.addRead = RedisQtAddRead;
88 m_ctx->ev.delRead = RedisQtDelRead;
89 m_ctx->ev.addWrite = RedisQtAddWrite;
90 m_ctx->ev.delWrite = RedisQtDelWrite;
91 m_ctx->ev.cleanup = RedisQtCleanup;
92 return REDIS_OK;
93 }
94
95 private:
96 void addRead() {
97 if (m_read) return;
98 m_read = new QSocketNotifier(m_ctx->c.fd, QSocketNotifier::Read, 0);
99 connect(m_read, SIGNAL(activated(int)), this, SLOT(read()));
100 }
101
102 void delRead() {
103 if (!m_read) return;
104 delete m_read;
105 m_read = 0;
106 }
107
108 void addWrite() {
109 if (m_write) return;
110 m_write = new QSocketNotifier(m_ctx->c.fd, QSocketNotifier::Write, 0);
111 connect(m_write, SIGNAL(activated(int)), this, SLOT(write()));
112 }
113
114 void delWrite() {
115 if (!m_write) return;
116 delete m_write;
117 m_write = 0;
118 }
119
120 void cleanup() {
121 delRead();
122 delWrite();
123 }
124
125 private slots:
126 void read() { redisAsyncHandleRead(m_ctx); }
127 void write() { redisAsyncHandleWrite(m_ctx); }
128
129 private:
130 redisAsyncContext * m_ctx;
131 QSocketNotifier * m_read;
132 QSocketNotifier * m_write;
133};
134
135#endif /* !__HIREDIS_QT_H__ */