org.pandora.thought
Class BasicMind

java.lang.Object
  extended by org.pandora.thought.BasicMind
All Implemented Interfaces:
Mind

public class BasicMind
extends java.lang.Object
implements Mind

Controls and manages the thought processing.


Nested Class Summary
 class BasicMind.SubconsciousThread
          Thread to process subconscious thoughts in the background.
 
Nested classes/interfaces inherited from interface org.pandora.api.thought.Mind
Mind.MentalState
 
Field Summary
static long UNACTIVE_TO_ASLEEP
           
static long UNACTIVE_TO_BORED
           
 
Constructor Summary
BasicMind()
           
 
Method Summary
 void addThought(Thought thought)
           
 void awake()
          Spawn a thread to run the thoughts.
 void decrementState(Mind.MentalState state)
          Ensure the maximum state.
 long getLastActiveTime()
           
 Pandora getPandora()
          Return Pandora.
 Mind.MentalState getState()
          Return the state of mind.
<T> T
getThought(java.lang.Class<T> type)
           
 Thought getThought(java.lang.String name)
           
 java.util.Map<java.lang.String,Thought> getThoughts()
           
 long getUnactiveTime()
          Returns the amount of time since was last active.
 void incrementState(Mind.MentalState state)
          Ensure the minimum state.
 void initialize(java.util.Map<java.lang.String,java.lang.Object> properties)
          Initialize any configurable settings from the properties.
 boolean isActive()
          Return if in an active state.
 boolean isAsleep()
          Return if in an sleep state.
 boolean isBored()
          Return if in an bored state.
 boolean isConscious()
          Return if in an conscious state.
 void log(java.lang.String message, java.util.logging.Level level, java.lang.Object... arguments)
          Log the message if the debug level is greater or equal to the level.
 void log(java.lang.Throwable exception)
          Log the exception.
 void processConsciousThoughts()
          Process all conscious thoughts, in-order, starting at Consciousness.
 void removeThought(Thought thought)
           
 void setLastActiveTime(long lastActiveTime)
           
 void setPandora(Pandora pandora)
          Set Pandora.
 void setState(Mind.MentalState state)
          Set the state of mind.
 void shutdown()
           
 java.lang.String toString()
          Print a useful string representation of the mind.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNACTIVE_TO_ASLEEP

public static long UNACTIVE_TO_ASLEEP

UNACTIVE_TO_BORED

public static long UNACTIVE_TO_BORED
Constructor Detail

BasicMind

public BasicMind()
Method Detail

getState

public Mind.MentalState getState()
Return the state of mind.

Specified by:
getState in interface Mind

setState

public void setState(Mind.MentalState state)
Set the state of mind.


incrementState

public void incrementState(Mind.MentalState state)
Ensure the minimum state.


decrementState

public void decrementState(Mind.MentalState state)
Ensure the maximum state.


isConscious

public boolean isConscious()
Return if in an conscious state.

Specified by:
isConscious in interface Mind

isActive

public boolean isActive()
Return if in an active state.

Specified by:
isActive in interface Mind

isAsleep

public boolean isAsleep()
Return if in an sleep state.

Specified by:
isAsleep in interface Mind

isBored

public boolean isBored()
Return if in an bored state.

Specified by:
isBored in interface Mind

log

public void log(java.lang.String message,
                java.util.logging.Level level,
                java.lang.Object... arguments)
Log the message if the debug level is greater or equal to the level.


log

public void log(java.lang.Throwable exception)
Log the exception.


getPandora

public Pandora getPandora()
Return Pandora.

Specified by:
getPandora in interface Mind

setPandora

public void setPandora(Pandora pandora)
Set Pandora.

Specified by:
setPandora in interface Mind

initialize

public void initialize(java.util.Map<java.lang.String,java.lang.Object> properties)
Initialize any configurable settings from the properties.

Specified by:
initialize in interface Mind

shutdown

public void shutdown()
Specified by:
shutdown in interface Mind

awake

public void awake()
Spawn a thread to run the thoughts. Currently only uses a single thread, but should probably have a least one thread per thought, or more.

Specified by:
awake in interface Mind

processConsciousThoughts

public void processConsciousThoughts()
Process all conscious thoughts, in-order, starting at Consciousness. Conscious thoughts use the short-term memory and are single threaded.


getThoughts

public java.util.Map<java.lang.String,Thought> getThoughts()
Specified by:
getThoughts in interface Mind

getThought

public <T> T getThought(java.lang.Class<T> type)
Specified by:
getThought in interface Mind

getThought

public Thought getThought(java.lang.String name)
Specified by:
getThought in interface Mind

addThought

public void addThought(Thought thought)
Specified by:
addThought in interface Mind

removeThought

public void removeThought(Thought thought)
Specified by:
removeThought in interface Mind

toString

public java.lang.String toString()
Print a useful string representation of the mind.

Overrides:
toString in class java.lang.Object

getUnactiveTime

public long getUnactiveTime()
Returns the amount of time since was last active.


getLastActiveTime

public long getLastActiveTime()

setLastActiveTime

public void setLastActiveTime(long lastActiveTime)