19 #include "igtlMessageBase.h"
33 this->m_Mutex->Lock();
35 m_CommandQueue.clear();
37 m_CommandQueue.push_back(message);
38 this->m_Mutex->Unlock();
43 this->m_Mutex->Lock();
45 std::stringstream infolog;
47 infolog <<
"Received message of type ";
49 if (dynamic_cast<igtl::TrackingDataMessage*>(msg.GetPointer()) !=
nullptr)
52 m_TrackingDataQueue.clear();
54 this->m_TrackingDataQueue.push_back(dynamic_cast<igtl::TrackingDataMessage*>(msg.GetPointer()));
58 else if (dynamic_cast<igtl::TransformMessage*>(msg.GetPointer()) !=
nullptr)
61 m_TransformQueue.clear();
63 this->m_TransformQueue.push_back(dynamic_cast<igtl::TransformMessage*>(msg.GetPointer()));
65 infolog <<
"TRANSFORM";
67 else if (dynamic_cast<igtl::StringMessage*>(msg.GetPointer()) !=
nullptr)
70 m_StringQueue.clear();
72 this->m_StringQueue.push_back(dynamic_cast<igtl::StringMessage*>(msg.GetPointer()));
76 else if (dynamic_cast<igtl::ImageMessage*>(msg.GetPointer()) !=
nullptr)
79 int* dim =
new int[3];
80 imageMsg->GetDimensions(dim);
84 m_Image3dQueue.clear();
86 this->m_Image3dQueue.push_back(dynamic_cast<igtl::ImageMessage*>(msg.GetPointer()));
93 m_Image2dQueue.clear();
95 this->m_Image2dQueue.push_back(dynamic_cast<igtl::ImageMessage*>(msg.GetPointer()));
105 this->m_MiscQueue.push_back(msg);
110 m_Latest_Message = msg;
114 this->m_Mutex->Unlock();
120 this->m_Mutex->Lock();
121 if (this->m_SendQueue.size() > 0)
123 ret = this->m_SendQueue.front();
124 this->m_SendQueue.pop_front();
126 this->m_Mutex->Unlock();
133 this->m_Mutex->Lock();
134 if (this->m_MiscQueue.size() > 0)
136 ret = this->m_MiscQueue.front();
137 this->m_MiscQueue.pop_front();
139 this->m_Mutex->Unlock();
146 this->m_Mutex->Lock();
147 if (this->m_Image2dQueue.size() > 0)
149 ret = this->m_Image2dQueue.front();
150 this->m_Image2dQueue.pop_front();
152 this->m_Mutex->Unlock();
159 this->m_Mutex->Lock();
160 if (this->m_Image3dQueue.size() > 0)
162 ret = this->m_Image3dQueue.front();
163 this->m_Image3dQueue.pop_front();
165 this->m_Mutex->Unlock();
172 this->m_Mutex->Lock();
173 if (this->m_TrackingDataQueue.size() > 0)
175 ret = this->m_TrackingDataQueue.front();
176 this->m_TrackingDataQueue.pop_front();
178 this->m_Mutex->Unlock();
185 this->m_Mutex->Lock();
186 if (this->m_CommandQueue.size() > 0)
188 ret = this->m_CommandQueue.front();
189 this->m_CommandQueue.pop_front();
191 this->m_Mutex->Unlock();
198 this->m_Mutex->Lock();
199 if (this->m_StringQueue.size() > 0)
201 ret = this->m_StringQueue.front();
202 this->m_StringQueue.pop_front();
204 this->m_Mutex->Unlock();
211 this->m_Mutex->Lock();
212 if (this->m_TransformQueue.size() > 0)
214 ret = this->m_TransformQueue.front();
215 this->m_TransformQueue.pop_front();
217 this->m_Mutex->Unlock();
223 this->m_Mutex->Lock();
225 if (this->m_Latest_Message !=
nullptr)
227 s <<
"Device Type: " << this->m_Latest_Message->GetDeviceType() << std::endl;
228 s <<
"Device Name: " << this->m_Latest_Message->GetDeviceName() << std::endl;
234 this->m_Mutex->Unlock();
240 this->m_Mutex->Lock();
242 if (m_Latest_Message !=
nullptr)
244 s << this->m_Latest_Message->GetDeviceType();
250 this->m_Mutex->Unlock();
256 this->m_Mutex->Lock();
258 if (m_Latest_Message !=
nullptr)
260 s <<
"Device Type: " << this->m_Latest_Message->GetDeviceType() << std::endl;
261 s <<
"Device Name: " << this->m_Latest_Message->GetDeviceName() << std::endl;
267 this->m_Mutex->Unlock();
273 this->m_Mutex->Lock();
275 if (m_Latest_Message !=
nullptr)
277 s << this->m_Latest_Message->GetDeviceType();
283 this->m_Mutex->Unlock();
289 return (this->m_CommandQueue.size() + this->m_Image2dQueue.size() + this->m_Image3dQueue.size() + this->m_MiscQueue.size()
290 + this->m_StringQueue.size() + this->m_TrackingDataQueue.size() + this->m_TransformQueue.size());
295 this->m_Mutex->Lock();
297 this->m_BufferingType = IGTLMessageQueue::BufferingType::Infinit;
299 this->m_BufferingType = IGTLMessageQueue::BufferingType::NoBuffering;
300 this->m_Mutex->Unlock();
311 this->m_Mutex->Unlock();
itk::SmartPointer< Self > Pointer
itk::FastMutexLock::Pointer m_Mutex
Mutex to take car of the queue.
igtl::ImageMessage::Pointer PullImage2dMessage()
BufferingType m_BufferingType
defines the kind of buffering
void PushSendMessage(igtl::MessageBase::Pointer message)
void PushCommandMessage(igtl::MessageBase::Pointer message)
Adds the message to the queue.
void PushMessage(igtl::MessageBase::Pointer message)
Adds the message to the queue.
void EnableInfiniteBuffering(bool enable)
Sets infinite buffering on/off. Initiale value is enabled.
virtual ~IGTLMessageQueue()
igtl::StringMessage::Pointer PullStringMessage()
std::string GetNextMsgInformationString()
Returns a string with information about the oldest message in the queue.
igtl::TransformMessage::Pointer PullTransformMessage()
igtl::MessageBase::Pointer PullCommandMessage()
std::deque< igtl::MessageBase::Pointer > m_SendQueue
std::string GetLatestMsgInformationString()
Returns a string with information about the oldest message in the queue.
std::string GetLatestMsgDeviceType()
Returns the device type of the oldest message in the queue.
igtl::TrackingDataMessage::Pointer PullTrackingMessage()
igtl::ImageMessage::Pointer PullImage3dMessage()
std::string GetNextMsgDeviceType()
Returns the device type of the oldest message in the queue.
int GetSize()
Get the number of messages in the queue.
igtl::MessageBase::Pointer PullSendMessage()
igtl::MessageBase::Pointer PullMiscMessage()
Returns and removes the oldest message from the queue.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.