private InstantDataTarget InternalUnregisterInstantDataTarget(Guid registrationToken) { lock (this.instantStreamReaders) { for (int index = this.instantStreamReaders.Count - 1; index >= 0; index--) { // Unregister the target from the instant stream reader InstantDataTarget target = this.instantStreamReaders[index].UnregisterInstantDataTarget(registrationToken); if (target != null) { // If the instant stream reader now has no data providers, remove it from the collection if (!this.instantStreamReaders[index].HasAdaptingDataProviders) { this.instantStreamReaders.RemoveAt(index); } // If there's no instant stream readers, remove the index view if (this.instantStreamReaders.Count <= 0) { this.instantIndexView = null; } return(target); } } return(null); } }
private void RunPushTask(InstantDataTarget target, TDest data, IndexEntry indexEntry) { Task.Run(() => { target.Callback.Invoke(data, indexEntry); }); }
/// <inheritdoc/> public void RegisterInstantDataTarget(InstantDataTarget target) { // Add the target to the collection lock (this.targets) { this.targets[target.RegistrationToken] = target; } }
private void InternalRegisterInstantDataTarget <TTarget>(InstantDataTarget target) { // Get the instant stream reader with the required cursor epsilon EpsilonInstantStreamReader <T> instantStreamReader = this.GetInstantStreamReader(target.CursorEpsilon, true); // Register the instant visualization object with the instant stream reader instantStreamReader.RegisterInstantDataTarget <TTarget>(target); }
/// <summary> /// Registers an instant data target to be notified when new data for a stream is available. /// </summary> /// <typeparam name="TStreamData">The type of data in the stream.</typeparam> /// <typeparam name="TTarget">The type of data the instant visualization object requires.</typeparam> /// <param name="target">An instant data target that specifies the stream binding, the cursor epsilon, and the callback to call when new data is available.</param> /// <param name="viewRange">The initial time range over which data is expected.</param> internal void RegisterInstantDataTarget <TStreamData, TTarget>(InstantDataTarget target, TimeInterval viewRange) { // Get the stream reader. Note that we don't care about the stream reader's stream adapter // because with instant data we always read raw data and adapt the stream later. IStreamReader streamReader = this.GetOrCreateStreamReader <TStreamData>(target.StreamName, null); // Register the target with the stream reader streamReader.RegisterInstantDataTarget <TTarget>(target, viewRange); }
/// <inheritdoc /> public void RegisterInstantDataTarget <TTarget>(InstantDataTarget target, TimeInterval viewRange) { this.InternalRegisterInstantDataTarget <TTarget>(target); // Create the index view if one does not already exist if (this.instantIndexView == null) { this.OnInstantViewRangeChanged(viewRange); } }
/// <inheritdoc/> public InstantDataTarget UnregisterInstantDataTarget(Guid registrationToken) { InstantDataTarget target = null; lock (this.targets) { if (this.targets.ContainsKey(registrationToken)) { target = this.targets[registrationToken]; this.targets.Remove(registrationToken); } } return(target); }
/// <inheritdoc /> public void UpdateInstantDataTargetEpsilon(Guid registrationToken, RelativeTimeInterval epsilon) { // Unregister and retrieve the old instant data target InstantDataTarget target = this.InternalUnregisterInstantDataTarget(registrationToken); if (target != null) { // Update the Ccursor epsilon target.CursorEpsilon = epsilon; // Create the internal register method MethodInfo method = this.GetType().GetMethod(nameof(this.InternalRegisterInstantDataTarget), BindingFlags.NonPublic | BindingFlags.Instance); MethodInfo genericMethod = method.MakeGenericMethod(target.StreamAdapter.DestinationType); // Re-register the instant data target genericMethod.Invoke(this, new object[] { target }); } }
/// <summary> /// Unregisters an instant data target from data notification. /// </summary> /// <param name="registrationToken">The registration token that the target was given when the target was initially registered.</param> /// <returns>An instant data target representing the target that was unregistered.</returns> public InstantDataTarget UnregisterInstantDataTarget(Guid registrationToken) { for (int index = this.dataProviders.Count - 1; index >= 0; index--) { // Unregister the target from the data provider if it exists there InstantDataTarget target = this.dataProviders[index].UnregisterInstantDataTarget(registrationToken); if (target != null) { // If the data provider now has no targets to call, remove it from the collection if (!this.dataProviders[index].HasRegisteredTargets) { this.dataProviders.RemoveAt(index); } return(target); } } return(null); }
/// <summary> /// Registers an instant data target to be notified when new data for a stream is available. /// </summary> /// <typeparam name="TTarget">The type of data the target requires.</typeparam> /// <param name="target">An instant data target specifying the properties of the target.</param> public void RegisterInstantDataTarget <TTarget>(InstantDataTarget target) { // Get the name of the stream adapter string streamAdapterName = target.StreamAdapter.GetType().FullName; // Check if we already have a data provider that uses this stream adapter IAdaptingInstantDataProvider <T> provider = this.dataProviders.FirstOrDefault(n => n.StreamAdapterName == streamAdapterName); if (provider == null) { // Create the adapting data provider provider = new AdaptingInstantDataProvider <T, TTarget>(target.StreamAdapter); // Add it to the collection lock (this.dataProviders) { this.dataProviders.Add(provider); } } // Register the target with the adapting data provider provider.RegisterInstantDataTarget(target); }