copyright The Portico Project 2008.

org.portico.lrc
Class LRCInstanceRepository

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

public class LRCInstanceRepository
extends Object

This class is the central location to store object instance information. Instance information is stored as a set of OCInstance objects and contains the handle and discovered class of the instance for the federate associated with it etc...


Field Summary
private  Map<Integer,Integer> disctypes
           
private  Map<Integer,OCInstance> instances
           
private  LRCState state
           
 
Constructor Summary
LRCInstanceRepository(LRCState state)
          Create a new instance repository that is to reside within the given LRCState
 
Method Summary
 OCInstance addInstance(OCInstance instance, int discoveredType)
          Adds the given instance to the repository.
 boolean containsInstance(int handle)
          Returns true if this repository contains an instance with the given handle, false otherwise
 Integer getDiscoveredType(int handle)
          Returns the handle of the class the instance was discovered as
 OCInstance getInstance(int handle)
          Gets the instance of the given handle from this repository and returns it.
 OCInstance getInstance(String name)
          Get the instance with the given name.
 boolean ownsAnyAttributes()
          Returns true if the federate represented by the LRC this repository is a part of owns any attributes stored within (currently only checks for owned instances as attribute-level ownership is not supported by Portico yet).
 OCInstance removeInstance(int handle)
          Removes and returns the instance with the given handle from the repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instances

private Map<Integer,OCInstance> instances

disctypes

private Map<Integer,Integer> disctypes

state

private LRCState state
Constructor Detail

LRCInstanceRepository

public LRCInstanceRepository(LRCState state)
Create a new instance repository that is to reside within the given LRCState

Method Detail

addInstance

public OCInstance addInstance(OCInstance instance,
                              int discoveredType)
Adds the given instance to the repository. If there is already a store instance with the same handle as this new instance, the old version will be replaced (and returned). If the new instance is the first with the given handle, null will be returned.

If the given instance is null, no action will be taken and null will be returned.

Parameters:
instance - The instance being discovered
discoveredType - The class handle of the type the instance is being discovered as

getInstance

public OCInstance getInstance(int handle)
Gets the instance of the given handle from this repository and returns it. If there is no instance for that handle, null is returned.


getInstance

public OCInstance getInstance(String name)
Get the instance with the given name. If there is none by that name, null will be returned.


removeInstance

public OCInstance removeInstance(int handle)
Removes and returns the instance with the given handle from the repository. If there is no instance with that handle, null will be returned.


getDiscoveredType

public Integer getDiscoveredType(int handle)
Returns the handle of the class the instance was discovered as

Parameters:
handle - The handle of the instance to find the discovered class for
Returns:
The handle of the class the instance was discovered as

containsInstance

public boolean containsInstance(int handle)
Returns true if this repository contains an instance with the given handle, false otherwise


ownsAnyAttributes

public boolean ownsAnyAttributes()
Returns true if the federate represented by the LRC this repository is a part of owns any attributes stored within (currently only checks for owned instances as attribute-level ownership is not supported by Portico yet).


copyright The Portico Project 2008.