Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::IGTLClient Class Reference

Superclass for OpenIGTLink clients. More...

#include <mitkIGTLClient.h>

Inheritance diagram for mitk::IGTLClient:
Collaboration diagram for mitk::IGTLClient:

Public Member Functions

 mitkClassMacro (IGTLClient, IGTLDevice) mitkNewMacro1Param(Self
 
bool Pointer Clone () const
 
virtual bool OpenConnection () override
 Establishes the connection between this client and the IGTL server. More...
 
virtual unsigned int GetNumberOfConnections () override
 Returns the number of connections of this device. More...
 
- Public Member Functions inherited from mitk::IGTLDevice
 mitkClassMacroItkParent (IGTLDevice, itk::Object) IGTLDevice(bool ReadFully)
 
virtual bool CloseConnection ()
 Closes the connection to the device. More...
 
virtual bool StopCommunication ()
 Stops the communication between the two devices. More...
 
bool StartCommunication ()
 Starts the communication between the two devices. More...
 
void RunCommunication (void(IGTLDevice::*ComFunction)(void), itk::FastMutexLock *mutex)
 Continuously calls the given function. More...
 
void SendMessage (igtl::MessageBase::Pointer msg)
 Adds the given message to the sending queue. More...
 
void SendMessage (const IGTLMessage *msg)
 Adds the given message to the sending queue. More...
 
IGTLDeviceState GetState () const
 Returns current object state (Setup, Ready or Running) More...
 
igtl::MessageBase::Pointer GetNextCommand ()
 Returns the oldest message in the command queue. More...
 
igtl::ImageMessage::Pointer GetNextImage2dMessage ()
 Returns the oldest message in the receive queue. More...
 
igtl::ImageMessage::Pointer GetNextImage3dMessage ()
 
igtl::TransformMessage::Pointer GetNextTransformMessage ()
 
igtl::TrackingDataMessage::Pointer GetNextTrackingDataMessage ()
 
igtl::StringMessage::Pointer GetNextStringMessage ()
 
igtl::MessageBase::Pointer GetNextMiscMessage ()
 
virtual void SetPortNumber (int _arg)
 Sets the port number of the device. More...
 
virtual int GetPortNumber ()
 Returns the port number of the device. More...
 
virtual void SetHostname (std::string _arg)
 Sets the ip/hostname of the device. More...
 
virtual std::string GetHostname ()
 Returns the ip/hostname of the device. More...
 
virtual std::string GetName () const
 Returns the name of this device. More...
 
virtual void SetName (std::string _arg)
 Sets the name of this device. More...
 
virtual void SetReadFully (bool _arg)
 Advises this IGTL Device to always block until the whole message is read. More...
 
virtual mitk::IGTLMessageQueue::Pointer GetMessageQueue () const
 Returns a const reference to the receive queue. More...
 
virtual mitk::IGTLMessageFactory::Pointer GetMessageFactory ()
 Returns the message factory. More...
 
virtual bool TestConnection ()
 TestConnection() tries to connect to a IGTL device on the current ip and port. More...
 
bool SendRTSMessage (const char *type)
 Send RTS message of given type. More...
 
void EnableInfiniteBufferingMode (mitk::IGTLMessageQueue::Pointer queue, bool enable=true)
 Sets the buffering mode of the given queue. More...
 

Protected Member Functions

 IGTLClient (bool ReadFully)
 
virtual ~IGTLClient ()
 
virtual void Receive () override
 Call this method to receive a message. More...
 
virtual void Send () override
 Call this method to send a message. More...
 
virtual void StopCommunicationWithSocket (igtl::Socket *) override
 Stops the communication with the given socket. More...
 
- Protected Member Functions inherited from mitk::IGTLDevice
unsigned int SendMessagePrivate (igtl::MessageBase::Pointer msg, igtl::Socket::Pointer socket)
 Sends a message. More...
 
unsigned int ReceivePrivate (igtl::Socket *device)
 Call this method to receive a message from the given device. More...
 
virtual void Connect ()
 Call this method to check for other devices that want to connect to this one. More...
 
void SetState (IGTLDeviceState state)
 change object state More...
 
 IGTLDevice ()
 
virtual ~IGTLDevice ()
 

Additional Inherited Members

- Public Types inherited from mitk::IGTLDevice
enum  IGTLDeviceState { Setup, Ready, Running }
 Type for state variable. The IGTLDevice is always in one of these states. More...
 
- Static Public Member Functions inherited from mitk::IGTLDevice
static ITK_THREAD_RETURN_TYPE ThreadStartSending (void *data)
 static start method for the sending thread. More...
 
static ITK_THREAD_RETURN_TYPE ThreadStartReceiving (void *data)
 static start method for the receiving thread. More...
 
static ITK_THREAD_RETURN_TYPE ThreadStartConnecting (void *data)
 static start method for the connection thread. More...
 
- Protected Attributes inherited from mitk::IGTLDevice
IGTLDeviceState m_State
 
std::string m_Name
 
bool m_StopCommunication
 
itk::FastMutexLock::Pointer m_StopCommunicationMutex
 
itk::FastMutexLock::Pointer m_SendingFinishedMutex
 
itk::FastMutexLock::Pointer m_ReceivingFinishedMutex
 
itk::FastMutexLock::Pointer m_ConnectingFinishedMutex
 
itk::FastMutexLock::Pointer m_StateMutex
 
std::string m_Hostname
 
int m_PortNumber
 
igtl::Socket::Pointer m_Socket
 
mitk::IGTLMessageQueue::Pointer m_MessageQueue
 
mitk::IGTLMessageFactory::Pointer m_MessageFactory
 

Detailed Description

Superclass for OpenIGTLink clients.

Implements the IGTLDevice interface for IGTLClients. In certain points it behaves different than the IGTLServer. The client connects directly to a server (it cannot connect to two different servers). Therefore, it has to check only this one connection.

Definition at line 39 of file mitkIGTLClient.h.

Constructor & Destructor Documentation

mitk::IGTLClient::IGTLClient ( bool  ReadFully)
protected

Constructor

Definition at line 31 of file mitkIGTLClient.cpp.

mitk::IGTLClient::~IGTLClient ( )
protectedvirtual

Destructor

Definition at line 36 of file mitkIGTLClient.cpp.

Member Function Documentation

bool Pointer mitk::IGTLClient::Clone ( ) const
unsigned int mitk::IGTLClient::GetNumberOfConnections ( )
overridevirtual

Returns the number of connections of this device.

A client can connect to one sever only, therefore, the number is either 0 or 1

Implements mitk::IGTLDevice.

Definition at line 121 of file mitkIGTLClient.cpp.

mitk::IGTLClient::mitkClassMacro ( IGTLClient  ,
IGTLDevice   
)
bool mitk::IGTLClient::OpenConnection ( )
overridevirtual

Establishes the connection between this client and the IGTL server.

Exceptions
mitk::ExceptionThrows an exception if the client is not in Setup mode or if it cannot connect to the defined host.

Implements mitk::IGTLDevice.

Definition at line 40 of file mitkIGTLClient.cpp.

References MITK_ERROR, MITK_WARN, mitkThrowException, mitk::New(), and Setup().

void mitk::IGTLClient::Receive ( )
overrideprotectedvirtual

Call this method to receive a message.

The message will be saved in the receive queue. If the connection is lost it will stop the communication.

Implements mitk::IGTLDevice.

Definition at line 82 of file mitkIGTLClient.cpp.

References MITK_INFO, and MITK_WARN.

void mitk::IGTLClient::Send ( )
overrideprotectedvirtual

Call this method to send a message.

The message will be read from the queue.

Implements mitk::IGTLDevice.

Definition at line 97 of file mitkIGTLClient.cpp.

References MITK_WARN.

void mitk::IGTLClient::StopCommunicationWithSocket ( igtl::Socket *  )
overrideprotectedvirtual

Stops the communication with the given socket.

The client uses just one socket. Therefore, calling this function causes the stop of the communication.

Implements mitk::IGTLDevice.

Definition at line 114 of file mitkIGTLClient.cpp.


The documentation for this class was generated from the following files: