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 #ifndef LIBVINTF_TARGET 18 #define LOG_TAG "libvintf" 19 #include <android-base/logging.h> 20 #endif 21 22 #include "ManifestInstance.h" 23 24 #include <utility> 25 26 namespace android { 27 namespace vintf { 28 29 ManifestInstance::ManifestInstance() = default; 30 31 ManifestInstance::ManifestInstance(const ManifestInstance&) = default; 32 33 ManifestInstance::ManifestInstance(ManifestInstance&&) = default; 34 35 ManifestInstance& ManifestInstance::operator=(const ManifestInstance&) = default; 36 37 ManifestInstance& ManifestInstance::operator=(ManifestInstance&&) = default; 38 39 ManifestInstance::ManifestInstance(FqInstance&& fqInstance, TransportArch&& ta, HalFormat fmt) 40 : mFqInstance(std::move(fqInstance)), mTransportArch(std::move(ta)), mHalFormat(fmt) {} 41 ManifestInstance::ManifestInstance(const FqInstance& fqInstance, const TransportArch& ta, 42 HalFormat fmt) 43 : mFqInstance(fqInstance), mTransportArch(ta), mHalFormat(fmt) {} 44 45 const std::string& ManifestInstance::package() const { 46 return mFqInstance.getPackage(); 47 } 48 49 Version ManifestInstance::version() const { 50 return mFqInstance.getVersion(); 51 } 52 53 const std::string& ManifestInstance::interface() const { 54 return mFqInstance.getInterface(); 55 } 56 57 const std::string& ManifestInstance::instance() const { 58 return mFqInstance.getInstance(); 59 } 60 61 Transport ManifestInstance::transport() const { 62 return mTransportArch.transport; 63 } 64 65 Arch ManifestInstance::arch() const { 66 return mTransportArch.arch; 67 } 68 69 HalFormat ManifestInstance::format() const { 70 return mHalFormat; 71 } 72 73 const FqInstance& ManifestInstance::getFqInstance() const { 74 return mFqInstance; 75 } 76 77 bool ManifestInstance::operator==(const ManifestInstance& other) const { 78 return mFqInstance == other.mFqInstance && mTransportArch == other.mTransportArch && 79 mHalFormat == other.mHalFormat; 80 } 81 bool ManifestInstance::operator<(const ManifestInstance& other) const { 82 if (mFqInstance < other.mFqInstance) return true; 83 if (other.mFqInstance < mFqInstance) return false; 84 if (mTransportArch < other.mTransportArch) return true; 85 if (other.mTransportArch < mTransportArch) return false; 86 return mHalFormat < other.mHalFormat; 87 } 88 89 FqInstance ManifestInstance::getFqInstanceNoPackage() const { 90 FqInstance e; 91 bool success = e.setTo(version().majorVer, version().minorVer, interface(), instance()); 92 #ifndef LIBVINTF_TARGET 93 CHECK(success) << "Cannot remove package from '" << mFqInstance.string() << "'"; 94 #else 95 (void)success; 96 #endif 97 return e; 98 } 99 100 } // namespace vintf 101 } // namespace android 102