fd24a116b01227215d395467852be286d79723f3
[ric-plt/sdl.git] / include / private / databaseconfiguration.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_DATABASECONFIGURATION_HPP_
18 #define SHAREDDATALAYER_DATABASECONFIGURATION_HPP_
19
20 #include <string>
21 #include <vector>
22 #include "private/hostandport.hpp"
23
24 namespace shareddatalayer
25 {
26     class DatabaseConfiguration
27     {
28     public:
29         class InvalidDbType;
30         using Addresses = std::vector<HostAndPort>;
31         enum class DbType
32         {
33             UNKNOWN = 0,
34             REDIS_STANDALONE,
35             REDIS_CLUSTER
36         };
37
38         virtual ~DatabaseConfiguration() = default;
39         virtual void checkAndApplyDbType(const std::string& type) = 0;
40         virtual void checkAndApplyServerAddress(const std::string& address) = 0;
41         virtual DatabaseConfiguration::DbType getDbType() const = 0;
42         virtual DatabaseConfiguration::Addresses getServerAddresses() const = 0;
43         virtual DatabaseConfiguration::Addresses getDefaultServerAddresses() const = 0;
44         virtual bool isEmpty() const = 0;
45
46         DatabaseConfiguration(DatabaseConfiguration&&) = delete;
47         DatabaseConfiguration(const DatabaseConfiguration&) = delete;
48         DatabaseConfiguration& operator = (DatabaseConfiguration&&) = delete;
49         DatabaseConfiguration& operator = (const DatabaseConfiguration&) = delete;
50
51     protected:
52         DatabaseConfiguration() = default;
53     };
54
55     class DatabaseConfiguration::InvalidDbType: public Exception
56     {
57     public:
58         InvalidDbType() = delete;
59
60         explicit InvalidDbType(const std::string& type);
61     };
62 }
63
64 #endif