48template <
class _elementType>
53 typedef _elementType value_type;
57 typedef value_type * pointer;
58 typedef const value_type * const_pointer;
59 typedef value_type & reference;
60 typedef const value_type & const_reference;
69 Node(
const pointer data):
75 typedef Node * NodePointer;
78 volatile NodePointer LastWriteNode;
79 volatile NodePointer WriteNode;
80 volatile NodePointer ReadNode;
95 this->Memory =
new value_type[3];
126 inline void SetupNodes(pointer pointer1, pointer pointer2, pointer pointer3) {
132 this->LastWriteNode =
new Node(pointer1);
133 this->LastWriteNode->Next =
new Node(pointer2);
134 this->LastWriteNode->Next->Next =
new Node(pointer3);
135 this->LastWriteNode->Next->Next->Next = this->LastWriteNode;
142 if (this->OwnMemory) {
145 delete[] this->Memory;
147 delete this->LastWriteNode->Next->Next->Pointer;
148 delete this->LastWriteNode->Next->Pointer;
149 delete this->LastWriteNode->Pointer;
153 delete this->LastWriteNode->Next->Next;
154 delete this->LastWriteNode->Next;
155 delete this->LastWriteNode;
160 inline void Read(reference placeHolder) {
162 placeHolder = *(ReadNode->Pointer);
168 inline void Write(const_reference newValue) {
170 *(WriteNode->Pointer) = newValue;
179 return this->ReadNode->Pointer;
187 return this->WriteNode->Pointer;
194 this->ReadNode = this->LastWriteNode;
209 this->WriteNode = this->LastWriteNode->Next;
211 LastCompare = (this->WriteNode == this->ReadNode);
213 this->WriteNode = this->WriteNode->Next;
221 this->LastWriteNode = this->WriteNode;
227 outputStream <<
"Node addresses from LastWriteNode: "
228 << this->LastWriteNode <<
"[" << this->LastWriteNode->Pointer <<
"] "
229 << this->LastWriteNode->Next <<
"[" << this->LastWriteNode->Next->Pointer <<
"] "
230 << this->LastWriteNode->Next->Next <<
"[" << this->LastWriteNode->Next->Next->Pointer <<
"]" << std::endl
231 <<
"LastCompare of read/write: " << ((this->LastCompare) ?
"equal" :
"different") << std::endl
232 <<
"ReadNode address: " << this->ReadNode << std::endl
233 <<
"WriteNode address: " << this->WriteNode << std::endl;
_elementType value_type
Definition mtsGenericObjectProxy.h:329
void EndWrite(void)
Definition osaTripleBuffer.h:220
void Read(reference placeHolder)
Definition osaTripleBuffer.h:160
pointer GetWritePointer(void) const
Definition osaTripleBuffer.h:186
void BeginWrite(void)
Definition osaTripleBuffer.h:208
void BeginRead(void)
Definition osaTripleBuffer.h:192
~osaTripleBuffer()
Definition osaTripleBuffer.h:140
const_pointer GetReadPointer(void) const
Definition osaTripleBuffer.h:178
osaTripleBuffer(pointer pointer1, pointer pointer2, pointer pointer3)
Definition osaTripleBuffer.h:117
void Write(const_reference newValue)
Definition osaTripleBuffer.h:168
friend class osaTripleBufferTest
Definition osaTripleBuffer.h:51
void ToStream(std::ostream &outputStream) const
Definition osaTripleBuffer.h:226
void SetupNodes(pointer pointer1, pointer pointer2, pointer pointer3)
Definition osaTripleBuffer.h:126
osaTripleBuffer(const_reference initialValue)
Definition osaTripleBuffer.h:104
void EndRead(void)
Definition osaTripleBuffer.h:199
osaTripleBuffer(void)
Definition osaTripleBuffer.h:92
Assert macros definitions.
#define CMN_ASSERT(expr)
Definition cmnAssert.h:97
const_pointer Pointer(index_type rowIndex, index_type colIndex) const
Definition vctDynamicConstMatrixBase.h:306