|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjp.go.aist.rtm.RTC.buffer.RingBuffer<DataType>
DataType
-
Data type to store in the bufferpublic class RingBuffer<DataType>
Ring buffer implementation class
[@.ja 指定した長さのリング状バッファを持つバッファ実装クラス。 バッファ全体にデータが格納された場合、以降のデータは古いデータから 順次上書きされる。 従って、バッファ内には直近のバッファ長分のデータのみ保持される。 注)現在の実装では、一番最後に格納したデータのみバッファから読み出し可能} This is the buffer implementation class with ring shaped buffer of specified length. If data is stored in the entire buffer, data from now on will be overwritten from old data one by one. Therefore, only the length of latest data is stored in the buffer. Note: In the current implementation, only last stored data can be read from the buffer.
Nested Class Summary | |
---|---|
protected class |
RingBuffer.condition
class for condition variable |
Field Summary | |
---|---|
(package private) int |
m_wcount
Counter for writing |
Constructor Summary | |
---|---|
RingBuffer()
Constructor |
|
RingBuffer(int length)
Constructor |
Method Summary | |
---|---|
ReturnCode |
advanceRptr()
advances the reading pointer. |
ReturnCode |
advanceRptr(int n)
advances the reading pointer. |
ReturnCode |
advanceWptr()
advances the writing pointer. |
ReturnCode |
advanceWptr(int n)
Get the buffer length |
boolean |
empty()
Check on whether the buffer is empty. |
boolean |
full()
Check on whether the buffer is full. |
DataType |
get()
Reading data from the buffer |
ReturnCode |
get(DataRef<DataType> value)
Write data into the buffer |
void |
init(Properties prop)
Sets the buffer. |
boolean |
isFull()
Check on whether the buffer is full. |
int |
length()
Get the buffer length |
ReturnCode |
length(int n)
Get the buffer length |
ReturnCode |
put(DataType data)
Write data into the buffer |
ReturnCode |
read(DataRef<DataType> valueRef)
Readout data from the buffer |
ReturnCode |
read(DataRef<DataType> valueRef,
int sec)
Readout data from the buffer |
ReturnCode |
read(DataRef<DataType> valueRef,
int sec,
int nsec)
Readout data from the buffer |
int |
readable()
returns the number of elements that can be read. |
ReturnCode |
reset()
Get the buffer length |
DataType |
rptr()
returns the pointer of a present reading element. |
DataType |
rptr(int n)
returns the pointer of a present reading element. |
DataType |
wptr()
Returns the pointer of a present writing element. |
DataType |
wptr(int n)
Returns the pointer of a present writing element. |
int |
writable()
Write data into the buffer |
ReturnCode |
write(DataType value)
Write data into the buffer |
ReturnCode |
write(DataType value,
int sec)
Write data into the buffer |
ReturnCode |
write(DataType value,
int sec,
int nsec)
Write data into the buffer |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
int m_wcount
Constructor Detail |
---|
public RingBuffer()
public RingBuffer(int length)
Initialize the buffer by specified buffer length. However, if the specified length is less than two, the buffer should be initialized by two in length.
length
-
Buffer lengthMethod Detail |
---|
public int length()
length
in interface BufferBase<DataType>
public ReturnCode length(int n)
Pure virtual function to get the buffer length.
length
in interface BufferBase<DataType>
public ReturnCode write(DataType value)
Write data which is given argument into the buffer.
write
in interface BufferBase<DataType>
value
-
Target data for writing
public ReturnCode write(DataType value, int sec)
Write data which is given argument into the buffer.
value
-
Target data for writingsec
-
Timeout sec
public ReturnCode write(DataType value, int sec, int nsec)
Write data which is given argument into the buffer.
write
in interface BufferBase<DataType>
value
-
Target data for writingsec
-
Timeout secnsec
-
Timeout nsec
public ReturnCode read(DataRef<DataType> valueRef)
Readout data stored into the buffer.
read
in interface BufferBase<DataType>
valueRef
-
Readout data
public ReturnCode read(DataRef<DataType> valueRef, int sec)
Readout data stored into the buffer.
valueRef
-
Readout datasec
-
TimeOut sec order
public ReturnCode read(DataRef<DataType> valueRef, int sec, int nsec)
Readout data stored into the buffer.
read
in interface BufferBase<DataType>
valueRef
-
Readout datasec
-
TimeOut sec ordernsec
-
TimeOut nsec order
public boolean isFull()
This is not implemented.
public ReturnCode put(DataType data)
Pure virtual function to write data into the buffer. Always BUFFER_OK will be returned in this implementation.
put
in interface BufferBase<DataType>
data
-
Target data to write.
public DataType get()
The position of the pointer for reading is not changed.
get
in interface BufferBase<DataType>
public ReturnCode get(DataRef<DataType> value)
The position of the pointer for reading is not changed.
get
in interface BufferBase<DataType>
value
-
Target data to write.
public void init(Properties prop)
Initializes the setting of the buffer according to the property given by Properties.
init
in interface BufferBase<DataType>
prop
-
Property to set bufferpublic ReturnCode reset()
Pure virtual function to get the buffer length.
reset
in interface BufferBase<DataType>
public DataType wptr(int n)
This function returns the object of a present writing element of the buffer.
wptr
in interface BufferBase<DataType>
n
-
Pointer for writing
public DataType wptr()
This function returns the pointer of a present writing element of the buffer.
wptr
in interface BufferBase<DataType>
public ReturnCode advanceWptr(int n)
This function advances the writing pointer.
advanceWptr
in interface BufferBase<DataType>
n
-
write pinter + n pointer
public ReturnCode advanceWptr()
This function advances the writing pointer.
advanceWptr
in interface BufferBase<DataType>
public int writable()
This function returns the number of elements that can be written in the buffer.
writable
in interface BufferBase<DataType>
public boolean full()
Pure virtual function to check on whether the buffer is full.
full
in interface BufferBase<DataType>
public DataType rptr(int n)
This function returns the pointer of a present reading element of the buffer.
rptr
in interface BufferBase<DataType>
n
-
reading position
public DataType rptr()
This function returns the pointer of a present reading element of the buffer.
rptr
in interface BufferBase<DataType>
public ReturnCode advanceRptr(int n)
This function advances the reading pointer.
advanceRptr
in interface BufferBase<DataType>
n
-
Advanced number of points
public ReturnCode advanceRptr()
This function advances the reading pointer.
advanceRptr
in interface BufferBase<DataType>
public int readable()
This function returns the number of elements that can be read from the buffer.
readable
in interface BufferBase<DataType>
public boolean empty()
Pure virtual function to check on whether the buffer is empty.
empty
in interface BufferBase<DataType>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |