| // Copyright 2024 The Chromium Authors | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| #ifndef OSP_PUBLIC_RECEIVER_LIST_H_ | |
| #define OSP_PUBLIC_RECEIVER_LIST_H_ | |
| #include <vector> | |
| #include "osp/public/service_info.h" | |
| #include "platform/base/error.h" | |
| namespace openscreen::osp { | |
| class ReceiverList { | |
| public: | |
| ReceiverList(); | |
| ReceiverList(const ReceiverList&) = delete; | |
| ReceiverList& operator=(const ReceiverList&) = delete; | |
| ReceiverList(ReceiverList&&) noexcept = delete; | |
| ReceiverList& operator=(ReceiverList&&) noexcept = delete; | |
| ~ReceiverList(); | |
| void OnReceiverAdded(const ServiceInfo& info); | |
| Error OnReceiverChanged(const ServiceInfo& info); | |
| // If successfully removed, returns the service info that was removed. If | |
| // `info` is a reference to an entry in `receivers`, it is immediately | |
| // invalid after calling this method. | |
| ErrorOr<ServiceInfo> OnReceiverRemoved(const ServiceInfo& info); | |
| Error OnAllReceiversRemoved(); | |
| const std::vector<ServiceInfo>& receivers() const { return receivers_; } | |
| private: | |
| std::vector<ServiceInfo> receivers_; | |
| }; | |
| } // namespace openscreen::osp | |
| #endif // OSP_PUBLIC_RECEIVER_LIST_H_ |