• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 represents a fragment of kernel
39 // config requirements.
40 struct MatrixKernel {
41 
MatrixKernelMatrixKernel42     MatrixKernel() {}
MatrixKernelMatrixKernel43     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 
minLtsMatrixKernel48     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()) {...}
configsMatrixKernel52     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()) {...}
conditionsMatrixKernel56     const std::vector<KernelConfig>& conditions() const { return mConditions; }
57 
58    private:
59     friend struct MatrixKernelConverter;
60     friend struct MatrixKernelConditionsConverter;
61     friend struct CompatibilityMatrix;
62     friend class AssembleVintfImpl;
63 
64     KernelVersion mMinLts;
65     std::vector<KernelConfig> mConfigs;
66     std::vector<KernelConfig> mConditions;
67 };
68 
69 } // namespace vintf
70 } // namespace android
71 
72 #endif // ANDROID_VINTF_MATRIX_KERNEL_H
73