Add extra line about src files are part of RIC platform project
[ric-plt/sdl.git] / include / private / redis / databaseinfo.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_DATABASEINFO_HPP_
23 #define SHAREDDATALAYER_REDIS_DATABASEINFO_HPP_
24
25 #include <algorithm>
26 #include <string>
27 #include <vector>
28 #include "private/databaseconfiguration.hpp"
29 #include <boost/optional.hpp>
30
31 namespace shareddatalayer
32 {
33     namespace redis
34     {
35         struct DatabaseInfo
36         {
37             enum class Type
38             {
39                 SINGLE,
40                 REDUNDANT,
41                 CLUSTER
42             };
43             enum class Discovery
44             {
45                 HIREDIS,
46                 SENTINEL
47             };
48
49             DatabaseConfiguration::Addresses hosts;
50             Type type;
51             boost::optional<std::string> ns;
52             Discovery discovery;
53
54             bool operator==(const DatabaseInfo& di) const
55             {
56                 DatabaseConfiguration::Addresses hosts1 = hosts;
57                 DatabaseConfiguration::Addresses hosts2 = di.hosts;
58
59                 std::sort(hosts1.begin(), hosts1.end());
60                 std::sort(hosts2.begin(), hosts2.end());
61
62                 return (hosts1 == hosts2 &&
63                         type == di.type &&
64                         ns == di.ns);
65             }
66
67             bool operator!=(const DatabaseInfo& di) const
68             {
69                 return !(di == *this);
70             }
71         };
72     }
73 }
74
75 #endif