1676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong/* 2676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * Copyright (C) 2017 The Android Open Source Project 3676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * 4676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * Licensed under the Apache License, Version 2.0 (the "License"); 5676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * you may not use this file except in compliance with the License. 6676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * You may obtain a copy of the License at 7676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * 8676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * http://www.apache.org/licenses/LICENSE-2.0 9676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * 10676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * Unless required by applicable law or agreed to in writing, software 11676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * distributed under the License is distributed on an "AS IS" BASIS, 12676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * See the License for the specific language governing permissions and 14676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong * limitations under the License. 15676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong */ 16676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong 17676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong#ifndef ANDROID_VINTF_MATRIX_KERNEL_H 18676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong#define ANDROID_VINTF_MATRIX_KERNEL_H 19676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong 203f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong#include <string> 21676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong#include <vector> 223f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong#include <utility> 23676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong 243f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong#include "KernelConfigTypedValue.h" 25676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong#include "Version.h" 26676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong 27676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hongnamespace android { 28676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hongnamespace vintf { 29676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong 303f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hongstruct KernelConfigKey : public std::string { 313f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong KernelConfigKey() : std::string() {} 323f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong KernelConfigKey(const std::string &other) : std::string(other) {} 333f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong KernelConfigKey(std::string &&other) : std::string(std::forward<std::string>(other)) {} 343f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong}; 353f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong 363f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hongusing KernelConfig = std::pair<KernelConfigKey, KernelConfigTypedValue>; 373f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong 38d776d20386b03780f31856dcee687c5f3187aa3eYifan Hong// A <kernel> entry to a compatibility matrix represents a fragment of kernel 39d776d20386b03780f31856dcee687c5f3187aa3eYifan Hong// config requirements. 40676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hongstruct MatrixKernel { 41676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong 423f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong MatrixKernel() {} 433f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong MatrixKernel(KernelVersion &&minLts, std::vector<KernelConfig> &&configs) 443f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong : mMinLts(std::move(minLts)), mConfigs(std::move(configs)) {} 453f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong 46676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong bool operator==(const MatrixKernel &other) const; 47676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong 483f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong inline const KernelVersion &minLts() const { return mMinLts; } 493f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong 503f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong // Return an iterable on all kernel configs. Use it as follows: 513f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong // for (const KernelConfig &config : kernel.configs()) {...} 523f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong const std::vector<KernelConfig> &configs() const { return mConfigs; } 533f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong 54ff0a5636b60be69ac61057bc8070b836d49f2fa4Yifan Hong // Return an iterable on all kernel config conditions. Use it as follows: 55ff0a5636b60be69ac61057bc8070b836d49f2fa4Yifan Hong // for (const KernelConfig &config : kernel.conditions()) {...} 56ff0a5636b60be69ac61057bc8070b836d49f2fa4Yifan Hong const std::vector<KernelConfig>& conditions() const { return mConditions; } 57ff0a5636b60be69ac61057bc8070b836d49f2fa4Yifan Hong 58ff0a5636b60be69ac61057bc8070b836d49f2fa4Yifan Hong private: 593f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong friend struct MatrixKernelConverter; 60ff0a5636b60be69ac61057bc8070b836d49f2fa4Yifan Hong friend struct MatrixKernelConditionsConverter; 618302cea08dea5238cbc4d2637ff90319480971aeYifan Hong friend class AssembleVintfImpl; 623f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong 633f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong KernelVersion mMinLts; 643f5489a519f5f1a7eb8bd7873a3170057502d93bYifan Hong std::vector<KernelConfig> mConfigs; 65ff0a5636b60be69ac61057bc8070b836d49f2fa4Yifan Hong std::vector<KernelConfig> mConditions; 66676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong}; 67676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong 68676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong} // namespace vintf 69676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong} // namespace android 70676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong 71676447acd00ebf93d1023f79fc02b5cbbb86dda2Yifan Hong#endif // ANDROID_VINTF_MATRIX_KERNEL_H 72