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 ANDROID_VINTF_MANIFEST_INSTANCE_H 18 #define ANDROID_VINTF_MANIFEST_INSTANCE_H 19 20 #include <optional> 21 #include <string> 22 23 #include <vintf/FqInstance.h> 24 #include <vintf/HalFormat.h> 25 #include <vintf/TransportArch.h> 26 #include <vintf/Version.h> 27 28 namespace android { 29 namespace vintf { 30 31 class ManifestInstance { 32 public: 33 ManifestInstance(); 34 ManifestInstance(const ManifestInstance&); 35 ManifestInstance(ManifestInstance&&) noexcept; 36 ManifestInstance& operator=(const ManifestInstance&); 37 ManifestInstance& operator=(ManifestInstance&&) noexcept; 38 39 using VersionType = Version; 40 ManifestInstance(FqInstance&& fqInstance, TransportArch&& ta, HalFormat fmt, 41 std::optional<std::string>&& updatableViaApex); 42 ManifestInstance(const FqInstance& fqInstance, const TransportArch& ta, HalFormat fmt, 43 const std::optional<std::string>& updatableViaApex); 44 const std::string& package() const; 45 Version version() const; 46 std::string interface() const; 47 const std::string& instance() const; 48 Transport transport() const; 49 Arch arch() const; 50 HalFormat format() const; 51 const std::optional<std::string>& updatableViaApex() const; 52 const std::optional<std::string> ip() const; 53 const std::optional<uint64_t> port() const; 54 55 bool operator==(const ManifestInstance& other) const; 56 bool operator<(const ManifestInstance& other) const; 57 58 // Convenience methods. 59 // return package@version::interface/instance 60 const FqInstance& getFqInstance() const; 61 62 // This is for writing the XML <fqname> tag. 63 // For AIDL, return "interface/instance". 64 // For others, return "@version::interface/instance". 65 std::string getSimpleFqInstance() const; 66 67 // For AIDL, return "package.interface/instance (@version)". 68 // For others, return "package@version::interface/instance". 69 std::string description() const; 70 71 // Similar to description() but without package name. 72 // For AIDL, return "interface/instance (@version)". 73 // For others, return "@version::interface/instance". 74 std::string descriptionWithoutPackage() const; 75 76 // Return a new ManifestInstance that's the same as this, but with the given version. 77 ManifestInstance withVersion(const Version& v) const; 78 79 private: 80 FqInstance mFqInstance; 81 TransportArch mTransportArch; 82 HalFormat mHalFormat; 83 std::optional<std::string> mUpdatableViaApex; 84 }; 85 86 } // namespace vintf 87 } // namespace android 88 89 #endif // ANDROID_VINTF_MANIFEST_INSTANCE_H 90