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 27 namespace android { 28 namespace vintf { 29 30 struct KernelConfigKey : public std::string { KernelConfigKeyKernelConfigKey31 KernelConfigKey() : std::string() {} KernelConfigKeyKernelConfigKey32 KernelConfigKey(const std::string &other) : std::string(other) {} KernelConfigKeyKernelConfigKey33 KernelConfigKey(std::string &&other) : std::string(std::forward<std::string>(other)) {} 34 }; 35 36 using KernelConfig = std::pair<KernelConfigKey, KernelConfigTypedValue>; 37 38 // A kernel entry to a compatibility matrix 39 struct MatrixKernel { 40 MatrixKernelMatrixKernel41 MatrixKernel() {} MatrixKernelMatrixKernel42 MatrixKernel(KernelVersion &&minLts, std::vector<KernelConfig> &&configs) 43 : mMinLts(std::move(minLts)), mConfigs(std::move(configs)) {} 44 45 bool operator==(const MatrixKernel &other) const; 46 minLtsMatrixKernel47 inline const KernelVersion &minLts() const { return mMinLts; } 48 49 // Return an iterable on all kernel configs. Use it as follows: 50 // for (const KernelConfig &config : kernel.configs()) {...} configsMatrixKernel51 const std::vector<KernelConfig> &configs() const { return mConfigs; } 52 53 private: 54 friend struct MatrixKernelConverter; 55 56 KernelVersion mMinLts; 57 std::vector<KernelConfig> mConfigs; 58 }; 59 60 } // namespace vintf 61 } // namespace android 62 63 #endif // ANDROID_VINTF_MATRIX_KERNEL_H 64