3bae844680ad69273f5b44469ea8fb9eb94e0b27
[ric-plt/sdl.git] / include / private / redis / hiredissystem.hpp
1 /*
2    Copyright (c) 2018-2019 Nokia.
3
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7
8        http://www.apache.org/licenses/LICENSE-2.0
9
10    Unless required by applicable law or agreed to in writing, software
11    distributed under the License is distributed on an "AS IS" BASIS,
12    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    See the License for the specific language governing permissions and
14    limitations under the License.
15 */
16
17 #ifndef SHAREDDATALAYER_REDIS_HIREDISSYSTEM_HPP_
18 #define SHAREDDATALAYER_REDIS_HIREDISSYSTEM_HPP_
19
20 #include <hiredis/hiredis.h>
21 #include <async.h>
22
23 namespace shareddatalayer
24 {
25     namespace redis
26     {
27         class HiredisSystem
28         {
29         public:
30             HiredisSystem() = default;
31
32             HiredisSystem(const HiredisSystem&) = delete;
33
34             HiredisSystem& operator = (const HiredisSystem&) = delete;
35
36             virtual ~HiredisSystem() = default;
37
38             virtual redisContext* redisConnect(const char* ip, int port);
39
40             virtual void* redisCommandArgv(redisContext* context, int argc, const char** argv, const size_t* argvlen);
41
42             virtual void freeReplyObject(void* reply);
43
44             virtual void redisFree(redisContext* context);
45
46             virtual redisAsyncContext* redisAsyncConnect(const char* ip, int port);
47
48             virtual int redisAsyncSetConnectCallback(redisAsyncContext* ac, redisConnectCallback* fn);
49
50             virtual int redisAsyncSetDisconnectCallback(redisAsyncContext* ac, redisDisconnectCallback* fn);
51
52             virtual int redisAsyncCommandArgv(redisAsyncContext* ac,
53                                               redisCallbackFn* fn,
54                                               void* privdata,
55                                               int argc,
56                                               const char** argv,
57                                               const size_t* argvlen);
58
59             virtual void redisAsyncHandleRead(redisAsyncContext* ac);
60
61             virtual void redisAsyncHandleWrite(redisAsyncContext* ac);
62
63             virtual void redisAsyncDisconnect(redisAsyncContext* ac);
64
65             virtual void redisAsyncFree(redisAsyncContext* ac);
66
67             static HiredisSystem& getHiredisSystem() noexcept;
68         };
69     }
70 }
71
72 #endif