MatrixKernel.h 2.4 KB

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