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#ifndef ANDROID_VINTF_MATRIX_KERNEL_H 18#define ANDROID_VINTF_MATRIX_KERNEL_H 19 20#include <string> 21#include <vector> 22#include <utility> 23 24#include "KernelConfigTypedValue.h" 25#include "Version.h" 26 27namespace android { 28namespace vintf { 29 30struct KernelConfigKey : public std::string { 31 KernelConfigKey() : std::string() {} 32 KernelConfigKey(const std::string &other) : std::string(other) {} 33 KernelConfigKey(std::string &&other) : std::string(std::forward<std::string>(other)) {} 34}; 35 36using KernelConfig = std::pair<KernelConfigKey, KernelConfigTypedValue>; 37 38// A <kernel> entry to a compatibility matrix represents a fragment of kernel 39// config requirements. 40struct MatrixKernel { 41 42 MatrixKernel() {} 43 MatrixKernel(KernelVersion &&minLts, std::vector<KernelConfig> &&configs) 44 : mMinLts(std::move(minLts)), mConfigs(std::move(configs)) {} 45 46 bool operator==(const MatrixKernel &other) const; 47 48 inline const KernelVersion &minLts() const { return mMinLts; } 49 50 // Return an iterable on all kernel configs. Use it as follows: 51 // for (const KernelConfig &config : kernel.configs()) {...} 52 const std::vector<KernelConfig> &configs() const { return mConfigs; } 53 54 // Return an iterable on all kernel config conditions. Use it as follows: 55 // for (const KernelConfig &config : kernel.conditions()) {...} 56 const std::vector<KernelConfig>& conditions() const { return mConditions; } 57 58 private: 59 friend struct MatrixKernelConverter; 60 friend struct MatrixKernelConditionsConverter; 61 friend class AssembleVintfImpl; 62 63 KernelVersion mMinLts; 64 std::vector<KernelConfig> mConfigs; 65 std::vector<KernelConfig> mConditions; 66}; 67 68} // namespace vintf 69} // namespace android 70 71#endif // ANDROID_VINTF_MATRIX_KERNEL_H 72