< Summary

Class:Itinero.Data.Usage.DataUseNotifier
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Data/Usage/DataUseNotifier.cs
Covered lines:14
Uncovered lines:14
Coverable lines:28
Total lines:66
Line coverage:50% (14 of 28)
Covered branches:3
Total branches:8
Branch coverage:37.5% (3 of 8)
Tag:251_23667616543

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor()100%1100%
AddListener(...)100%10%
get_RegisteredListeners()100%1100%
IsVertexDataReady(...)25%444.44%
NotifyVertex()50%250%
NotifyBox()50%250%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Data/Usage/DataUseNotifier.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.Linq;
 3using System.Threading;
 4using System.Threading.Tasks;
 5using Itinero.Network;
 6
 7namespace Itinero.Data.Usage;
 8
 9/// <summary>
 10/// Notifies listeners about data use in a router db.
 11/// </summary>
 12public class DataUseNotifier
 13{
 40514    private readonly HashSet<IDataUseListener> _listeners = new();
 15
 16    /// <summary>
 17    /// Adds a new listener.
 18    /// </summary>
 19    /// <param name="listener">The new listener.</param>
 20    public void AddListener(IDataUseListener listener)
 021    {
 022        _listeners.Add(listener);
 023    }
 24
 25    internal IEnumerable<IDataUseListener> RegisteredListeners
 26    {
 27        get
 16928        {
 16929            return _listeners.ToList();
 16930        }
 31    }
 32
 33    /// <summary>
 34    /// Returns true if all listeners report the vertex data is ready (no async work needed).
 35    /// </summary>
 36    internal bool IsVertexDataReady(RoutingNetwork network, VertexId vertex)
 30233037    {
 90699038        foreach (var listener in _listeners)
 039        {
 040            if (!listener.IsVertexDataReady(network, vertex))
 041            {
 042                return false;
 43            }
 044        }
 45
 30233046        return true;
 30233047    }
 48
 49    internal async Task NotifyVertex(RoutingNetwork network, VertexId vertex, CancellationToken cancellationToken = defa
 750    {
 2151        foreach (var listener in _listeners)
 052        {
 053            await listener.VertexTouched(network, vertex, cancellationToken);
 054        }
 755    }
 56
 57    internal async Task NotifyBox(RoutingNetwork network,
 58        ((double longitude, double latitude, float? e) topLeft, (double longitude, double latitude, float? e)
 59            bottomRight) box, CancellationToken cancellationToken = default)
 216260    {
 648661        foreach (var listener in _listeners)
 062        {
 063            await listener.BoxTouched(network, box, cancellationToken);
 064        }
 216265    }
 66}