1 /* 2 * Copyright (c) 2021-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 #ifndef OHOS_FORM_FWK_FORM_ID_KEY_H 17 #define OHOS_FORM_FWK_FORM_ID_KEY_H 18 19 #include <string> 20 21 namespace OHOS { 22 namespace AppExecFwk { 23 struct FormIdKey { 24 public: FormIdKeyFormIdKey25 FormIdKey(std::string &bundleName, std::string &abilityName) 26 : bundleName(bundleName), moduleName(), abilityName(abilityName), formName(), specificationId(0), orientation(0) 27 { 28 } 29 30 std::string bundleName; 31 std::string moduleName; 32 std::string abilityName; 33 std::string formName; 34 int specificationId; 35 int orientation; 36 37 bool operator== (const FormIdKey &formIdKey) const 38 { 39 return specificationId == formIdKey.specificationId 40 && orientation == formIdKey.orientation 41 && bundleName == formIdKey.bundleName 42 && moduleName == formIdKey.moduleName 43 && abilityName == formIdKey.abilityName 44 && formName == formIdKey.formName; 45 } 46 /** 47 * @brief overloaded == for Indicates the formDBInfo by formId 48 * @return Returns true if the data equal; returns false otherwise. 49 */ 50 bool operator< (const FormIdKey &formIdKey) const 51 { 52 return specificationId != formIdKey.specificationId 53 || orientation != formIdKey.orientation 54 || bundleName != formIdKey.bundleName 55 || moduleName != formIdKey.moduleName 56 || abilityName != formIdKey.abilityName 57 || formName != formIdKey.formName; 58 } hashCodeFormIdKey59 int hashCode() 60 { 61 return std::hash<std::string>()(bundleName) 62 + std::hash<std::string>()(moduleName) 63 + std::hash<std::string>()(abilityName) 64 + std::hash<std::string>()(formName) 65 + std::hash<int>()(specificationId) 66 + std::hash<int>()(orientation); 67 } 68 }; 69 } // namespace AppExecFwk 70 } // namespace OHOS 71 72 #endif // OHOS_FORM_FWK_FORM_ID_KEY_H 73