RDK Documentation (Open Sourced RDK Components)
XrdkCentralComBSStore.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 2019 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 XRDKCENTRALCOMBSSTORE_H
21 #define XRDKCENTRALCOMBSSTORE_H
22 
23 #include <unordered_map>
24 #include <string>
25 #include <thread>
26 #include <mutex>
27 #include <condition_variable>
28 #include <XrdkCentralComBSStoreJournal.h>
29 #include "cJSON.h"
30 
31 using namespace std;
32 
33 class XBSStore
34 {
35 public:
36  static XBSStore* getInstance();
37  void stop();
38  faultCode_t getValue(HOSTIF_MsgData_t *stMsgData);
39  faultCode_t overrideValue(HOSTIF_MsgData_t *stMsgData);
40  // adding a member function to call loadjson
41  bool call_loadJson() { return loadFromJson(); }
42 
43 private:
44  static XBSStore* xbsInstance;
45  static XBSStoreJournal* xbsJournalInstance;
46  string m_filename;
47  bool m_initDone;
48  bool m_initialUpdate;
49  bool m_rfcUpdateInProgress;
50  static thread partnerIdThread;
51  static recursive_mutex mtx;
52  static bool m_stopped;
53  static mutex mtx_stopped;
54  static condition_variable cv;
55  static mutex g_instance_mutex;
56  std::unordered_map<std::string, std::string> m_dict;
57 
58  XBSStore();
59  XBSStore(XBSStore const&){};
60 
61  bool init();
62  string getRawValue(const string &key);
63  bool setRawValue(const string &key, const string &value, HostIf_Source_Type_t sourceType);
64 
65  void initBSPropertiesFileName();
66  bool loadBSPropertiesIntoCache();
67  void resetCacheAndStore();
68  bool getPartnerDeviceConfig(cJSON* partnerConfig, const string & partnerId);
69  bool loadFromJson();
70  bool clearRfcValues();
71  static void getAuthServicePartnerID();
72 };
73 
74 #endif // XRDKCENTRALCOMBSSTORE_H
75 
XBSStore
Definition: XrdkCentralComBSStore.h:33
HostIf_Source_Type_t
enum _HostIf_Source_Type_t HostIf_Source_Type_t
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
XBSStoreJournal
Definition: XrdkCentralComBSStoreJournal.h:43
faultCode_t
enum _faultCodes faultCode_t