Android-cuttlefish cvd tool
discovered_services.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 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#pragma once
18
19#include <memory>
20#include <string>
21
23
24namespace mdns {
26 public:
27 void ServiceCreated(const ServiceInfo& service_info);
28 void ServiceUpdated(const ServiceInfo& service_info);
29 void ServiceDeleted(const ServiceInfo& service_info);
30 std::optional<ServiceInfo> FindInstance(const std::string& service,
31 const std::string& instance);
32 void ForEachServiceNamed(const std::string& service,
33 const std::function<void(const ServiceInfo&)>& callback);
34 void ForAllServices(const std::function<void(const ServiceInfo&)>& callback);
35
36 private:
37 std::mutex services_mutex_;
38 std::unordered_map<std::string, ServiceInfo> services_ GUARDED_BY(services_mutex_);
39};
40
42} // namespace mdns
Definition: discovered_services.h:25
void ForAllServices(const std::function< void(const ServiceInfo &)> &callback)
Definition: discovered_services.cpp:66
void ForEachServiceNamed(const std::string &service, const std::function< void(const ServiceInfo &)> &callback)
Definition: discovered_services.cpp:56
void ServiceCreated(const ServiceInfo &service_info)
Definition: discovered_services.cpp:28
std::unordered_map< std::string, ServiceInfo > services_ GUARDED_BY(services_mutex_)
void ServiceDeleted(const ServiceInfo &service_info)
Definition: discovered_services.cpp:40
void ServiceUpdated(const ServiceInfo &service_info)
Definition: discovered_services.cpp:34
std::optional< ServiceInfo > FindInstance(const std::string &service, const std::string &instance)
Definition: discovered_services.cpp:46
std::mutex services_mutex_
Definition: discovered_services.h:37
Definition: discovered_services.cpp:21
DiscoveredServices discovered_services
Definition: discovered_services.cpp:22
Definition: mdns_service_info.h:29