/// <summary> /// Adds an event handler to the list of event handlers. /// </summary> internal void addEventHandler(INSFEventHandler eventHandler) { lock (threadMutex) { eventHandlers.Add(eventHandler); } }
/// <summary> /// Removes an event handler from the list of event handlers. /// </summary> internal void removeEventHandler(INSFEventHandler eventHandler) { lock (threadMutex) { eventHandlers.Remove(eventHandler); } }
/// <summary> /// Creates a deep copy, replacing the specified parameters. /// </summary> /// <param name="source">The new source for the copy.</param> /// <param name="destination">The new destination for the copy.</param> /// <param name="data">The new data for the copy.</param> /// <returns>A copy of the event.</returns> /// <remarks> /// A common design pattern is to queue data event copies, each with its own unique data payload, to state machines for handling. /// </remarks> public NSFDataEvent <DataType> copy(INSFNamedObject source, INSFEventHandler destination, DataType data) { NSFDataEvent <DataType> eventCopy = copy(data); eventCopy.Source = source; eventCopy.Destination = destination; return(eventCopy); }
/// <summary> /// Creates a deep copy, replacing the specified parameters. /// </summary> /// <param name="source">The new source for the copy.</param> /// <param name="destination">The new destination for the copy.</param> /// <returns>A copy of the event.</returns> /// <remarks> /// A common design pattern is to queue data event copies, each with its own unique data payload, to state machines for handling. /// </remarks> public NSFEvent copy(INSFNamedObject source, INSFEventHandler destination) { NSFEvent eventCopy = copy(); eventCopy.Source = source; eventCopy.Destination = destination; return(eventCopy); }
/// <summary> /// Indicates if the event queue contains an event for the specified destination. /// </summary> /// <param name="eventHandler">The event handler destination.</param> /// <returns>True if the event queue contains an event with the specified destination, false otherwise.</returns> public bool hasEventFor(INSFEventHandler eventHandler) { lock (threadMutex) { foreach (NSFEvent nsfEvent in nsfEvents) { if (nsfEvent.Destination == eventHandler) { return(true); } } return(false); } }
/// <summary> /// Removes all events for the specified event handler. /// </summary> /// <param name="eventHandler">The event handler destination.</param> public void removeEventsFor(INSFEventHandler eventHandler) { lock (threadMutex) { LinkedListNode <NSFEvent> node = nsfEvents.First; while (node != null) { LinkedListNode <NSFEvent> nextNode = node.Next; if (node.Value.Destination == eventHandler) { nsfEvents.Remove(node); } node = nextNode; } } }
/// <summary> /// Creates an event. /// </summary> /// <param name="name">The name of the event.</param> /// <param name="parent">The parent of the event.</param> /// <remarks> /// The event source and destination will be set to the parent. /// </remarks> public NSFEvent(NSFString name, INSFEventHandler parent) : this(name, parent, parent) { }
private void construct(NSFId id, INSFNamedObject source, INSFEventHandler destination) { Id = id; Source = source; Destination = destination; }
/// <summary> /// Sets the source and destination of the event. /// </summary> /// <param name="source">Source of the event.</param> /// <param name="destination">Destination of the event.</param> public void setRouting(INSFNamedObject source, INSFEventHandler destination) { Source = source; Destination = destination; }
/// <summary> /// Schedules the event to execute. /// </summary> /// <param name="source">Source of the event.</param> /// <param name="destination">Destination of the event.</param> /// <param name="delayTime">Delay time before executing the event.</param> /// <param name="repeatTime">Repeat time, if desired. Zero if one-shot.</param> public void schedule(INSFNamedObject source, INSFEventHandler destination, NSFTime delayTime, NSFTime repeatTime) { Source = source; Destination = destination; NSFTimerThread.PrimaryTimerThread.scheduleAction(this, delayTime, repeatTime); }
/// <summary> /// Creates a deep copy, replacing the specified parameters. /// </summary> /// <param name="name">The new name for the copy.</param> /// <param name="source">The new source for the copy.</param> /// <param name="destination">The new destination for the copy.</param> /// <returns>A copy of the event.</returns> /// <remarks> /// A common design pattern is to queue data event copies, each with its own unique data payload, to state machines for handling. /// </remarks> public NSFEvent copy(NSFString name, INSFNamedObject source, INSFEventHandler destination) { NSFEvent eventCopy = copy(); eventCopy.Name = name; eventCopy.Source = source; eventCopy.Destination = destination; return eventCopy; }
/// <summary> /// Removes an event handler from the list of event handlers. /// </summary> internal void removeEventHandler(INSFEventHandler eventHandler) { lock (threadMutex) { eventHandlers.Remove(eventHandler); } }
/// <summary> /// Creates an event. /// </summary> /// <param name="name">The name of the event.</param> /// <param name="source">The source of the event.</param> /// <param name="destination">The destination of the event.</param> public NSFEvent(NSFString name, INSFNamedObject source, INSFEventHandler destination) : base(name) { construct(NSFUniquelyNumberedObject.getNextUniqueId(), source, destination); }
/// <summary> /// Creates event that can have a data payload. /// </summary> /// <param name="name">The name of the event.</param> /// <param name="source">The source of the event.</param> /// <param name="destination">The destination of event.</param> public NSFDataEvent(NSFString name, INSFNamedObject source, INSFEventHandler destination) : base(name, source, destination) { }
/// <summary> /// Creates event that can have a data payload. /// </summary> /// <param name="name">The name of the event.</param> /// <param name="parent">The parent of the event.</param> /// <remarks> /// The event source and destination will be set to the parent. /// </remarks> public NSFDataEvent(NSFString name, INSFEventHandler parent) : base(name, parent) { }
/// <summary> /// Sets the source and destination of the event. /// </summary> /// <param name="source">Source of the event.</param> /// <param name="destination">Destination of the event.</param> public void setRouting(INSFNamedObject source, INSFEventHandler destination) { Source = source; Destination = destination; }
private void construct(NSFId id, INSFNamedObject source, INSFEventHandler destination) { Id = id; Source = source; Destination = destination; }
/// <summary> /// Creates an event. /// </summary> /// <param name="name">The name of the event.</param> /// <param name="source">The source of the event.</param> /// <param name="destination">The destination of the event.</param> public NSFEvent(NSFString name, INSFNamedObject source, INSFEventHandler destination) : base(name) { construct(NSFUniquelyNumberedObject.getNextUniqueId(), source, destination); }
/// <summary> /// Schedules the event to execute. /// </summary> /// <param name="source">Source of the event.</param> /// <param name="destination">Destination of the event.</param> /// <param name="delayTime">Delay time before executing the event.</param> /// <param name="repeatTime">Repeat time, if desired. Zero if one-shot.</param> public void schedule(INSFNamedObject source, INSFEventHandler destination, NSFTime delayTime, NSFTime repeatTime) { Source = source; Destination = destination; NSFTimerThread.PrimaryTimerThread.scheduleAction(this, delayTime, repeatTime); }
/// <summary> /// Indicates if the event queue contains an event for the specified destination. /// </summary> /// <param name="eventHandler">The event handler destination.</param> /// <returns>True if the event queue contains an event with the specified destination, false otherwise.</returns> public bool hasEventFor(INSFEventHandler eventHandler) { lock (threadMutex) { foreach (NSFEvent nsfEvent in nsfEvents) { if (nsfEvent.Destination == eventHandler) { return true; } } return false; } }
/// <summary> /// Creates an event. /// </summary> /// <param name="name">The name of the event.</param> /// <param name="parent">The parent of the event.</param> /// <remarks> /// The event source and destination will be set to the parent. /// </remarks> public NSFEvent(NSFString name, INSFEventHandler parent) : this(name, parent, parent) { }
/// <summary> /// Creates event that can have a data payload. /// </summary> /// <param name="name">The name of the event.</param> /// <param name="parent">The parent of the event.</param> /// <param name="data">The data of the event.</param> /// <remarks> /// The event source and destination will be set to the parent. /// </remarks> public NSFDataEvent(NSFString name, INSFEventHandler parent, DataType data) : base(name, parent) { Data = data; }
/// <summary> /// Removes all events for the specified event handler. /// </summary> /// <param name="eventHandler">The event handler destination.</param> public void removeEventsFor(INSFEventHandler eventHandler) { lock (threadMutex) { LinkedListNode<NSFEvent> node = nsfEvents.First; while (node != null) { LinkedListNode<NSFEvent> nextNode = node.Next; if (node.Value.Destination == eventHandler) { nsfEvents.Remove(node); } node = nextNode; } } }
/// <summary> /// Creates event that can have a data payload. /// </summary> /// <param name="name">The name of the event.</param> /// <param name="source">The source of the event.</param> /// <param name="destination">The destination of the event.</param> /// <param name="data">The data of the event.</param> public NSFDataEvent(NSFString name, INSFNamedObject source, INSFEventHandler destination, DataType data) : base(name, source, destination) { Data = data; }
/// <summary> /// Adds an event handler to the list of event handlers. /// </summary> internal void addEventHandler(INSFEventHandler eventHandler) { lock (threadMutex) { eventHandlers.Add(eventHandler); } }