blob: 47094fb45ec7f6fd5d07a8ea13610fafc9da21c0 [file] [log] [blame]
Yifan Hong676447a2016-11-15 12:57:23 -08001/*
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#ifndef ANDROID_VINTF_MATRIX_HAL_H
18#define ANDROID_VINTF_MATRIX_HAL_H
19
Yifan Hong9cd9eb02017-05-17 18:36:08 -070020#include <map>
Zhuoyao Zhangc7e75bd2017-10-29 17:20:19 -070021#include <set>
Yifan Hong676447a2016-11-15 12:57:23 -080022#include <string>
23#include <vector>
24
25#include "HalFormat.h"
Yifan Hong9cd9eb02017-05-17 18:36:08 -070026#include "HalInterface.h"
Yifan Hong676447a2016-11-15 12:57:23 -080027#include "VersionRange.h"
28
29namespace android {
30namespace vintf {
31
32// A HAL entry to a compatibility matrix
33struct MatrixHal {
34
35 bool operator==(const MatrixHal &other) const;
Zhuoyao Zhangc7e75bd2017-10-29 17:20:19 -070036 // Check whether the MatrixHal contains the given version.
37 bool containsVersion(const Version& version) const;
38 // Get all instances of the ManifestHal with given interface name.
39 std::set<std::string> getInstances(const std::string& interfaceName) const;
Yifan Hong676447a2016-11-15 12:57:23 -080040
41 HalFormat format = HalFormat::HIDL;
42 std::string name;
43 std::vector<VersionRange> versionRanges;
44 bool optional = false;
Yifan Hong9cd9eb02017-05-17 18:36:08 -070045 std::map<std::string, HalInterface> interfaces;
Yifan Hong0fd7aef2017-05-24 14:37:19 -070046
47 inline const std::string& getName() const { return name; }
Zhuoyao Zhangc7e75bd2017-10-29 17:20:19 -070048 inline bool hasInterface(const std::string& interface_name) const {
49 return interfaces.find(interface_name) != interfaces.end();
50 }
Yifan Hong7b2970a2017-12-11 19:06:11 -080051
52 // Return true if "this" contains all interface/instance instances in "other".
53 bool containsInstances(const MatrixHal& other) const;
Yifan Hong676447a2016-11-15 12:57:23 -080054};
55
56} // namespace vintf
57} // namespace android
58
59#endif // ANDROID_VINTF_MATRIX_HAL_H