templates.operations
Class EventSynchronizer

java.lang.Object
  extended by templates.operations.EventSynchronizer

public class EventSynchronizer
extends java.lang.Object

Implements operations commonly employed by the other template design operations.

Author:
Lenko Grigorov

Constructor Summary
EventSynchronizer()
           
 
Method Summary
protected static long[] getEventPointer(java.lang.String name)
          Retrieve the ids of the template design component and the event in the underlying model from the unique event name string generated by getUniqueEventName(TemplateComponent, long).
protected static java.lang.String getUniqueEventName(TemplateComponent c, long eventId)
          Generate a unique event name string for the given event.
static void label4Humans(TemplateModel model, java.util.Collection<ides.api.model.fsa.FSAModel> fsas)
          Relabel the events of the outputs of synchronizeAndCompose(TemplateModel, Collection, Collection) with names which are human-readable.
static ides.api.model.fsa.FSAModel[] synchronizeAndCompose(TemplateModel model, java.util.Collection<TemplateComponent> modules, java.util.Collection<TemplateComponent> channels)
          Composes a list of modules and synchronizes and composes a list of channels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventSynchronizer

public EventSynchronizer()
Method Detail

synchronizeAndCompose

public static ides.api.model.fsa.FSAModel[] synchronizeAndCompose(TemplateModel model,
                                                                  java.util.Collection<TemplateComponent> modules,
                                                                  java.util.Collection<TemplateComponent> channels)
Composes a list of modules and synchronizes and composes a list of channels. Modules are composed using the "sync" operation. The events of the channels are synchronized with the corresponding events from the linked modules; the irrelevant events of each channel are self-looped; and the channels are composed using the "product" operation. If the list of channels is empty, instead of the channel composition the output contains a single-state automaton with all events in a self-loop.

Note: as different modules may have the same event names (and as all alphabets are assumed to be disjunct), the event names in the outputs are replaced with unique strings. To convert these unique string to a human-readable form, use label4Humans(TemplateModel, Collection).

Parameters:
model - the template model containing the modules and channels
modules - the modules to be composed
channels - the channels to be synchronized and composed
Returns:
an array of two FSAModels; the first model is the composition of the given modules; the second model is the composition of the synchronized versions of the given channels (if no channels were given, the second model is a single-state automaton where all events are self-looped)
Throws:
java.lang.IllegalArgumentException - when the list of modules is empty
See Also:
label4Humans(TemplateModel, Collection)

label4Humans

public static void label4Humans(TemplateModel model,
                                java.util.Collection<ides.api.model.fsa.FSAModel> fsas)
Relabel the events of the outputs of synchronizeAndCompose(TemplateModel, Collection, Collection) with names which are human-readable. The existing labels are assumed to be unique string identifiers as generated by synchronizeAndCompose(TemplateModel, Collection, Collection). This method may produce unexpected results if the template design has been modified in between the invocations of synchronizeAndCompose(TemplateModel, Collection, Collection) and this method.

Parameters:
model - the template design containing the inputs to synchronizeAndCompose(TemplateModel, Collection, Collection)
fsas - the outputs of synchronizeAndCompose(TemplateModel, Collection, Collection)
See Also:
synchronizeAndCompose(TemplateModel, Collection, Collection)

getUniqueEventName

protected static java.lang.String getUniqueEventName(TemplateComponent c,
                                                     long eventId)
Generate a unique event name string for the given event.

Parameters:
c - the template design component
eventId - the id of the event in the underlying model of the given component
Returns:
a unique event name string

getEventPointer

protected static long[] getEventPointer(java.lang.String name)
Retrieve the ids of the template design component and the event in the underlying model from the unique event name string generated by getUniqueEventName(TemplateComponent, long).

Parameters:
name - the unique event name
Returns:
an array of two elements: the id of the TemplateComponent and the id of the event in the underlying model of the TemplateComponent.