public abstract class AbstractChannel extends java.lang.Object implements Channel
Modifier and Type | Field and Description |
---|---|
protected int |
channelID
This channels's ID.
|
protected java.util.Collection<Entity> |
subscribers
The set of subscribers.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractChannel(int channelID)
Construct an AbstractChannel.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addMessageForAgent(Entity a,
AKSpeak msg)
Register a message that should be send to an agent on the next call to @{link #getMessagesForAgent(AgentProxy)}.
|
protected void |
addMessageForSubscribers(AKSpeak msg)
Register a message that should be send to all subscribers.
|
void |
addSubscriber(Entity a)
Add a subscriber to this channel.
|
java.util.Collection<AKSpeak> |
getMessagesForAgent(Entity agent)
Get the messages that should be send to an agent.
|
java.util.Collection<Entity> |
getSubscribers()
Get all subscribers.
|
protected boolean |
isSubscribed(Entity e)
Find out if an entity is subscribed to this channel.
|
void |
push(AKSpeak speak)
Push a message through this channel.
|
protected abstract void |
pushImpl(AKSpeak msg,
int originalSize)
Push a message after input noise has been applied.
|
void |
removeSubscriber(Entity a)
Remove a subscriber from this channel.
|
void |
setInputNoise(Noise noise)
Set the input noise object for this channel.
|
void |
setOutputNoise(Noise noise)
Set the output noise object for this channel.
|
void |
timestep()
Notify the channel that a timestep has elapsed.
|
protected java.util.Collection<Entity> subscribers
protected int channelID
protected AbstractChannel(int channelID)
channelID
- The ID of this channel.public void setInputNoise(Noise noise)
Channel
setInputNoise
in interface Channel
noise
- The input noise.public void setOutputNoise(Noise noise)
Channel
setOutputNoise
in interface Channel
noise
- The output noise.public void timestep()
Channel
public void addSubscriber(Entity a)
Channel
addSubscriber
in interface Channel
a
- The subscriber.public void removeSubscriber(Entity a)
Channel
removeSubscriber
in interface Channel
a
- The subscriber.public java.util.Collection<Entity> getSubscribers()
Channel
getSubscribers
in interface Channel
public java.util.Collection<AKSpeak> getMessagesForAgent(Entity agent)
Channel
getMessagesForAgent
in interface Channel
agent
- The agent to look up.public final void push(AKSpeak speak) throws InvalidMessageException
Channel
push
in interface Channel
speak
- The message to push.InvalidMessageException
- If the message is invalid.protected abstract void pushImpl(AKSpeak msg, int originalSize) throws InvalidMessageException
msg
- The message.InvalidMessageException
- If the message is invalid.protected void addMessageForAgent(Entity a, AKSpeak msg)
a
- The agent.msg
- The message.protected void addMessageForSubscribers(AKSpeak msg)
msg
- The message.protected boolean isSubscribed(Entity e)
e
- The entity to check.