2 Copyright (c) 2018-2019 Nokia.
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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef SHAREDDATALAYER_DATABASECONFIGURATION_HPP_
18 #define SHAREDDATALAYER_DATABASECONFIGURATION_HPP_
22 #include <boost/optional.hpp>
23 #include "private/hostandport.hpp"
25 namespace shareddatalayer
27 class DatabaseConfiguration
31 using Addresses = std::vector<HostAndPort>;
40 virtual ~DatabaseConfiguration() = default;
41 virtual void checkAndApplyDbType(const std::string& type) = 0;
42 virtual void checkAndApplyServerAddress(const std::string& address) = 0;
43 virtual void checkAndApplySentinelAddress(const std::string& address) = 0;
44 virtual void checkAndApplySentinelMasterName(const std::string& name) = 0;
45 virtual DatabaseConfiguration::DbType getDbType() const = 0;
46 virtual DatabaseConfiguration::Addresses getServerAddresses() const = 0;
47 virtual DatabaseConfiguration::Addresses getDefaultServerAddresses() const = 0;
48 virtual boost::optional<HostAndPort> getSentinelAddress() const = 0; // Optional return value, because empty HostAndPort can't be created.
49 virtual std::string getSentinelMasterName() const = 0;
50 virtual bool isEmpty() const = 0;
52 DatabaseConfiguration(DatabaseConfiguration&&) = delete;
53 DatabaseConfiguration(const DatabaseConfiguration&) = delete;
54 DatabaseConfiguration& operator = (DatabaseConfiguration&&) = delete;
55 DatabaseConfiguration& operator = (const DatabaseConfiguration&) = delete;
58 DatabaseConfiguration() = default;
61 class DatabaseConfiguration::InvalidDbType: public Exception
64 InvalidDbType() = delete;
66 explicit InvalidDbType(const std::string& type);