The Meta-Environment API

toolbus.matching
Class MatchStore

java.lang.Object
  extended by toolbus.matching.MatchStore

public class MatchStore
extends java.lang.Object

This store keeps track of all links between sending and receiving communication atoms.

Author:
Arnold Lankamp

Nested Class Summary
private static class MatchStore.MappingRefCount
          Reference count structure.
 
Field Summary
private  java.util.List<Atom> atomSet
           
private  toolbus.util.collections.ConcurrentHashMap<aterm.ATerm,java.util.List<aterm.ATerm>> messageLinks
           
private  java.lang.Object messageLock
           
private  java.util.Map<aterm.ATerm,java.util.List<RecMsg>> messageMappings
           
private static java.util.List<RecMsg> NOMESSAGEPARTNERS
           
private static java.util.Set<ProcessInstance> NONOTEPARTNERS
           
private  toolbus.util.collections.ConcurrentHashMap<aterm.ATerm,java.util.List<aterm.ATerm>> noteLinks
           
private  java.lang.Object noteLock
           
private  java.util.Map<aterm.ATerm,java.util.Map<ProcessInstance,MatchStore.MappingRefCount>> noteMappings
           
private  TBTermFactory tbFactory
           
 
Constructor Summary
MatchStore(TBTermFactory tbTermFactory)
          Constructor.
 
Method Summary
private  void addReceiveMessagePattern(RecMsg message, java.util.List<aterm.ATerm> receiveMessages)
          Indexes the given receive message atom.
private  void addSendMessagePattern(SndMsg message, java.util.List<aterm.ATerm> receiveMessages)
          Indexes the given send message atom.
private  void addSendNotePattern(SndNote message, java.util.List<aterm.ATerm> subscribeNotes)
          Indexes the given send note atom.
private  void addSubscribeNotePattern(Subscribe subscribeNote, java.util.List<aterm.ATerm> subscribeNotes)
          Indexes the given subscribe atom.
private  void calculateMatches()
          Staticly determains all (potential) relations between the atoms.
 void deregisterReceiveMessage(RecMsg receiveMessage)
          Deregisteres the given, instantiated, receive message atom.
 void deregisterSubscribeNote(Subscribe subscribeNote)
          Deregisters the given, instantiated, subscribe atom.
 java.util.List<RecMsg> findPartnerLessReceiveMessageAtoms()
          Gathers a list of partnerless message receiving atoms.
 java.util.List<SndMsg> findPartnerlessSendMessageAtoms()
          Gathers a list of partnerless message sending atoms.
 java.util.List<SndNote> findPartnerlessSendNoteAtoms()
          Gathers a list of partnerless note sending atoms.
 java.util.List<Subscribe> findPartnerlessSubscribeAtoms()
          Gathers a list of partnerless subscribe atoms.
 java.util.List<RecMsg> getPossibleMessagePartners(aterm.ATerm pattern)
          Gathers the potential partners for the given send message pattern.
 java.util.Set<ProcessInstance> getPossibleNotePartners(aterm.ATerm pattern)
          Gathers the potential partners for the given send note pattern.
 void initialize(java.util.List<Atom> atomSet)
          Initializes this match store with the given set of atoms.
 void printPartnerlessCommunicationAtoms()
          Dumps a list of partnerless communication atoms to standard out.
private  void printPartnerlessReceivers()
          Dumps a list of partnerless receiving atoms to standard out.
private  void printPartnerlessSenders()
          Dumps a list of partnerless sending atoms to standard out.
 void registerReceiveMessage(RecMsg receiveMessage)
          Registers the given, instantiated, receive message atom.
 void registerSubscribeNote(Subscribe subscribeNote)
          Registers the given, instantiated, subscribe atom.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOMESSAGEPARTNERS

private static final java.util.List<RecMsg> NOMESSAGEPARTNERS

NONOTEPARTNERS

private static final java.util.Set<ProcessInstance> NONOTEPARTNERS

tbFactory

private final TBTermFactory tbFactory

atomSet

private volatile java.util.List<Atom> atomSet

messageLinks

private final toolbus.util.collections.ConcurrentHashMap<aterm.ATerm,java.util.List<aterm.ATerm>> messageLinks

noteLinks

private final toolbus.util.collections.ConcurrentHashMap<aterm.ATerm,java.util.List<aterm.ATerm>> noteLinks

messageMappings

private final java.util.Map<aterm.ATerm,java.util.List<RecMsg>> messageMappings

noteMappings

private final java.util.Map<aterm.ATerm,java.util.Map<ProcessInstance,MatchStore.MappingRefCount>> noteMappings

messageLock

private final java.lang.Object messageLock

noteLock

private final java.lang.Object noteLock
Constructor Detail

MatchStore

public MatchStore(TBTermFactory tbTermFactory)
Constructor.

Parameters:
tbTermFactory - The term factory to use for matching.
Method Detail

initialize

public void initialize(java.util.List<Atom> atomSet)
Initializes this match store with the given set of atoms.

Parameters:
atomSet - The complete collection of atoms, for which the relations must to be calculated.

calculateMatches

private void calculateMatches()
Staticly determains all (potential) relations between the atoms.


addReceiveMessagePattern

private void addReceiveMessagePattern(RecMsg message,
                                      java.util.List<aterm.ATerm> receiveMessages)
Indexes the given receive message atom.

Parameters:
message - The receive message atom.
receiveMessages - The list to add the message's match pattern to.

addSendMessagePattern

private void addSendMessagePattern(SndMsg message,
                                   java.util.List<aterm.ATerm> receiveMessages)
Indexes the given send message atom. NOTE: All receive message atoms need to have been added prior to the invokation of this method, otherwise the the ToolBus may exhibit undefined runtime behaviour.

Parameters:
message - The send message atom.
receiveMessages - The complete list of receive messages.

addSubscribeNotePattern

private void addSubscribeNotePattern(Subscribe subscribeNote,
                                     java.util.List<aterm.ATerm> subscribeNotes)
Indexes the given subscribe atom.

Parameters:
subscribeNote - The subscribe atom.
subscribeNotes - The list to add the subscribe's match pattern to.

addSendNotePattern

private void addSendNotePattern(SndNote message,
                                java.util.List<aterm.ATerm> subscribeNotes)
Indexes the given send note atom. NOTE: All subscribe atoms need to have been added prior to the invokation of this method, otherwise the the ToolBus may exhibit undefined runtime behaviour.

Parameters:
message - The send note atom.
subscribeNotes - The complete list of subscribes.

registerReceiveMessage

public void registerReceiveMessage(RecMsg receiveMessage)
Registers the given, instantiated, receive message atom.

Parameters:
receiveMessage - The receive message atom to register.

deregisterReceiveMessage

public void deregisterReceiveMessage(RecMsg receiveMessage)
Deregisteres the given, instantiated, receive message atom.

Parameters:
receiveMessage - The receive message atom to deregister.

getPossibleMessagePartners

public java.util.List<RecMsg> getPossibleMessagePartners(aterm.ATerm pattern)
Gathers the potential partners for the given send message pattern.

Parameters:
pattern - The send message pattern.
Returns:
The collections of potentially matching partners.

registerSubscribeNote

public void registerSubscribeNote(Subscribe subscribeNote)
Registers the given, instantiated, subscribe atom.

Parameters:
subscribeNote - The subscribe atom to register.

deregisterSubscribeNote

public void deregisterSubscribeNote(Subscribe subscribeNote)
Deregisters the given, instantiated, subscribe atom.

Parameters:
subscribeNote - The subscribe atom to deregister.

getPossibleNotePartners

public java.util.Set<ProcessInstance> getPossibleNotePartners(aterm.ATerm pattern)
Gathers the potential partners for the given send note pattern.

Parameters:
pattern - The send message pattern.
Returns:
The collections of potentially matching partners.

printPartnerlessCommunicationAtoms

public void printPartnerlessCommunicationAtoms()
Dumps a list of partnerless communication atoms to standard out.


findPartnerlessSendMessageAtoms

public java.util.List<SndMsg> findPartnerlessSendMessageAtoms()
Gathers a list of partnerless message sending atoms.

Returns:
A list of partnerless message sending atoms.

findPartnerlessSendNoteAtoms

public java.util.List<SndNote> findPartnerlessSendNoteAtoms()
Gathers a list of partnerless note sending atoms.

Returns:
A list of partnerless note sending atoms.

findPartnerLessReceiveMessageAtoms

public java.util.List<RecMsg> findPartnerLessReceiveMessageAtoms()
Gathers a list of partnerless message receiving atoms.

Returns:
A list of partnerless message receiving atoms.

findPartnerlessSubscribeAtoms

public java.util.List<Subscribe> findPartnerlessSubscribeAtoms()
Gathers a list of partnerless subscribe atoms.

Returns:
A list of partnerless subscribe atoms.

printPartnerlessSenders

private void printPartnerlessSenders()
Dumps a list of partnerless sending atoms to standard out.


printPartnerlessReceivers

private void printPartnerlessReceivers()
Dumps a list of partnerless receiving atoms to standard out.


The Meta-Environment API