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 compVersion_.dhType = DHType::UNKNOWN; 38 } 39 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)40 MetaCapabilityInfo(std::string dhId, std::string devId, std::string devName, uint16_t devType, DHType dhType, 41 std::string dhAttrs, std::string dhSubtype, std::string udidHash, CompVersion compVersion) 42 : CapabilityInfo(dhId, devId, devName, devType, dhType, dhAttrs, dhSubtype), 43 udidHash_(udidHash), compVersion_(compVersion) {} 44 ~MetaCapabilityInfo()45 virtual ~MetaCapabilityInfo() {} 46 47 std::string GetUdidHash() const; 48 void SetUdidHash(const std::string &udidHash); 49 std::string GetSinkVersion() const; 50 void SetSinkVersion(const std::string &sinkVersion); 51 CompVersion& GetCompVersion(); 52 CompVersion GetCompVersion() const; 53 void SetCompVersion(const CompVersion &compVersion); 54 55 virtual int32_t FromJsonString(const std::string &jsonStr); 56 virtual std::string ToJsonString(); 57 bool Compare(const MetaCapabilityInfo& metaCapInfo); 58 virtual std::string GetKey() const; 59 virtual std::string GetAnonymousKey() const; 60 61 private: 62 std::string udidHash_; 63 CompVersion compVersion_; 64 }; 65 66 void ToJson(cJSON *jsonObject, const MetaCapabilityInfo &metaCapInfo); 67 void FromJson(const cJSON *jsonObject, MetaCapabilityInfo &metaCapInfo); 68 void FromJsonContinue(const cJSON *jsonObject, MetaCapabilityInfo &metaCapInfo); 69 70 using MetaCapInfoMap = std::map<std::string, std::shared_ptr<MetaCapabilityInfo>>; 71 } // namespace DistributedHardware 72 } // namespace OHOS 73 #endif 74