Yifan Hong | 2a90ffe | 2018-03-05 17:45:34 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | #include "MatrixInstance.h" |
| 18 | |
| 19 | #include <utility> |
| 20 | |
| 21 | namespace android { |
| 22 | namespace vintf { |
| 23 | |
Yifan Hong | cf231a9 | 2018-03-13 14:19:13 -0700 | [diff] [blame] | 24 | MatrixInstance::MatrixInstance() = default; |
| 25 | |
| 26 | MatrixInstance::MatrixInstance(const MatrixInstance&) = default; |
| 27 | |
| 28 | MatrixInstance::MatrixInstance(MatrixInstance&&) = default; |
| 29 | |
| 30 | MatrixInstance& MatrixInstance::operator=(const MatrixInstance&) = default; |
| 31 | |
| 32 | MatrixInstance& MatrixInstance::operator=(MatrixInstance&&) = default; |
| 33 | |
Yifan Hong | 2a90ffe | 2018-03-05 17:45:34 -0800 | [diff] [blame] | 34 | MatrixInstance::MatrixInstance(FqInstance&& fqInstance, VersionRange&& range, bool optional) |
| 35 | : mFqInstance(std::move(fqInstance)), mRange(std::move(range)), mOptional(optional) {} |
| 36 | |
| 37 | MatrixInstance::MatrixInstance(const FqInstance fqInstance, const VersionRange& range, |
| 38 | bool optional) |
| 39 | : mFqInstance(fqInstance), mRange(range), mOptional(optional) {} |
| 40 | |
| 41 | const std::string& MatrixInstance::package() const { |
| 42 | return mFqInstance.getPackage(); |
| 43 | } |
| 44 | |
| 45 | const VersionRange& MatrixInstance::versionRange() const { |
| 46 | return mRange; |
| 47 | } |
| 48 | |
| 49 | const std::string& MatrixInstance::interface() const { |
| 50 | return mFqInstance.getInterface(); |
| 51 | } |
| 52 | |
| 53 | const std::string& MatrixInstance::instance() const { |
| 54 | return mFqInstance.getInstance(); |
| 55 | } |
| 56 | |
| 57 | bool MatrixInstance::optional() const { |
| 58 | return mOptional; |
| 59 | } |
| 60 | |
Yifan Hong | 075b363 | 2018-03-14 16:03:11 -0700 | [diff] [blame] | 61 | bool MatrixInstance::isSatisfiedBy(const FqInstance& provided) const { |
| 62 | return package() == provided.getPackage() && |
| 63 | versionRange().supportedBy(provided.getVersion()) && |
| 64 | interface() == provided.getInterface() && instance() == provided.getInstance(); |
| 65 | } |
| 66 | |
Yifan Hong | 2a90ffe | 2018-03-05 17:45:34 -0800 | [diff] [blame] | 67 | } // namespace vintf |
| 68 | } // namespace android |