Home | History | Annotate | Download | only in vintf
      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 
     44     inline bool hasVersion(Version v) const {
     45         return std::find(versions.begin(), versions.end(), v) != versions.end();
     46     }
     47     inline Transport transport() const {
     48         return transportArch.transport;
     49     }
     50 
     51     inline const std::string& getName() const { return name; }
     52 
     53    private:
     54     friend struct LibVintfTest;
     55     friend struct ManifestHalConverter;
     56     friend struct HalManifest;
     57     friend bool parse(const std::string &s, ManifestHal *hal);
     58 
     59     // Whether this hal is a valid one. Note that an empty ManifestHal
     60     // (constructed via ManifestHal()) is valid.
     61     bool isValid() const;
     62 };
     63 
     64 } // namespace vintf
     65 } // namespace android
     66 
     67 #endif // ANDROID_VINTF_MANIFEST_HAL_H
     68