using System;
using System.Collections.Generic;
namespace OpenMacroBoard.SDK
{
///
/// Represents a context that tracks devices and their connection state using device listeners.
///
///
/// This is basically the entry point to opening a . Once constructed
/// you can add device listeners for various providers and the context will collect all devices
/// (even from different providers) in one place.
///
public interface IDeviceContext : IDisposable
{
///
/// Gets the observable that reports all device state changes, for example like
/// new devices or connection state changes.
///
///
/// Once subscribed, reports are generated to reflect the current state of known devices and
/// their connection state. This does not mean that all original reports are replayed, but only
/// the most recent events, that are needed to rebuild the currently known state for all known devices.
///
IObservable DeviceStateReports { get; }
///
/// A list of known devices.
///
///
/// The order of the list is consistent and new devices are always added at the end.
///
IReadOnlyList KnownDevices { get; }
///
/// Registers a new device listener for that context.
///
///
/// Registered listeners can't be unsubscribed individually.
/// All listeners will unsubscribed when the context is disposed.
///
/// Returns the original instance to allow for fluent API calls.
IDeviceContext AddListener(IObservable deviceListener);
///
/// Registers a new device listener for that context.
///
///
///
/// Registered listeners can't be unsubscribed individually.
/// All listeners will unsubscribed when the context is disposed.
///
///
/// When is set to true and is
/// it will be disposed when the context is disposed.
///
///
/// Returns the original instance to allow for fluent API calls.
IDeviceContext AddListener(IObservable deviceListener, bool disposeWithContext);
///
/// Registers a new device listener for that context.
///
/// A with a parameterless constructor.
///
/// Registered listeners can't be unsubscribed individually.
/// All listeners will unsubscribed when the context is disposed.
///
/// Returns the original instance to allow for fluent API calls.
IDeviceContext AddListener()
where TListener : IObservable, new();
}
}