blob: bd0c1044acdf2caedd11fb345ec73957a08afb52 [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
32// Reads the HIDL interface inheritance hierarchy JSON file at the given path.
33Result<InterfaceInheritanceHierarchyMap> ReadInterfaceInheritanceHierarchy(const std::string& path);
34
35// For the given set of interfaces / interface instances, checks that each
36// interface's hierarchy of inherited interfaces is also included in the given
37// interface set. Uses the provided hierarchy data.
38Result<void> CheckInterfaceInheritanceHierarchy(const std::set<std::string>& instances,
39 const InterfaceInheritanceHierarchyMap& hierarchy);
40Result<void> CheckInterfaceInheritanceHierarchy(const std::set<android::FQName>& interfaces,
41 const InterfaceInheritanceHierarchyMap& hierarchy);
42
43// Saves the set of known interfaces using the provided HIDL interface
44// inheritance hierarchy.
45void SetKnownInterfaces(const InterfaceInheritanceHierarchyMap& hierarchy);
46
47// Checks if the provided interface is in the set of known interfaces. Returns
48// an empty Result if present, otherwise an Error.
49Result<void> IsKnownInterface(const std::string& instance);
50Result<void> IsKnownInterface(const FQName& intf);
51
52} // namespace init
53} // namespace android