copyright The Portico Project 2008.

org.portico.lrc
Class LRCInterestManager

java.lang.Object
  extended by org.portico.lrc.LRCInterestManager

public class LRCInterestManager
extends Object

This class maintains the publication and subscription interests of a federate. NOTE: This class does *not* do any checking of validity regarding the given handles. In fact, it will take pub/sub interests even when there is not FOM! It is only a vessel for storing and querying such values.

The LRCInterestManager also provides a number of helper methods for use during the validation of various actions. For example, the isOCPublished(int) method can be used to ensure that the federate publishes the specified object class handle before it attempts to register an instance of it.


Nested Class Summary
private  class LRCInterestManager.RegionSubscription
          This class represents a subscription interest with region data.
 
Field Summary
private  Set<Integer> publishedIC
           
private  Map<Integer,Set<Integer>> publishedOC
           
private  Map<Integer,LRCInterestManager.RegionSubscription> subscribedIC
           
private  Map<Integer,Map<Integer,Set<Integer>>> subscribedOC
           
 
Constructor Summary
LRCInterestManager()
           
 
Method Summary
 void clear()
          Remove all information and reset the manager to its initial state
 Set<Integer> getICRegions(int classHandle)
          This will return all the regions associated with the subscription for the identified interaciton class handle.
 boolean isACPublished(int classHandle, int attributeHandle)
          Returns true if the federate is publishing the specified attribute handle of the identified object class, false otherwise.
 boolean isICPublished(int classHandle)
           
 boolean isICSubscribed(int classHandle)
           
 boolean isOCPublished(int classHandle)
          Returns true if the given class is currently published in some capacity.
 boolean isOCPublished(int classHandle, Collection<Integer> attributes)
          Returns true if the federate is publishing *ALL* of the specified attributes of the given object class.
 boolean isOCSubscribed(int classHandle)
          Returns true if the federate is subscribed to any attributes of the given object class.
 void publishIC(int classHandle)
           
 void publishOC(int classHandle, Set<Integer> attributes)
          Records a new publication for the given class handle and the associated attributes.
 void subscribeIC(int classHandle)
           
 void subscribeIC(int classHandle, int regionToken)
          Add a subscription interest in the interaction class for the associated region.
 void subscribeOC(int classHandle, Set<Integer> attributes)
          Registers a new subscription for the federate regarding the given attributes for the given class handle.
 void subscribeOC(int classHandle, Set<Integer> attributes, int regionToken)
          Registers a new subscription for the federate regarding the given attributes for the given class handle and associates that subscription with the given region.
 void unpublishIC(int classHandle)
           
 void unpublishOC(int classHandle)
          Removes any publication for the given class handle.
 void unpublishOC(int classHandle, Set<Integer> attributes)
          Removes the publication interest in the given attributes of the given class.
 void unsubscribeIC(int classHandle)
          This method will remove all subscription interests in the given interaction class.
 void unsubscribeIC(int classHandle, int regionToken)
          This method will disassociate the identified region with the interaction subscription, but it will never remove the subscription entirely.
 void unsubscribeOC(int classHandle)
          Removes any subscription for the given class handle.
 void unsubscribeOC(int classHandle, int regionToken)
          Same as unpublishOC(int) except that it only removes the subscription to any attributes with the given region.
 void unsubscribeOC(int classHandle, Set<Integer> attributes)
          Removes the subscription interest in the given attributes of the given class.
 void unsubscribeOC(int classHandle, Set<Integer> attributes, int regionToken)
          Removes the subscription interest in the given attributes of the given class for the given region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

publishedOC

private Map<Integer,Set<Integer>> publishedOC

subscribedOC

private Map<Integer,Map<Integer,Set<Integer>>> subscribedOC

publishedIC

private Set<Integer> publishedIC

subscribedIC

private Map<Integer,LRCInterestManager.RegionSubscription> subscribedIC
Constructor Detail

LRCInterestManager

public LRCInterestManager()
Method Detail

clear

public void clear()
Remove all information and reset the manager to its initial state


publishOC

public void publishOC(int classHandle,
                      Set<Integer> attributes)
Records a new publication for the given class handle and the associated attributes. If there was previously a publication for that class handle, it is replaced by this new data.


unpublishOC

public void unpublishOC(int classHandle)
Removes any publication for the given class handle. If there is no publication, nothing happens.


unpublishOC

public void unpublishOC(int classHandle,
                        Set<Integer> attributes)
Removes the publication interest in the given attributes of the given class. If the given set is null or empty, all attributes will be removed.


subscribeOC

public void subscribeOC(int classHandle,
                        Set<Integer> attributes)
Registers a new subscription for the federate regarding the given attributes for the given class handle. If there was previously a subscription interest for the class identified by the class handle, it is overwritten with this new data.


subscribeOC

public void subscribeOC(int classHandle,
                        Set<Integer> attributes,
                        int regionToken)
Registers a new subscription for the federate regarding the given attributes for the given class handle and associates that subscription with the given region. If there was previously a subscription interest for the class identified by the class handle, it will be extended to cover this new region. If the regions are the same, then the old data is overwritten.


unsubscribeOC

public void unsubscribeOC(int classHandle)
Removes any subscription for the given class handle. If there was no subscriptions, nothing happens.


unsubscribeOC

public void unsubscribeOC(int classHandle,
                          int regionToken)
Same as unpublishOC(int) except that it only removes the subscription to any attributes with the given region. If the federate is only subscribed to attributes in that region, then the subscription is removed entirely.


unsubscribeOC

public void unsubscribeOC(int classHandle,
                          Set<Integer> attributes)
Removes the subscription interest in the given attributes of the given class. If the given set is null or empty, all attributes will be removed.


unsubscribeOC

public void unsubscribeOC(int classHandle,
                          Set<Integer> attributes,
                          int regionToken)
Removes the subscription interest in the given attributes of the given class for the given region. If the given set is null or empty, all attributes will be removed. The federate may still remain subscribed to some attributes if there is a subscription with a different region.


isOCPublished

public boolean isOCPublished(int classHandle)
Returns true if the given class is currently published in some capacity.


isOCPublished

public boolean isOCPublished(int classHandle,
                             Collection<Integer> attributes)
Returns true if the federate is publishing *ALL* of the specified attributes of the given object class. If one or more of the attributes are not being published, false is returned.


isACPublished

public boolean isACPublished(int classHandle,
                             int attributeHandle)
Returns true if the federate is publishing the specified attribute handle of the identified object class, false otherwise.


isOCSubscribed

public boolean isOCSubscribed(int classHandle)
Returns true if the federate is subscribed to any attributes of the given object class.


publishIC

public void publishIC(int classHandle)

unpublishIC

public void unpublishIC(int classHandle)

subscribeIC

public void subscribeIC(int classHandle)

subscribeIC

public void subscribeIC(int classHandle,
                        int regionToken)
Add a subscription interest in the interaction class for the associated region. If a subscription interest doesn't exist, one will be added. If one already exists, the region data will be added to it.


unsubscribeIC

public void unsubscribeIC(int classHandle)
This method will remove all subscription interests in the given interaction class. Unlike unsubscribeIC(int, int), it will always remove the interest entirely.


unsubscribeIC

public void unsubscribeIC(int classHandle,
                          int regionToken)
This method will disassociate the identified region with the interaction subscription, but it will never remove the subscription entirely.


isICPublished

public boolean isICPublished(int classHandle)

isICSubscribed

public boolean isICSubscribed(int classHandle)

getICRegions

public Set<Integer> getICRegions(int classHandle)
This will return all the regions associated with the subscription for the identified interaciton class handle. If there is no subscription interest, null will be returned. If there are no regions associated with the subscription, an empty set will be returned.


copyright The Portico Project 2008.