1 /*
2  * Copyright (c) 2024 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 
28 namespace OHOS {
29 namespace DistributedHardware {
30 class MetaCapabilityInfo : public CapabilityInfo {
31 public:
MetaCapabilityInfo()32     MetaCapabilityInfo()
33         : CapabilityInfo("", "", "", 0, DHType::UNKNOWN, "", ""), udidHash_(""), sinkVersion_("")
34     {}
35 
MetaCapabilityInfo(std::string dhId,std::string devId,std::string devName,uint16_t devType,DHType dhType,std::string dhAttrs,std::string dhSubtype,std::string udidHash,std::string sinkVersion)36     MetaCapabilityInfo(std::string dhId, std::string devId, std::string devName, uint16_t devType, DHType dhType,
37         std::string dhAttrs, std::string dhSubtype, std::string udidHash, std::string sinkVersion)
38         : CapabilityInfo(dhId, devId, devName, devType, dhType, dhAttrs, dhSubtype),
39           udidHash_(udidHash), sinkVersion_(sinkVersion) {}
40 
~MetaCapabilityInfo()41     virtual ~MetaCapabilityInfo() {}
42 
43     std::string GetUdidHash() const;
44     void SetUdidHash(const std::string &udidHash);
45     std::string GetSinkVersion() const;
46     void SetSinkVersion(const std::string &sinkVersion);
47 
48     virtual int32_t FromJsonString(const std::string &jsonStr);
49     virtual std::string ToJsonString();
50     bool Compare(const MetaCapabilityInfo& metaCapInfo);
51     virtual std::string GetKey() const;
52     virtual std::string GetAnonymousKey() const;
53 
54 private:
55     std::string udidHash_;
56     std::string sinkVersion_;
57 };
58 
59 void ToJson(cJSON *jsonObject, const MetaCapabilityInfo &metaCapInfo);
60 void FromJson(const cJSON *jsonObject, MetaCapabilityInfo &metaCapInfo);
61 
62 using MetaCapInfoMap = std::map<std::string, std::shared_ptr<MetaCapabilityInfo>>;
63 } // namespace DistributedHardware
64 } // namespace OHOS
65 #endif
66