Add extra line about src files are part of RIC platform project
[ric-plt/sdl.git] / include / private / redis / reply.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 /*
18  * This source code is part of the near-RT RIC (RAN Intelligent Controller)
19  * platform project (RICP).
20 */
21
22 #ifndef SHAREDDATALAYER_REDIS_REPLY_HPP_
23 #define SHAREDDATALAYER_REDIS_REPLY_HPP_
24
25 #include <string>
26 #include <vector>
27 #include <memory>
28 #include <hiredis/hiredis.h>
29
30 namespace shareddatalayer
31 {
32     namespace redis
33     {
34         using ReplyStringLength = decltype(::redisReply::len);
35
36         class Reply
37         {
38         public:
39             Reply(const Reply&) = delete;
40
41             Reply& operator = (const Reply&) = delete;
42
43             virtual ~Reply() = default;
44
45             enum class Type
46             {
47                 NIL,
48                 INTEGER,
49                 STATUS,
50                 STRING,
51                 ARRAY
52             };
53
54             struct DataItem
55             {
56                 std::string str;
57                 ReplyStringLength len;
58             };
59
60             virtual Type getType() const = 0;
61
62             virtual long long getInteger() const = 0;
63
64             virtual const DataItem* getString() const = 0;
65
66             using ReplyVector = std::vector<std::shared_ptr<Reply>>;
67
68             virtual const ReplyVector* getArray() const = 0;
69
70         protected:
71             Reply() = default;
72         };
73     }
74 }
75
76 #endif