1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef ANDROID_VINTF_VNDK_H
19 #define ANDROID_VINTF_VNDK_H
20 
21 #include <set>
22 #include <string>
23 
24 namespace android {
25 namespace vintf {
26 
27 struct VndkVersionRange {
28 
VndkVersionRangeVndkVersionRange29     VndkVersionRange() : VndkVersionRange(0u, 0u, 0u) {}
VndkVersionRangeVndkVersionRange30     VndkVersionRange(size_t s, size_t v, size_t p)
31         : VndkVersionRange(s, v, p, p) {}
VndkVersionRangeVndkVersionRange32     VndkVersionRange(size_t s, size_t v, size_t pi, size_t pa)
33         : sdk(s), vndk(v), patchMin(pi), patchMax(pa) {}
34 
isSingleVersionVndkVersionRange35     inline bool isSingleVersion() const { return patchMin == patchMax; };
36 
37     size_t sdk;
38     size_t vndk;
39     size_t patchMin;
40     size_t patchMax;
41 };
42 
43 struct Vndk {
44 
versionRangeVndk45     const VndkVersionRange &versionRange() const { return mVersionRange; }
librariesVndk46     const std::set<std::string> &libraries() const { return mLibraries; }
47 
48 private:
49     friend struct VndkConverter;
50     friend struct HalManifestConverter;
51     friend struct LibVintfTest;
52     friend struct HalManifest;
53     friend struct CompatibilityMatrix;
54     friend bool operator==(const Vndk &, const Vndk &);
55     VndkVersionRange mVersionRange;
56     std::set<std::string> mLibraries;
57 };
58 
59 inline bool operator==(const VndkVersionRange &lft, const VndkVersionRange &rgt) {
60     return lft.sdk == rgt.sdk && lft.vndk == rgt.vndk &&
61            lft.patchMin == rgt.patchMin && lft.patchMax == rgt.patchMax;
62 }
63 inline bool operator==(const Vndk &lft, const Vndk &rgt) {
64     return lft.mVersionRange == rgt.mVersionRange &&
65            lft.mLibraries == rgt.mLibraries;
66 }
67 
68 } // namespace vintf
69 } // namespace android
70 
71 #endif // ANDROID_VINTF_VNDK_H
72