RDK Documentation (Open Sourced RDK Components)
XrdkCentralComRFCStore.h
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 2018 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 #ifndef XRDKCENTRALCOMRFCSTORE_H
21 #define XRDKCENTRALCOMRFCSTORE_H
22 
23 #include "hostIf_tr69ReqHandler.h"
24 
25 #include <unordered_map>
26 #include <string>
27 
28 using namespace std;
29 
30 class XRFCStore
31 {
32 public:
33  static XRFCStore* getInstance();
34  void clearAll();
35  void reloadCache();
36 
37  faultCode_t getValue(HOSTIF_MsgData_t *stMsgData);
38  faultCode_t setValue(HOSTIF_MsgData_t *stMsgData);
39 
40 private:
41 
42  static XRFCStore* xrfcInstance;
43  string m_filename;
44  string m_local_filename;
45  bool m_initDone;
46  bool m_updateInProgress;
47 
48  std::unordered_map<std::string, std::string> m_dict;
49  std::unordered_map<std::string, std::string> m_local_dict;
50  std::unordered_map<std::string, std::string> m_nonpersist_dict;
51  std::unordered_map<std::string, std::string> m_dict_rfcdefaults;
52 
53  XRFCStore();
54  XRFCStore(XRFCStore const&){};
55 
56  bool init();
57  string getRawValue(const string &key);
58  bool setRawValue(const string &key, const string &value);
59  faultCode_t clearValue(const string &key, const string &value);
60  bool writeHashToFile(const string &key, const string &value, unordered_map<string, string> &dict, const string &filename);
61  void initTR181PropertiesFileName();
62  bool loadFileToCache(const string &filename, unordered_map<string, string> &dict);
63  bool loadTR181PropertiesIntoCache();
64 };
65 
66 #endif // XRDKCENTRALCOMRFCSTORE_H
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
faultCode_t
enum _faultCodes faultCode_t
XRFCStore
Definition: XrdkCentralComRFCStore.h:30