• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef UDMF_DATA_MANAGER_H
17 #define UDMF_DATA_MANAGER_H
18 
19 #include <map>
20 #include <memory>
21 #include <mutex>
22 #include <vector>
23 
24 #include "error_code.h"
25 #include "store_cache.h"
26 #include "unified_data.h"
27 #include "unified_types.h"
28 
29 namespace OHOS {
30 namespace UDMF {
31 class DataManager {
32 public:
33     virtual ~DataManager();
34 
35     static DataManager &GetInstance();
36 
37     int32_t SaveData(CustomOption &option, UnifiedData &unifiedData, std::string &key);
38     int32_t RetrieveData(const QueryOption &query, UnifiedData &unifiedData);
39     int32_t RetrieveBatchData(const QueryOption &query, std::vector<UnifiedData> &unifiedDataSet);
40     int32_t UpdateData(const QueryOption &query, UnifiedData &unifiedData);
41     int32_t DeleteData(const QueryOption &query, std::vector<UnifiedData> &unifiedDataSet);
42     int32_t GetSummary(const QueryOption &query, Summary &summary);
43     int32_t AddPrivilege(const QueryOption &query, const Privilege &privilege);
44     int32_t Sync(const QueryOption &query, const std::vector<std::string> &devices);
45 
46 private:
47     DataManager();
48     int32_t QueryDataCommon(const QueryOption &query, std::vector<UnifiedData> &dataSet, std::shared_ptr<Store> &store);
49     int32_t ProcessingUri(const QueryOption &query, UnifiedData &unifiedData);
50     bool CheckPermissionInCache(const QueryOption &query);
51 
52     StoreCache storeCache_;
53     std::map<std::string, std::string> authorizationMap_;
54     std::map<std::string, Privilege> privilegeCache_;
55 };
56 } // namespace UDMF
57 } // namespace OHOS
58 #endif // UDMF_DATA_MANAGER_H
59