RDK Documentation (Open Sourced RDK Components)
hostPersistence.hpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 
22 
23 /**
24 * @defgroup devicesettings
25 * @{
26 * @defgroup rpc
27 * @{
28 **/
29 
30 
31 #ifndef _DS_MGR_HOSTPERSISTENCE_HPP_
32 #define _DS_MGR_HOSTPERSISTENCE_HPP_
33 #include <map>
34 /* This namespace is used to defined custom Hash table which has provision
35  to write to local storage for a back up and recover it upon request */
36 namespace device {
37 
39  std::map <std::string, std::string> _properties;
40  std::map <std::string, std::string> _defaultProperties;
41  std::string filePath;
42  std::string defaultFilePath;
43 
44  void loadFromFile (const std::string &file, std::map <std::string, std::string> &map);
45  void writeToFile (const std::string &file);
46 
47 public:
49  HostPersistence (const std::string &storeFolder);
50  static HostPersistence& getInstance(void);
51  virtual ~HostPersistence();
52  void load();
53  std::string getProperty(const std::string &key);
54  std::string getProperty(const std::string &key, const std::string &defValue);
55  std::string getDefaultProperty(const std::string &key);
56  void persistHostProperty(const std::string &key, const std::string &value);
57 };
58 
59 }
60 
61 #endif /* _DS_HOSTPERSISTENCE_HPP_ */
62 
63 
64 
65 
66 /** @} */
67 /** @} */
device::HostPersistence::persistHostProperty
void persistHostProperty(const std::string &key, const std::string &value)
Definition: hostPersistence.cpp:273
device::HostPersistence::HostPersistence
HostPersistence()
Definition: hostPersistence.cpp:81
device::HostPersistence::loadFromFile
void loadFromFile(const std::string &file, std::map< std::string, std::string > &map)
Definition: hostPersistence.cpp:324
device::HostPersistence::writeToFile
void writeToFile(const std::string &file)
Definition: hostPersistence.cpp:357
device::HostPersistence::load
void load()
Definition: hostPersistence.cpp:133
device::HostPersistence::getDefaultProperty
std::string getDefaultProperty(const std::string &key)
Definition: hostPersistence.cpp:239
device::HostPersistence::getInstance
static HostPersistence & getInstance(void)
Definition: hostPersistence.cpp:122
device::HostPersistence
Definition: hostPersistence.hpp:38