• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-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_META_CAPABILITY_INFO_H
17 #define OHOS_DISTRIBUTED_HARDWARE_META_CAPABILITY_INFO_H
18 
19 #include <list>
20 #include <memory>
21 #include <map>
22 
23 #include "cJSON.h"
24 
25 #include "capability_info.h"
26 #include "device_type.h"
27 #include "impl_utils.h"
28 
29 namespace OHOS {
30 namespace DistributedHardware {
31 class MetaCapabilityInfo : public CapabilityInfo {
32 public:
MetaCapabilityInfo()33     MetaCapabilityInfo()
34         : CapabilityInfo("", "", "", 0, DHType::UNKNOWN, "", ""), udidHash_("")
35     {
36         compVersion_.haveFeature = false;
37     }
38 
MetaCapabilityInfo(std::string dhId,std::string devId,std::string devName,uint16_t devType,DHType dhType,std::string dhAttrs,std::string dhSubtype,std::string udidHash,CompVersion compVersion)39     MetaCapabilityInfo(std::string dhId, std::string devId, std::string devName, uint16_t devType, DHType dhType,
40         std::string dhAttrs, std::string dhSubtype, std::string udidHash, CompVersion compVersion)
41         : CapabilityInfo(dhId, devId, devName, devType, dhType, dhAttrs, dhSubtype),
42           udidHash_(udidHash), compVersion_(compVersion) {}
43 
~MetaCapabilityInfo()44     virtual ~MetaCapabilityInfo() {}
45 
46     std::string GetUdidHash() const;
47     void SetUdidHash(const std::string &udidHash);
48     std::string GetSinkVersion() const;
49     void SetSinkVersion(const std::string &sinkVersion);
50     CompVersion& GetCompVersion();
51     CompVersion GetCompVersion() const;
52     void SetCompVersion(const CompVersion &compVersion);
53 
54     virtual int32_t FromJsonString(const std::string &jsonStr);
55     virtual std::string ToJsonString();
56     bool Compare(const MetaCapabilityInfo& metaCapInfo);
57     virtual std::string GetKey() const;
58     virtual std::string GetAnonymousKey() const;
59 
60 private:
61     std::string udidHash_;
62     CompVersion compVersion_;
63 };
64 
65 void ToJson(cJSON *jsonObject, const MetaCapabilityInfo &metaCapInfo);
66 void FromJson(const cJSON *jsonObject, MetaCapabilityInfo &metaCapInfo);
67 void FromJsonContinue(const cJSON *jsonObject, MetaCapabilityInfo &metaCapInfo);
68 
69 using MetaCapInfoMap = std::map<std::string, std::shared_ptr<MetaCapabilityInfo>>;
70 } // namespace DistributedHardware
71 } // namespace OHOS
72 #endif
73