copyright The Portico Project 2008.

org.portico.shared.model
Class ObjectModel

java.lang.Object
  extended by org.portico.shared.model.ObjectModel
All Implemented Interfaces:
Serializable

public class ObjectModel
extends Object
implements Serializable

This class represents a HLA FOM. It contains a set of object and interaction classes (routing spaces not yet supported) which can be fetch via handle. It also contains links to the object and interaction roots of the model. In order to provide support for the notion of a dynamic-FOM, instances can be modified at any time unless the model has been locked with a call to the lock() method. After this call, the model will become static and function as normally expected within the HLA (note: models can be unlocked).

See Also:
Serialized Form

Field Summary
private  int handle
           
private  Map<Integer,ICMetadata> iclasses
           
private  ICMetadata icroot
           
static int INVALID_HANDLE
           
private  boolean locked
           
static int MAX_MOM_HANDLE
          The maximum handle value for MOM data
private  Map<Integer,OCMetadata> oclasses
           
private  OCMetadata ocroot
           
private  int privilegeToDelete
           
private static long serialVersionUID
           
private  Map<Integer,Space> spaces
           
private  HLAVersion version
           
 
Constructor Summary
ObjectModel()
          Creates a new instance with the default of Version.V1_3
ObjectModel(HLAVersion version)
          Creates a new instance with the given version
 
Method Summary
 void addInteractionClass(ICMetadata ic)
          Add the given interaction class to this model.
 void addObjectClass(OCMetadata oc)
          Add the given object class to this model.
 void addSpace(Space space)
          Add the given Space to this model.
private  int generateHandle()
           
 Set<ICMetadata> getAllInteractionClasses()
          Get a set of all the interaction classes currently contained within this FOM.
 Set<OCMetadata> getAllObjectClasses()
          Get a set of all the object classes currently contained within this FOM.
 Collection<Space> getAllSpaces()
          Returns the collection of all spaces declared in the FOM
 ACMetadata getAttributeClass(int classHandle, String attributeName)
          This method will fetch the ACMetadata for the attribute of the given name in the class of the given handle.
 ICMetadata getInteractionClass(int handle)
          Fetch the object class of the given handle in this model.
 ICMetadata getInteractionClass(String name)
          Find the interaction class with the given name and return it.
 int getInteractionClassHandle(String name)
          Get the handle of the class with the given name.
 String getInteractionClassName(int handle)
          Get the name of the interaction class represented by the given handle in this model.
 ICMetadata getInteractionRoot()
          Get the class that represents InteractionRoot (or HLAInteractionRoot in 1516).
 OCMetadata getObjectClass(int handle)
          Fetch the object class of the given handle in this model.
 OCMetadata getObjectClass(String name)
          Fetch the object class with the given name and return it.
 int getObjectClassHandle(String name)
          Get the handle of the class with the given name.
 String getObjectClassName(int handle)
          Get the name of the object class represented by the given handle in this model.
 OCMetadata getObjectRoot()
          Get the class that represents ObjectRoot (or HLAObjectRoot in 1516).
 int getPrivilegeToDelete()
          This method will get the handle of the privilege to delete attribute.
 Space getSpace(int spaceHandle)
          Fetch the space contained in this model that has the given handle and return it.
 Space getSpace(String name)
          Fetch the space contained in this model that has the given name and return it.
 void lock()
          Locks this model so that changes can no longer be made.
static void mommify(ObjectModel model)
          DO NOT USE!!!
 ACMetadata newAttribute(String name)
          Creates a new ACMetadata instance with the given name and a generated handle.
 Dimension newDimension(String name)
          Creates a new Dimension instance with the given name and generates a FOM-unique handle for it.
 ICMetadata newInteraction(String name)
          Creates a new ICMetadata instance with the given name and a generaetd handle.
 OCMetadata newObject(String name)
          Creates a new OCMetadata instance with the given name and a generaetd handle.
 PCMetadata newParameter(String name)
          Creates a new PCMetadata instance with the given name and a generated handle.
 Space newSpace(String name)
          Creates a new Space instance with the given name and generates a FOM-unique handle for it.
 ICMetadata removeInteractionClass(int handle)
          Remove and return the given interaction class from this model.
 OCMetadata removeObjectClass(int handle)
          Remove and return the given object class from this model.
 void setInteractionRoot(ICMetadata root)
          Designate the given class as the interaction root of this FOM.
 void setObjectRoot(OCMetadata root)
          Designate the given class as the object root of this FOM.
 String toString()
           
 void unlock()
          Unlocks this model so that changes can be made once again
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

INVALID_HANDLE

public static final int INVALID_HANDLE
See Also:
Constant Field Values

MAX_MOM_HANDLE

public static final int MAX_MOM_HANDLE
The maximum handle value for MOM data

See Also:
Constant Field Values

handle

private int handle

version

private HLAVersion version

locked

private boolean locked

oclasses

private Map<Integer,OCMetadata> oclasses

iclasses

private Map<Integer,ICMetadata> iclasses

spaces

private Map<Integer,Space> spaces

ocroot

private OCMetadata ocroot

icroot

private ICMetadata icroot

privilegeToDelete

private int privilegeToDelete
Constructor Detail

ObjectModel

public ObjectModel()
Creates a new instance with the default of Version.V1_3


ObjectModel

public ObjectModel(HLAVersion version)
Creates a new instance with the given version

Method Detail

getSpace

public Space getSpace(int spaceHandle)
Fetch the space contained in this model that has the given handle and return it. If the space doesn't exist, return null.


getSpace

public Space getSpace(String name)
Fetch the space contained in this model that has the given name and return it. If the space doesn't exist, return null.


getAllSpaces

public Collection<Space> getAllSpaces()
Returns the collection of all spaces declared in the FOM

Returns:

addSpace

public void addSpace(Space space)
Add the given Space to this model. If a space with the same handle already exists, it will be overwritten with this new space. If the model has been locked, this request will be ignored.


getObjectClass

public OCMetadata getObjectClass(int handle)
Fetch the object class of the given handle in this model. If there is none for the handle, null will be returned.


getObjectClass

public OCMetadata getObjectClass(String name)
Fetch the object class with the given name and return it. If none is found, null is returned. This method will take into account version differences, thus, you can use ObjectRoot or HLAobjectRoot in the name and it will make no difference.


getAttributeClass

public ACMetadata getAttributeClass(int classHandle,
                                    String attributeName)
This method will fetch the ACMetadata for the attribute of the given name in the class of the given handle. If the name doesn't represent a valid attribute, or the handle doesn't represent a valid class, null will be returned.


getObjectRoot

public OCMetadata getObjectRoot()
Get the class that represents ObjectRoot (or HLAObjectRoot in 1516). If it has not yet been set, null will be returned.


setObjectRoot

public void setObjectRoot(OCMetadata root)
Designate the given class as the object root of this FOM. This request will be ignored if the model has been lock()'ed. This request will also be ignored if the fully qualified name of the class is not "ObjectRoot" (for 1.3) or "HLAObjectRoot" (for 1516).


getAllObjectClasses

public Set<OCMetadata> getAllObjectClasses()
Get a set of all the object classes currently contained within this FOM.


addObjectClass

public void addObjectClass(OCMetadata oc)
Add the given object class to this model. If a class with the same handle already exists, it will be overwritten with this new class. If the model has been locked, this request will be ignored.


removeObjectClass

public OCMetadata removeObjectClass(int handle)
Remove and return the given object class from this model. If the class does not exist, null will be returned. If the model has been locked, this request will be ignored.


getObjectClassHandle

public int getObjectClassHandle(String name)
Get the handle of the class with the given name. If no such class exists in this model, INVALID_HANDLE will be returned.


getObjectClassName

public String getObjectClassName(int handle)
Get the name of the object class represented by the given handle in this model. If the handle does not represent a class, null will be returned.


getPrivilegeToDelete

public int getPrivilegeToDelete()
This method will get the handle of the privilege to delete attribute. As the standards board changed the name of the attribute from 1.3 to 1516 (for no other good reason than to cause everyone pain), this method will take version into account. A user should NEVER try and get privilegeToDelete or HLAprivilegeToDeleteObject by name from wihin a handler (or any part of the RTI).

Returns:
The handle for the privilege to delete attribute or INVALID_HANDLE if there is no currently set object root.

getInteractionClass

public ICMetadata getInteractionClass(int handle)
Fetch the object class of the given handle in this model. If there is none for the handle, null will be returned.


getInteractionClass

public ICMetadata getInteractionClass(String name)
Find the interaction class with the given name and return it. If there is none with that name, null will be returned.


getInteractionRoot

public ICMetadata getInteractionRoot()
Get the class that represents InteractionRoot (or HLAInteractionRoot in 1516). If it has not yet been set, null will be returned.


setInteractionRoot

public void setInteractionRoot(ICMetadata root)
Designate the given class as the interaction root of this FOM. This request will be ignored if the model has been lock()'ed. This request will also be ignored if the fully qualified name of the class is not "InteractionRoot" (for 1.3) or "HLAInteractionRoot" (for 1516).


getAllInteractionClasses

public Set<ICMetadata> getAllInteractionClasses()
Get a set of all the interaction classes currently contained within this FOM.


addInteractionClass

public void addInteractionClass(ICMetadata ic)
Add the given interaction class to this model. If a class with the same handle already exists, it will be overwritten with this new class. If the model has been locked, this request will be ignored.


removeInteractionClass

public ICMetadata removeInteractionClass(int handle)
Remove and return the given interaction class from this model. If the class does not exist, null will be returned. If the model has been locked, this request will be ignored.


getInteractionClassHandle

public int getInteractionClassHandle(String name)
Get the handle of the class with the given name. If no such class exists in this model, INVALID_HANDLE will be returned.


getInteractionClassName

public String getInteractionClassName(int handle)
Get the name of the interaction class represented by the given handle in this model. If the handle does not represent a class, null will be returned.


lock

public void lock()
Locks this model so that changes can no longer be made.


unlock

public void unlock()
Unlocks this model so that changes can be made once again


newObject

public OCMetadata newObject(String name)
Creates a new OCMetadata instance with the given name and a generaetd handle.


newAttribute

public ACMetadata newAttribute(String name)
Creates a new ACMetadata instance with the given name and a generated handle.


newInteraction

public ICMetadata newInteraction(String name)
Creates a new ICMetadata instance with the given name and a generaetd handle.


newParameter

public PCMetadata newParameter(String name)
Creates a new PCMetadata instance with the given name and a generated handle.


newSpace

public Space newSpace(String name)
Creates a new Space instance with the given name and generates a FOM-unique handle for it.


newDimension

public Dimension newDimension(String name)
Creates a new Dimension instance with the given name and generates a FOM-unique handle for it.


generateHandle

private int generateHandle()

toString

public String toString()
Overrides:
toString in class Object

mommify

public static void mommify(ObjectModel model)
DO NOT USE!!!

This method will take the given model, rip out any MOM classes and then insert a bunch of MOM specific classes that conform to the structure/handles we expect. Use of this method is a temporary solution for PORT-313. I reserve the right to remove it at any point in time, without warning, hinting or even a cryptic blog post that might hint towards a potential impending action which may or may not pertain to the removal of said method. This won't ever be marked deprecated, rather, I'll just go all "preemptive strike" on it. One day you WILL wake up and it WILL just be gone.


copyright The Portico Project 2008.