public class QueueReceiver extends AbstractReceiver
FIFOQueue
Modifier and Type | Field and Description |
---|---|
protected FIFOQueue |
_queue
This is the queue in which data is stored.
|
static int |
INFINITE_CAPACITY
Used to indicate that the size of this queue receiver is infinite.
|
Constructor and Description |
---|
QueueReceiver()
Construct an empty receiver with no container.
|
QueueReceiver(IOPort container)
Construct an empty receiver with the specified container.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear this receiver of any contained tokens.
|
java.util.List<Token> |
elementList()
List the tokens in the receiver, beginning with the oldest.
|
java.util.Enumeration |
elements()
Deprecated.
Used elementList() instead.
|
Token |
get()
Remove the first token (the oldest one) from the receiver and
return it.
|
Token |
get(int offset)
Return a token in the receiver or its history.
|
int |
getCapacity()
Return the capacity, or INFINITE_CAPACITY if it is unbounded.
|
int |
getHistoryCapacity()
Return the capacity of the history queue.
|
boolean |
hasRoom()
Return true if the next call to put() will succeed without
a NoRoomException.
|
boolean |
hasRoom(int numberOfTokens)
Return true if the queue has room to put the given number of
tokens into it (via the put() method).
|
boolean |
hasToken()
Return true if the next call to get() will succeed without a
a NoTokenException.
|
boolean |
hasToken(int numberOfTokens)
Return true if the specified number of tokens is available in the
queue.
|
java.util.List |
historyElementList()
Deprecated.
Used historyElementList() instead.
|
java.util.Enumeration |
historyElements()
Deprecated.
Used historyElementList() instead.
|
int |
historySize()
Return the number of tokens in history.
|
void |
put(Token token)
Put a token to the receiver.
|
void |
setCapacity(int capacity)
Set receiver capacity.
|
void |
setHistoryCapacity(int capacity)
Set the capacity of the history queue.
|
int |
size()
Return the number of tokens in the receiver.
|
getArray, getContainer, getCurrentTime, getModelTime, isKnown, putArray, putArrayToAll, putToAll, reset, setContainer, toString
public static final int INFINITE_CAPACITY
protected FIFOQueue _queue
public QueueReceiver()
public QueueReceiver(IOPort container) throws IllegalActionException
container
- The container of the receiver.IllegalActionException
- If the container does
not accept this receiver.public void clear()
clear
in interface Receiver
clear
in class AbstractReceiver
public java.util.List<Token> elementList()
elementList
in interface Receiver
elementList
in class AbstractReceiver
@Deprecated public java.util.Enumeration elements()
public Token get()
get
in interface Receiver
get
in class AbstractReceiver
NoTokenException
- If there is no token in the receiver.public Token get(int offset)
offset
- The offset from the oldest token in the receiver.NoTokenException
- If the offset is out of range.public int getCapacity()
setCapacity(int)
public int getHistoryCapacity()
setHistoryCapacity(int)
public boolean hasRoom()
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
public boolean hasRoom(int numberOfTokens) throws java.lang.IllegalArgumentException
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
numberOfTokens
- The number of tokens to put into the queue.java.lang.IllegalArgumentException
- If the number of tokens is less
than one. This is a runtime exception, and hence does not need to
be explicitly declared by the caller.public boolean hasToken()
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
public boolean hasToken(int numberOfTokens) throws java.lang.IllegalArgumentException
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
numberOfTokens
- The number of tokens to get from the queue.java.lang.IllegalArgumentException
- If the number of tokens is less
than one. This is a runtime exception, and hence does not need to
be explicitly declared by the caller.@Deprecated public java.util.List historyElementList()
@Deprecated public java.util.Enumeration historyElements()
public int historySize()
public void put(Token token)
put
in interface Receiver
put
in class AbstractReceiver
token
- The token to be put to the receiver.NoRoomException
- If the receiver is full.public void setCapacity(int capacity) throws IllegalActionException
capacity
- The desired receiver capacity.IllegalActionException
- If the receiver has more tokens
than the proposed capacity or the proposed capacity is illegal.getCapacity()
public void setHistoryCapacity(int capacity) throws IllegalActionException
capacity
- The desired history capacity.IllegalActionException
- If the desired capacity is illegal.getHistoryCapacity()
public int size()