The built-in capacity InnerContextAccess
provides access to the inner context of the agent.
This is a key feature for creating holonic agent implementation.
The context supported by this built-in capacity is the “inner context,” illustrated by the
bottom context in the figure above.
For retrieving the inner context of an agent, this built-in capacity provides the following function:
def getInnerContext : AgentContext
Example:
agent A {
uses InnerContextAccess
var c : AgentContext
def myaction {
c = getInnerContext
}
}
For retrieving the default space of the inner context, this built-in capacity provides the following function:
def getInnerDefaultSpace : EventSpace
Example:
agent A {
uses InnerContextAccess
var s : EventSpace
def myaction {
s = getInnerDefaultSpace
}
}
For retrieving information on the member agents of the current agent, several functions are provided by this built-in capacity. A member agent is an agent that is not the calling agent, and is a member of at least one space of the inner context.
The first function replies if the calling agent has other agents as members of its inner context:
def hasMemberAgent : boolean
The second function replies the number of agents that are members of the inner context of the calling agent:
def getMemberAgentCount : int
The third function replies all the member agents in the inner context:
def getMemberAgents : ConcurrentSet<UUID>
Examples:
agent A {
uses InnerContextAccess
var b : boolean
var n : int
var m : ConcurrentSet<UUID>
def myaction {
b = hasMemberAgent
n = getMemberAgentCount
m = getMemberAgents
}
}
The InnerContextAccess
provides a collection of utility functions that test if their parameters
are related to the inner context.
Function | Explanation |
---|---|
isInnerDefaultSpace(Space) |
tests if the given space is the default space of the inner context. |
isInnerDefaultSpace(SpaceID) |
tests if the default space of the inner context has the given identifier. |
isInnerDefaultSpace(UUID) |
tests if the default space of the inner context has the given identifier. |
isInInnerDefaultSpace(Event) |
tests if the given event was emitted in the default space of the inner context. |
The following example illustrates the use of the isInInnerDefaultSpace
function in the guard
of an behavior unit. In this example, the behavior unit is run only if the event
of type AnEvent
was emitted in the default space of the inner context.
Note According to the General Syntax Reference, the event.isInnerDefaultSpace
is equivalent to isInnerDefaultSpace(event)
.
on AnEvent [ occurrence.inInnerDefaultSpace ] {
// Do something with the event when it was emitted in the inner default space
}
Copyright © 2014-2024 SARL.io, the Original Authors and Main Authors.
Documentation text and medias are licensed under the Creative Common CC-BY-SA-4.0; you may not use this file except in compliance with CC-BY-SA-4.0. You may obtain a copy of CC-BY-4.0.
Examples of SARL code are licensed under the Apache License, Version 2.0; you may not use this file except in compliance with the Apache License. You may obtain a copy of the Apache License.
You are free to reproduce the content of this page on copyleft websites such as Wikipedia.
Generated with the translator docs.generator 0.14.0.