blob: 4ca377f644683bbefe348f4969d002bcc02c7ec1 [file] [log] [blame]
Daniel Normand2533c32019-08-02 15:13:50 -07001/*
2 * Copyright (C) 2019 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#pragma once
18
19#include <map>
20#include <set>
21#include <string>
22
23#include <hidl-util/FQName.h>
24
25#include "result.h"
26
27namespace android {
28namespace init {
29
30using InterfaceInheritanceHierarchyMap = std::map<android::FQName, std::set<android::FQName>>;
31
Daniel Normand2533c32019-08-02 15:13:50 -070032// For the given set of interfaces / interface instances, checks that each
33// interface's hierarchy of inherited interfaces is also included in the given
34// interface set. Uses the provided hierarchy data.
35Result<void> CheckInterfaceInheritanceHierarchy(const std::set<std::string>& instances,
36 const InterfaceInheritanceHierarchyMap& hierarchy);
37Result<void> CheckInterfaceInheritanceHierarchy(const std::set<android::FQName>& interfaces,
38 const InterfaceInheritanceHierarchyMap& hierarchy);
39
40// Saves the set of known interfaces using the provided HIDL interface
41// inheritance hierarchy.
42void SetKnownInterfaces(const InterfaceInheritanceHierarchyMap& hierarchy);
43
44// Checks if the provided interface is in the set of known interfaces. Returns
45// an empty Result if present, otherwise an Error.
46Result<void> IsKnownInterface(const std::string& instance);
47Result<void> IsKnownInterface(const FQName& intf);
48
49} // namespace init
50} // namespace android