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