summaryrefslogtreecommitdiffstats
blob: 14cf5bf0733b8c3135a1a63a194f09de563ef605 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_VINTF_MATRIX_KERNEL_H
#define ANDROID_VINTF_MATRIX_KERNEL_H

#include <string>
#include <vector>
#include <utility>

#include "KernelConfigTypedValue.h"
#include "Version.h"

namespace android {
namespace vintf {

struct KernelConfigKey : public std::string {
    KernelConfigKey() : std::string() {}
    KernelConfigKey(const std::string &other) : std::string(other) {}
    KernelConfigKey(std::string &&other) : std::string(std::forward<std::string>(other)) {}
};

using KernelConfig = std::pair<KernelConfigKey, KernelConfigTypedValue>;

// A <kernel> entry to a compatibility matrix represents a fragment of kernel
// config requirements.
struct MatrixKernel {

    MatrixKernel() {}
    MatrixKernel(KernelVersion &&minLts, std::vector<KernelConfig> &&configs)
            : mMinLts(std::move(minLts)), mConfigs(std::move(configs)) {}

    bool operator==(const MatrixKernel &other) const;

    inline const KernelVersion &minLts() const { return mMinLts; }

    // Return an iterable on all kernel configs. Use it as follows:
    // for (const KernelConfig &config : kernel.configs()) {...}
    const std::vector<KernelConfig> &configs() const { return mConfigs; }

    // Return an iterable on all kernel config conditions. Use it as follows:
    // for (const KernelConfig &config : kernel.conditions()) {...}
    const std::vector<KernelConfig>& conditions() const { return mConditions; }

   private:
    friend struct MatrixKernelConverter;
    friend struct MatrixKernelConditionsConverter;
    friend struct CompatibilityMatrix;
    friend class AssembleVintfImpl;

    KernelVersion mMinLts;
    std::vector<KernelConfig> mConfigs;
    std::vector<KernelConfig> mConditions;
};

} // namespace vintf
} // namespace android

#endif // ANDROID_VINTF_MATRIX_KERNEL_H