Package cmion.storage
Class CmionStorageContainer
java.lang.Object
ion.Meta.Element
cmion.architecture.CmionComponent
cmion.storage.CmionStorageContainer
- Direct Known Subclasses:
BlackBoard,WorldModel
a storage container is used for storing data that is shared between the components.
The world model and the black board are examples of storage containers. The way the stored
data is organised is as following: A storage container can contain properties and
sub containers. Sub Containers in turn contain properties and sub containers again, etc.
This way hierarchical knowledge can be stored. Write access to all data is through
scheduling requests only (RequestAddSubContainer, RequestRemoveSubContainer,
RequestSetProperty, RequestRemoveProperty). All data can be read any time though,
but many times registering event handlers will be the preferred method.
All sub containers and sub properties are identified through their name, which needs
to be unique (among the sibling sub containers and properties respectively). So
storage container worldModel cannot have 2 sub containers "John" or 2 properties
"date" but Storage containers "John" and "Paul" can both have property "age".
Storage containers additionally have a type field (if not needed it should just contain ""),
so that the storage hierarchy itself can also contain information about the type of information stored.
For example if there are containers for Agents and Objects as in WorldModel, the type
can help distinguishing them. For properties the type is not stored explicitly but implicit
through the class of the property object.
-
Field Summary
FieldsModifier and TypeFieldDescriptionby default properties are non persistent, if the container has a persistent property it will be in this set hereFields inherited from class cmion.architecture.CmionComponent
architecture -
Constructor Summary
ConstructorsModifierConstructorDescriptionCmionStorageContainer(IArchitecture architecture, String name, String type) create a new CMION Storage ContainerprotectedCmionStorageContainer(IArchitecture architecture, String name, String type, CmionStorageContainer parentContainer) create a new CMION Storage Container (this constructor is protected because it should not be accessed from outside) to create a new top level container, use the public constructor) -
Method Summary
Modifier and TypeMethodDescriptionreturns the name (identifier) of this containerreturns the type (class) of this containerreturns the parent container or null if this is the top container of a storage hierarchyreturns a list of all property namesgetPropertyNames(Class<T> propertyClass) returns a list of names of all properties that are of a certain classgetPropertyValue(String propertyName) returns the value of the property with the specified name or null if such a property does not exist in this containergetSubContainer(String subContainerName) returns the sub container with the provided name or null, if there is no such container in this storage containerreturns a list of all sub container namesgetSubContainerNames(String type) returns a list of names of all sub containers that have a certain typereturns the top container of the storage hierarchy that this container is part of, so typically this should return either the blackboard or the world model objectbooleanhasProperty(String name) returns whether the container has a property with the specified name<T> booleanhasProperty(String name, Class<T> propertyClass) returns whether the container has a property with the specified name and of the specified classbooleanhasSubContainer(String name) returns whether the container has a sub container with the specified namebooleanhasSubContainer(String name, String type) returns whether the container has a sub container with the specified name and of the specified typebooleanisPropertyPersistent(String propertyName) returns whether a property is persistent or notvoidregisterEventHandlerWithSubContainers(ion.Meta.EventHandler handler) registers an Event Handler with all entities this storage component possesses or will possess eventually.final voidregisters the request handlers of this storage component classvoidrequestAddSubContainer(String name, String type) convenience method for scheduling a requestAddSubContainer with this containervoidconvenience method for scheduling a requestAddSubContainer with this containervoidrequestAddSubContainer(String name, String type, HashMap<String, Object> initialProperties, HashSet<String> persistentProperties) convenience method for scheduling a requestAddSubContainer with this containervoidrequestRemoveProperty(String name) convenience method for scheduling a requestRemoveProperty with this containervoidconvenience method for scheduling a requestRemoveSubContainer with this containervoidrequestSetProperty(String name, Object value) convenience method for scheduling a requestSetProperty with this containervoidrequestSetProperty(String name, Object value, boolean persistent) convenience method for scheduling a requestSetProperty with this containertoString()Methods inherited from class cmion.architecture.CmionComponent
getArchitecture, isConnected, onDestroy, raiseMethods inherited from class ion.Meta.Element
destroy, getEventFilters, getEventHandlers, getRequestFilters, getRequestHandlers, getSimulation, getUID, schedule, wasDestroyed
-
Field Details
-
persistentProperties
by default properties are non persistent, if the container has a persistent property it will be in this set here
-
-
Constructor Details
-
CmionStorageContainer
protected CmionStorageContainer(IArchitecture architecture, String name, String type, CmionStorageContainer parentContainer) create a new CMION Storage Container (this constructor is protected because it should not be accessed from outside) to create a new top level container, use the public constructor)- Parameters:
name- the name of this container, should be unique along siblings in storage hierarchytype- the type/class of this containerparentContainer- the container that owns this container or null for a top container in a hierarchyarchitecture- reference to the architecture object
-
CmionStorageContainer
create a new CMION Storage Container- Parameters:
name- the name of this container, should be unique along siblings in storage hierarchytype- the type/class of this containerarchitecture- reference to the architecture object
-
-
Method Details
-
registerEventHandlerWithSubContainers
public void registerEventHandlerWithSubContainers(ion.Meta.EventHandler handler) registers an Event Handler with all entities this storage component possesses or will possess eventually. This method works recursively, so will also register with all sub containers of sub containers, etc. -
getSubContainer
returns the sub container with the provided name or null, if there is no such container in this storage container -
getParentContainer
returns the parent container or null if this is the top container of a storage hierarchy -
getPropertyValue
returns the value of the property with the specified name or null if such a property does not exist in this container -
getContainerName
returns the name (identifier) of this container -
getContainerType
returns the type (class) of this container -
getSubContainerNames
returns a list of all sub container names -
getSubContainerNames
returns a list of names of all sub containers that have a certain type -
getPropertyNames
returns a list of all property names -
isPropertyPersistent
returns whether a property is persistent or not- Returns:
- true if persistent, false if not
-
getPropertyNames
returns a list of names of all properties that are of a certain class- Type Parameters:
T- the class we want to find properties of- Parameters:
propertyClass- the class represented as a dynamic Class object- Returns:
- list of names of all properties that are of class T
-
registerHandlers
public final void registerHandlers()registers the request handlers of this storage component class- Specified by:
registerHandlersin classCmionComponent
-
hasProperty
returns whether the container has a property with the specified name -
hasProperty
returns whether the container has a property with the specified name and of the specified class -
hasSubContainer
returns whether the container has a sub container with the specified name -
hasSubContainer
returns whether the container has a sub container with the specified name and of the specified type -
requestAddSubContainer
public void requestAddSubContainer(String name, String type, HashMap<String, Object> initialProperties, HashSet<String> persistentProperties) convenience method for scheduling a requestAddSubContainer with this container -
requestAddSubContainer
public void requestAddSubContainer(String name, String type, HashMap<String, Object> initialProperties) convenience method for scheduling a requestAddSubContainer with this container -
requestAddSubContainer
convenience method for scheduling a requestAddSubContainer with this container -
requestRemoveSubContainer
convenience method for scheduling a requestRemoveSubContainer with this container -
requestSetProperty
convenience method for scheduling a requestSetProperty with this container -
requestSetProperty
convenience method for scheduling a requestSetProperty with this container -
requestRemoveProperty
convenience method for scheduling a requestRemoveProperty with this container -
getTopContainer
returns the top container of the storage hierarchy that this container is part of, so typically this should return either the blackboard or the world model object -
toString
-