public interface IAgentRunner<AGENT extends IAgent,PARAMS extends IAgentParameters>
IMultipleAgentRunner implementation that you can use.)
Every implementor is instantiated with default values that should be passed into the agent when no
other parameters are provided. Therefore you may use startAgent() to start agent
with default params, or startAgents(int) and startAgents(IAgentParameters...)
where you may specify your own params.
Note that the IAgentRunner utilize IAgentParameters.assignDefaults(IAgentParameters) to fill
missing fields into IAgentParameters which allows you to instantiate the IAgentParameters implementor
with custom data leaving the rest to the IAgentRunner (eases the pain of starting agents greatly).
The interface also provides a "synchronizing" feature via setPausing(boolean). If set true,
the runner will pause all agents after they start and resume them at once when all agents have been instantiated.
Pausing behavior is disabled (== set to false) as default.
USING FROM THE main(String[] args) METHOD
Starting agents from the main method requires special care:
setMain(boolean) with 'true' and the runner will behave differently.
(Note that all startAgent methods will block!)| Modifier and Type | Method and Description |
|---|---|
boolean |
isMain()
Whether the runner is set to provide 'main' functionality (see the Javadoc for the whole class).
|
boolean |
isPausing()
Tells, whether the pausing behavior is enabled.
|
IAgentRunner<AGENT,PARAMS> |
setMain(boolean state)
Sets 'main' functionality (see the Javadoc for the whole class).
|
IAgentRunner<AGENT,PARAMS> |
setPausing(boolean state)
Sets the pausing behavior.
|
AGENT |
startAgent()
Starts the agent by providing default parameters (defined during the construction of the implementor).
|
List<AGENT> |
startAgents(int count)
Starts agents by providing every one of them with default parameters
(defined during the construction of the implementor).
|
List<AGENT> |
startAgents(PARAMS... agentsParameters)
Start an agent instance configured with 'agentsParameters'.
|
AGENT startAgent() throws cz.cuni.amis.utils.exception.PogamutException
cz.cuni.amis.utils.exception.PogamutExceptionList<AGENT> startAgents(int count) throws cz.cuni.amis.utils.exception.PogamutException
Note that if any instantiation/start of the agent fails, all agents are killed before the method throws the exception.
count - how many agents should be startedcz.cuni.amis.utils.exception.PogamutExceptionList<AGENT> startAgents(PARAMS... agentsParameters) throws cz.cuni.amis.utils.exception.PogamutException
Note that if any instantiation/start of the agent fails, all agents are killed before the method throws the exception.
WARNING: if you want to use this method, you have to carefully type your runner instance, i.e., provide java-generic <AGENT_CLASS> information, otherwise Java won't compile your code correctly!
agentsParameters - cz.cuni.amis.utils.exception.PogamutExceptionIAgentRunner<AGENT,PARAMS> setPausing(boolean state)
If set true, the runner will pause all agents after their construction and resume them at once whenever all agents has been successfully started.
state - boolean isPausing()
If enabled, the runner will pause all agents after their construction and resume them at once whenever all agents has been instantiated.
IAgentRunner<AGENT,PARAMS> setMain(boolean state)
state - boolean isMain()
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.