ManifestInstance.cpp 3.1 KB

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