• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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 OHOS_DISTRIBUTED_HARDWARE_VERSION_MANAGER_H
17 #define OHOS_DISTRIBUTED_HARDWARE_VERSION_MANAGER_H
18 
19 #include <mutex>
20 #include <vector>
21 #include <string>
22 
23 #include "single_instance.h"
24 #include "distributed_hardware_errno.h"
25 #include "device_type.h"
26 #include "utils/impl_utils.h"
27 
28 namespace OHOS {
29 namespace DistributedHardware {
30 class VersionManager {
31     DECLARE_SINGLE_INSTANCE_BASE(VersionManager);
32 
33 public:
VersionManager()34     VersionManager() {}
~VersionManager()35     ~VersionManager() {}
36     int32_t Init();
37     void UnInit();
38     int32_t AddDHVersion(const std::string &uuid, const DHVersion &dhVersion);
39     int32_t RemoveDHVersion(const std::string &uuid);
40     int32_t GetDHVersion(const std::string &uuid, DHVersion &dhVersion);
41     int32_t GetCompVersion(const std::string &uuid, const DHType dhType, CompVersion &compVersion);
42     int32_t SyncDHVersionFromDB(const std::string &uuid, DHVersion &dhVersion);
43     std::string GetLocalDeviceVersion();
44     void ShowLocalVersion(const DHVersion &dhVersion) const;
45 
46 private:
47     std::unordered_map<std::string, DHVersion> dhVersions_;
48     std::mutex versionMutex_;
49 };
50 } // namespace DistributedHardware
51 } // namespace OHOS
52 #endif
53