2 * Samsung Ukraine R&D Center (SRK under a contract between)
3 * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
4 * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
20 * @brief Application settings
21 * @date Created Feb 14, 2018
22 * @author Mail to: <A HREF="mailto:d.lomtev@samsung.com">Dmytro Lomtev, d.lomtev@samsung.com</A>
34 * @brief The Settings class reprensents application settings
40 static Settings& instance()
46 * @brief getServerAddress returns the address of the DSM server
47 * @return URL as string
49 const std::string& getServerAddress() const
55 * @brief getDeviceId returns the device identifier
56 * @return the device indentifier as string
58 const std::string& getDeviceId() const
64 * @brief getKeepAliveTimeout returns KeepAlive timeout period
65 * @return KeepAlive timeout period
67 const std::chrono::milliseconds& getKeepAliveTimeout() const
69 return keepAliveTimeout;
73 * @brief setServerAddress sets the address of the DSM server
74 * @param address DSM server URL
76 void setServerAddress(const std::string& address)
78 serverAddress = address;
82 * @brief setDeviceId sets the device identifier
83 * @param id the device identifier
85 void setDeviceId(const std::string& id)
91 * @brief setKeepAliveTimeout sets KeepAlive timeout period
92 * @param keepalive KeepAlive timeout period
94 void setKeepAliveTimeout(const std::chrono::milliseconds& keepalive)
96 keepAliveTimeout = keepalive;
100 * @brief setLock sets lock state
101 * @param locked lock state to set
103 void setLock(bool locked)
109 * @brief loadDefaults loads default settings from the default configuration file
110 * @return true if successfully loaded and false otherwise
115 * @brief load loads settings from the configuration file
116 * @return true if successfully loaded and false otherwise
121 * @brief save saves settings to the file
122 * @return true if successfully saved and false otherwise
127 * @brief setSaveFileName sets the file path used to store settings
128 * @param fileName path to the file
130 void setSaveFileName(const std::string& fileName)
132 saveFileName = fileName;
136 * @brief getSaveFileName return the path of the file used to store settings
139 const std::string& getSaveFileName() const
145 * @brief isLoaded returns settings load state
146 * @return true if settings are loaded and false otherwise
148 bool isLoaded() const
154 * @brief isLocked return lock state
157 bool isLocked() const
165 * @brief Settings default constructor
169 bool _load(const std::string& fileName);
171 std::string serverAddress;
172 std::string deviceId;
173 std::chrono::milliseconds keepAliveTimeout;
174 std::string saveFileName;
177 static Settings _instance;
180 } // namespace communication