Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches
Plugin.h
1// Copyright (c) ZeroC, Inc.
2
3#ifndef ICE_BT_PLUGIN_H
4#define ICE_BT_PLUGIN_H
5
6#include "Ice/Plugin.h"
7#include "Ice/PluginFactory.h"
8#include "Types.h"
9
10#include <functional>
11#include <map>
12
13/// The Bluetooth transport plug-in.
14namespace IceBT
15{
16 /// Returns the factory for the Bluetooth transport plug-in, IceBT.
17 /// @return The factory for the IceBT plug-in.
18 /// @see InitializationData::pluginFactories
20
21 /// A name-value map.
22 using PropertyMap = std::map<std::string, std::string>;
23
24 /// A collection of properties for each device.
25 using DeviceMap = std::map<std::string, PropertyMap>;
26
27 /// Represents the IceBT plug-in object.
28 /// @headerfile IceBT/IceBT.h
29 class ICEBT_API Plugin : public Ice::Plugin
30 {
31 public:
32 /// Starts Bluetooth device discovery on the adapter with the specified address. @p cb will be invoked for each
33 /// discovered device. The same device may be reported more than once. Discovery remains active until
34 /// explicitly stopped by a call to #stopDiscovery, or via other administrative means.
35 /// @param address The address associated with the Bluetooth adapter.
36 /// @param cb The callback to invoke when a device is discovered.
37 virtual void startDiscovery(
38 const std::string& address,
39 std::function<void(const std::string& addr, const PropertyMap& props)> cb) = 0;
40
41 /// Stops Bluetooth device discovery on the adapter with the specified address. All discovery callbacks are
42 /// removed when discovery stops.
43 /// @param address The address associated with the Bluetooth adapter.
44 virtual void stopDiscovery(const std::string& address) = 0;
45
46 /// Retrieves a snapshot of all known remote devices. The plug-in obtains a snapshot of the remote devices at
47 /// startup and then dynamically updates its map as the host adds and removes devices.
48 /// @return A map containing properties for each known device.
49 [[nodiscard]] virtual DeviceMap getDevices() const = 0;
50 };
51
52 /// A shared pointer to a Plugin.
53 using PluginPtr = std::shared_ptr<Plugin>;
54}
55
56#endif
virtual DeviceMap getDevices() const =0
Retrieves a snapshot of all known remote devices.
virtual void startDiscovery(const std::string &address, std::function< void(const std::string &addr, const PropertyMap &props)> cb)=0
Starts Bluetooth device discovery on the adapter with the specified address.
virtual void stopDiscovery(const std::string &address)=0
Stops Bluetooth device discovery on the adapter with the specified address.
Represents the IceBT plug-in object.
Definition Plugin.h:30
Represents a communicator plug-in.
Definition Plugin.h:18
std::map< std::string, std::string > PropertyMap
A name-value map.
Definition Plugin.h:22
std::shared_ptr< Plugin > PluginPtr
A shared pointer to a Plugin.
Definition Plugin.h:53
std::map< std::string, PropertyMap > DeviceMap
A collection of properties for each device.
Definition Plugin.h:25
Ice::PluginFactory btPluginFactory()
Returns the factory for the Bluetooth transport plug-in, IceBT.
The Bluetooth transport plug-in.
Represents a plug-in factory.