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_MANIFEST_HAL_H 19 #define ANDROID_VINTF_MANIFEST_HAL_H 20 21 #include <string> 22 #include <vector> 23 #include <map> 24 25 #include "HalFormat.h" 26 #include "HalInterface.h" 27 #include "TransportArch.h" 28 #include "Version.h" 29 30 namespace android { 31 namespace vintf { 32 33 // A component of HalManifest. 34 struct ManifestHal { 35 36 bool operator==(const ManifestHal &other) const; 37 38 HalFormat format = HalFormat::HIDL; 39 std::string name; 40 std::vector<Version> versions; 41 TransportArch transportArch; 42 std::map<std::string, HalInterface> interfaces; 43 hasVersionManifestHal44 inline bool hasVersion(Version v) const { 45 return std::find(versions.begin(), versions.end(), v) != versions.end(); 46 } transportManifestHal47 inline Transport transport() const { 48 return transportArch.transport; 49 } 50 51 private: 52 friend struct LibVintfTest; 53 friend struct ManifestHalConverter; 54 friend struct HalManifest; 55 friend bool parse(const std::string &s, ManifestHal *hal); 56 57 // Whether this hal is a valid one. Note that an empty ManifestHal 58 // (constructed via ManifestHal()) is valid. 59 bool isValid() const; 60 }; 61 62 } // namespace vintf 63 } // namespace android 64 65 #endif // ANDROID_VINTF_MANIFEST_HAL_H 66