• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #include "distributed_kv_data_manager.h"
17 
18 #include "mock_single_kv_store.h"
19 
20 namespace {
21     int32_t g_mockLocalDevice = 0;
22 }
23 
MockGetLocalDevice(int32_t mockRet)24 void MockGetLocalDevice(int32_t mockRet)
25 {
26     g_mockLocalDevice = mockRet;
27 }
28 
29 namespace OHOS {
30 namespace DistributedKv {
DistributedKvDataManager()31 DistributedKvDataManager::DistributedKvDataManager()
32 {}
33 
~DistributedKvDataManager()34 DistributedKvDataManager::~DistributedKvDataManager()
35 {}
36 
StartWatchDeviceChange(std::shared_ptr<DeviceStatusChangeListener> observer)37 Status DistributedKvDataManager::StartWatchDeviceChange(std::shared_ptr<DeviceStatusChangeListener> observer)
38 {
39     return Status::SUCCESS;
40 }
41 
StopWatchDeviceChange(std::shared_ptr<DeviceStatusChangeListener> observer)42 Status DistributedKvDataManager::StopWatchDeviceChange(std::shared_ptr<DeviceStatusChangeListener> observer)
43 {
44     return Status::SUCCESS;
45 }
46 
GetSingleKvStore(const Options & options,const AppId & appId,const StoreId & storeId,std::shared_ptr<SingleKvStore> & singleKvStore)47 Status DistributedKvDataManager::GetSingleKvStore(const Options &options, const AppId &appId, const StoreId &storeId,
48     std::shared_ptr<SingleKvStore> &singleKvStore)
49 {
50     std::shared_ptr<MockSingleKvStore> kvStore = std::make_shared<MockSingleKvStore>();
51     singleKvStore = std::static_pointer_cast<SingleKvStore>(kvStore);
52     return DistributedKv::Status::SUCCESS;
53 }
54 
GetLocalDevice(DeviceInfo & localDevice)55 Status DistributedKvDataManager::GetLocalDevice(DeviceInfo &localDevice)
56 {
57     localDevice.deviceId = "<localDeviceId>";
58     localDevice.deviceName = "<localDeviceName>";
59     localDevice.deviceType = "<localDeviceType>";
60     return static_cast<Status>(g_mockLocalDevice);
61 }
62 
GetDeviceList(std::vector<DeviceInfo> & deviceInfoList,DeviceFilterStrategy strategy)63 Status DistributedKvDataManager::GetDeviceList(std::vector<DeviceInfo> &deviceInfoList, DeviceFilterStrategy strategy)
64 {
65     DeviceInfo localDevice = {
66         .deviceId = "<localDeviceId>",
67         .deviceName = "<localDeviceName>",
68         .deviceType = "<localDeviceType>",
69     };
70     DeviceInfo remoteDevice = {
71         .deviceId = "<remoteDeviceId>",
72         .deviceName = "<remoteDeviceName>",
73         .deviceType = "<remoteDeviceType>",
74     };
75     deviceInfoList.clear();
76     deviceInfoList.push_back(localDevice);
77     deviceInfoList.push_back(remoteDevice);
78 
79     return Status::SUCCESS;
80 }
81 
CloseKvStore(const AppId & appId,const StoreId & storeId)82 Status DistributedKvDataManager::CloseKvStore(const AppId &appId, const StoreId &storeId)
83 {
84     return Status::SUCCESS;
85 }
86 
CloseKvStore(const AppId & appId,std::shared_ptr<SingleKvStore> & kvStorePtr)87 Status DistributedKvDataManager::CloseKvStore(const AppId &appId, std::shared_ptr<SingleKvStore> &kvStorePtr)
88 {
89     return Status::SUCCESS;
90 }
91 
DeleteKvStore(const AppId & appId,const StoreId & storeId,const std::string & path)92 Status DistributedKvDataManager::DeleteKvStore(const AppId &appId, const StoreId &storeId, const std::string &path)
93 {
94     return Status::SUCCESS;
95 }
96 }  // namespace DistributedKv
97 }  // namespace OHOS