cz.cuni.amis.pogamut.multi.communication.worldview.property
Class AbstractSharedProperty<TYPE>

java.lang.Object
  extended by cz.cuni.amis.pogamut.multi.communication.worldview.property.AbstractSharedProperty<TYPE>
All Implemented Interfaces:
ISharedProperty<TYPE>, java.lang.Cloneable
Direct Known Subclasses:
BooleanProperty, ColorProperty, Dimension2DProperty, DoubleProperty, FloatProperty, IntegerProperty, IntProperty, ItemTypeProperty, LocationProperty, LongProperty, RotationProperty, StringProperty, UnrealIdProperty, Vector3dProperty, VelocityProperty

public abstract class AbstractSharedProperty<TYPE>
extends java.lang.Object
implements ISharedProperty<TYPE>

Abstract implementation of the ISharedProperty object, this class manages the methods every ISharedProperty needs to have, regardless of its type.

SharedProperties are generally derived from bot's subjective observation of the world (local properties). If the local properties, which are used to derive the value of the sharedProperty are dated, the sharedProperty is considered "dirty", because the value might be wrong, the team that owns this property only assumes the value.


Nested Class Summary
static class AbstractSharedProperty.GenericPropertyUpdate
           
 
Field Summary
protected  java.lang.Class<?> compositeClass
           
protected  boolean dirty
           
protected  PropertyId propertyId
           
protected  TYPE value
           
 
Constructor Summary
AbstractSharedProperty(AbstractSharedProperty source)
          Used in copy-constructors, when writing a copy constructor for a descendant class, you must add a clone for value.
AbstractSharedProperty(WorldObjectId objectId, java.lang.String identifier, java.lang.Class compositeClass)
          Used in propertyConstructors from data.
AbstractSharedProperty(WorldObjectId objId, java.lang.String identifier, TYPE value, java.lang.Class<?> compositeClass)
           
 
Method Summary
abstract  ISharedProperty<TYPE> clone()
          Must return an exact duplicate of this ISharedProperty, this will be used to create old versions of SharedProperties in the worldView.
protected abstract  TYPE cloneValue()
          Every descendant must implement this by calling value.clone() or otherwise returning a new copy of value.
 ISharedPropertyUpdatedEvent createUpdateEvent(long time, ITeamId teamId)
          Creates an event updating a sharedProperty of the same id and the specified team to the same value as the parent property.
 boolean equals(java.lang.Object another)
           
 java.lang.Class getCompositeClass()
          Class of the compositeObject this property belongs to.
 WorldObjectId getObjectId()
          ObjectId of the object that this property is part of.
 PropertyId getPropertyId()
          Unique Id of this property.
 TYPE getValue()
          Returns value of the property.
 int hashCode()
           
 boolean isDirty()
          SharedProperties are generally properties derived from bot's observation of the world.
 void setDirty(boolean value)
           
 void setValue(TYPE value)
          Sets the value of the property - should be used by Pogamut Library developers only!
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.amis.pogamut.multi.communication.worldview.object.ISharedProperty
getPropertyValueClass
 

Field Detail

propertyId

protected PropertyId propertyId

dirty

protected boolean dirty

compositeClass

protected java.lang.Class<?> compositeClass

value

protected TYPE value
Constructor Detail

AbstractSharedProperty

public AbstractSharedProperty(WorldObjectId objId,
                              java.lang.String identifier,
                              TYPE value,
                              java.lang.Class<?> compositeClass)

AbstractSharedProperty

public AbstractSharedProperty(AbstractSharedProperty source)
Used in copy-constructors, when writing a copy constructor for a descendant class, you must add a clone for value.

Parameters:
source -

AbstractSharedProperty

public AbstractSharedProperty(WorldObjectId objectId,
                              java.lang.String identifier,
                              java.lang.Class compositeClass)
Used in propertyConstructors from data.

Parameters:
objectId -
identifier -
compositeClass -
Method Detail

cloneValue

protected abstract TYPE cloneValue()
Every descendant must implement this by calling value.clone() or otherwise returning a new copy of value.

Returns:

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object another)
Overrides:
equals in class java.lang.Object

clone

public abstract ISharedProperty<TYPE> clone()
Description copied from interface: ISharedProperty
Must return an exact duplicate of this ISharedProperty, this will be used to create old versions of SharedProperties in the worldView.

Specified by:
clone in interface ISharedProperty<TYPE>
Overrides:
clone in class java.lang.Object
Returns:

getValue

public TYPE getValue()
Description copied from interface: ISharedProperty
Returns value of the property.

Specified by:
getValue in interface ISharedProperty<TYPE>
Returns:

setValue

public void setValue(TYPE value)
Description copied from interface: ISharedProperty
Sets the value of the property - should be used by Pogamut Library developers only!

Specified by:
setValue in interface ISharedProperty<TYPE>

getCompositeClass

public java.lang.Class getCompositeClass()
Description copied from interface: ISharedProperty
Class of the compositeObject this property belongs to.

Specified by:
getCompositeClass in interface ISharedProperty<TYPE>
Returns:

isDirty

public boolean isDirty()
Description copied from interface: ISharedProperty
SharedProperties are generally properties derived from bot's observation of the world. (like visible => spawned ). This may become a problem when the inferred information is outdated (ie. a bot can no longer see the spawned item, but the last time anybody from the team saw it, it was spawned). In this case, we consider the information "dirty", because the team only assumes the value. It can be wrong. (the game will always know the correct value of course, only our AI won't.

Specified by:
isDirty in interface ISharedProperty<TYPE>
Returns:

setDirty

public void setDirty(boolean value)

getObjectId

public WorldObjectId getObjectId()
Description copied from interface: ISharedProperty
ObjectId of the object that this property is part of.

Specified by:
getObjectId in interface ISharedProperty<TYPE>
Returns:

getPropertyId

public PropertyId getPropertyId()
Description copied from interface: ISharedProperty
Unique Id of this property.

Specified by:
getPropertyId in interface ISharedProperty<TYPE>
Returns:

createUpdateEvent

public ISharedPropertyUpdatedEvent createUpdateEvent(long time,
                                                     ITeamId teamId)
Description copied from interface: ISharedProperty
Creates an event updating a sharedProperty of the same id and the specified team to the same value as the parent property.

Specified by:
createUpdateEvent in interface ISharedProperty<TYPE>
Returns: