public class Probe<A extends AbstractAgent> extends Object
Watcher
,
PropertyProbe
Constructor and Description |
---|
Probe(String communityName,
String groupName,
String roleName)
Builds a new Probe<> on the given CGR location of the
artificial society.
|
Modifier and Type | Method and Description |
---|---|
protected void |
adding(A agent)
This method is automatically called when an agent
joins the corresponding group and role.
|
protected void |
adding(List<A> agents)
Called when a list of agents joins the corresponding group and role.
|
void |
allAgentsLeaveRole() |
static Field |
findFieldOn(Class<? extends AbstractAgent> agentClass,
String fieldName)
Returns the agent's field named
fieldName . |
String |
getCommunity() |
List<A> |
getCurrentAgentsList()
Returns a snapshot at moment t of the agents handling the group/role couple
|
String |
getGroup() |
String |
getRole() |
List<A> |
getShuffledList()
Returns a ListIterator over the agents which is shuffled
|
void |
initialize()
Called by the MaDKit kernel when the Activator or Probe is
first added.
|
void |
killAgents() |
protected void |
removing(A agent)
This method is automatically called when an agent
leaves the corresponding group and role.
|
protected void |
removing(List<A> agents)
This method is automatically called when
a list of agents has leaved the corresponding group and role.
|
int |
size()
Returns the number of the agents handling the group/role couple
|
String |
toString() |
public Probe(String communityName, String groupName, String roleName)
Watcher
agent using the Watcher.addProbe(Probe)
method.communityName
- groupName
- roleName
- Watcher
public static Field findFieldOn(Class<? extends AbstractAgent> agentClass, String fieldName) throws NoSuchFieldException
fieldName
.
This also works on private
fields, even
inherited ones.agentClass
- the targeted agentfieldName
- the name of the fieldfieldName
NoSuchFieldException
public String getCommunity()
public String getGroup()
public String getRole()
public void initialize()
adding(getCurrentAgentsList());
protected void adding(List<A> agents)
AbstractAgent.launchAgentBucket(String, int, String...)
.
Override this method when you want
to do some initialization on the agents that enter the group/role.
Default implementation is:
protected void adding(final List<A> agents) { for (A agent : agents) { adding(agent); } }
agents
- the list of agents which have been added to this group/role at once.protected void adding(A agent)
agent
- which has been added to this group/roleprotected void removing(List<A> agents)
protected void removing(final List<A> agents) { for (A agent : agents) { removing(agent); } }
agents
- the list of agents which have been removed from this group/roleprotected void removing(A agent)
agent
- which has been removed from this group/rolepublic int size()
public List<A> getCurrentAgentsList()
public List<A> getShuffledList()
public void killAgents()
public void allAgentsLeaveRole()
Fabien Michel, Olivier Gutknecht, Jacques Ferber