Medical Imaging Interaction Toolkit  2018.4.99-9a29ffc6
Medical Imaging Interaction Toolkit
mitk::IGTLMessageFactory Class Reference

Factory class of supported OpenIGTLink message types. More...

#include <mitkIGTLMessageFactory.h>

Inheritance diagram for mitk::IGTLMessageFactory:
Collaboration diagram for mitk::IGTLMessageFactory:

Public Types

typedef igtl::MessageBase::Pointer(* PointerToMessageBaseNew) ()
 Function pointer for storing New() static methods of igtl::MessageBase classes. More...
 

Public Member Functions

 mitkClassMacroItkParent (IGTLMessageFactory, itk::Object)
 
Pointer Clone () const
 
void AddMessageType (std::string messageTypeName, IGTLMessageFactory::PointerToMessageBaseNew messageTypeNewPointer, mitk::IGTLMessageCloneHandler::Pointer cloneHandler)
 Add message type name and pointer to IGTL message new function and the clone handler. More...
 
virtual void AddMessageNewMethod (std::string messageTypeName, IGTLMessageFactory::PointerToMessageBaseNew messageTypeNewPointer)
 Add message type name and pointer to IGTL message new function Usage: AddMessageType("IMAGE", (PointerToMessageBaseNew)&igtl::ImageMessage::New);. More...
 
virtual IGTLMessageFactory::PointerToMessageBaseNew GetMessageTypeNewPointer (std::string messageTypeName)
 Get pointer to message type new function, or nullptr if the message type not registered Usage: igtl::MessageBase::Pointer message = GetMessageTypeNewPointer("IMAGE")();. More...
 
igtl::MessageBase::Pointer CreateInstance (std::string messageTypeName)
 Creates a new message instance fitting to the given type. More...
 
igtl::MessageBase::Pointer CreateInstance (igtl::MessageHeader::Pointer msg)
 Creates a new message according to the given header. More...
 
virtual void AddMessageCloneHandler (std::string msgTypeName, mitk::IGTLMessageCloneHandler::Pointer msgCloneHandler)
 Adds a clone function for the specified message type. More...
 
virtual mitk::IGTLMessageCloneHandler::Pointer GetCloneHandler (std::string messageTypeName)
 Get pointer to message type clone function, or nullptr if the message type is not registered Usage: igtl::TransformMessage::Pointer original = igtl::TransformMessage::New(); igtl::MessageBase::Pointer message = GetCloneHandler("IMAGE")->Clone(original);. More...
 
igtl::MessageBase::Pointer Clone (igtl::MessageBase::Pointer msg)
 Clones the given message according to the available clone methods. More...
 
std::list< std::string > GetAvailableMessageRequestTypes ()
 Returns available get messages. More...
 

Static Public Member Functions

static Pointer New ()
 

Protected Member Functions

 IGTLMessageFactory ()
 
 ~IGTLMessageFactory () override
 

Protected Attributes

std::map< std::string, mitk::IGTLMessageCloneHandler::Pointer > m_CloneHandlers
 Map igt message types and the Clone() methods. More...
 
std::map< std::string, PointerToMessageBaseNewm_NewMethods
 Map igt message types and the New() static methods of igtl::MessageBase classes. More...
 

Detailed Description

Factory class of supported OpenIGTLink message types.

This class is a factory for the creation of OpenIGTLink messages. It stores pairs of type and pointer to the message new method. Available standard types are already added but you can also add your custom types at runtime.

Definition at line 33 of file mitkIGTLMessageFactory.h.

Member Typedef Documentation

◆ PointerToMessageBaseNew

typedef igtl::MessageBase::Pointer(* mitk::IGTLMessageFactory::PointerToMessageBaseNew) ()

Function pointer for storing New() static methods of igtl::MessageBase classes.

Definition at line 44 of file mitkIGTLMessageFactory.h.

Constructor & Destructor Documentation

◆ IGTLMessageFactory()

mitk::IGTLMessageFactory::IGTLMessageFactory ( )
protected

Definition at line 94 of file mitkIGTLMessageFactory.cpp.

References AddMessageNewMethod().

◆ ~IGTLMessageFactory()

mitk::IGTLMessageFactory::~IGTLMessageFactory ( )
overrideprotected

Definition at line 159 of file mitkIGTLMessageFactory.cpp.

Member Function Documentation

◆ AddMessageCloneHandler()

void mitk::IGTLMessageFactory::AddMessageCloneHandler ( std::string  msgTypeName,
mitk::IGTLMessageCloneHandler::Pointer  msgCloneHandler 
)
virtual

Adds a clone function for the specified message type.

Parameters
msgTypeNameThe name of the message type
msgCloneHandlerFunction pointer to the message clone function (e.g. TBD )

Definition at line 177 of file mitkIGTLMessageFactory.cpp.

References m_CloneHandlers.

Referenced by AddMessageType().

◆ AddMessageNewMethod()

void mitk::IGTLMessageFactory::AddMessageNewMethod ( std::string  messageTypeName,
IGTLMessageFactory::PointerToMessageBaseNew  messageTypeNewPointer 
)
virtual

Add message type name and pointer to IGTL message new function Usage: AddMessageType("IMAGE", (PointerToMessageBaseNew)&igtl::ImageMessage::New);.

Parameters
messageTypeNameThe name of the message type
messageTypeNewPointerFunction pointer to the message type new function (e.g. (PointerToMessageBaseNew)&igtl::ImageMessage::New )

Definition at line 171 of file mitkIGTLMessageFactory.cpp.

References m_NewMethods.

Referenced by AddMessageType(), and IGTLMessageFactory().

◆ AddMessageType()

void mitk::IGTLMessageFactory::AddMessageType ( std::string  messageTypeName,
IGTLMessageFactory::PointerToMessageBaseNew  messageTypeNewPointer,
mitk::IGTLMessageCloneHandler::Pointer  cloneHandler 
)

Add message type name and pointer to IGTL message new function and the clone handler.

Parameters
messageTypeNameThe name of the message type
messageTypeNewPointerFunction pointer to the message type new function (e.g. (PointerToMessageBaseNew)&igtl::ImageMessage::New )
cloneHandlerpointer to the message clone object

Definition at line 163 of file mitkIGTLMessageFactory.cpp.

References AddMessageCloneHandler(), and AddMessageNewMethod().

◆ Clone() [1/2]

Pointer mitk::IGTLMessageFactory::Clone ( ) const

Referenced by Clone().

◆ Clone() [2/2]

igtl::MessageBase::Pointer mitk::IGTLMessageFactory::Clone ( igtl::MessageBase::Pointer  msg)

Clones the given message according to the available clone methods.

Parameters
msgThe message that has to be cloned This method checks the data type and clones the message according to this type.

Definition at line 201 of file mitkIGTLMessageFactory.cpp.

References Clone(), and GetCloneHandler().

◆ CreateInstance() [1/2]

igtl::MessageBase::Pointer mitk::IGTLMessageFactory::CreateInstance ( std::string  messageTypeName)

Creates a new message instance fitting to the given type.

If this type is not registered it returns nullptr Usage: igtl::MessageBase::Pointer message = CreateInstance("IMAGE");

Definition at line 220 of file mitkIGTLMessageFactory.cpp.

References GetMessageTypeNewPointer().

◆ CreateInstance() [2/2]

igtl::MessageBase::Pointer mitk::IGTLMessageFactory::CreateInstance ( igtl::MessageHeader::Pointer  msg)

Creates a new message according to the given header.

Parameters
msgThe message header that defines the type of the message This method checks the data type and creates a new message according to the type.

Definition at line 255 of file mitkIGTLMessageFactory.cpp.

References m_NewMethods, and MITK_ERROR.

◆ GetAvailableMessageRequestTypes()

std::list< std::string > mitk::IGTLMessageFactory::GetAvailableMessageRequestTypes ( )

Returns available get messages.

Definition at line 235 of file mitkIGTLMessageFactory.cpp.

References m_NewMethods.

◆ GetCloneHandler()

mitk::IGTLMessageCloneHandler::Pointer mitk::IGTLMessageFactory::GetCloneHandler ( std::string  messageTypeName)
virtual

Get pointer to message type clone function, or nullptr if the message type is not registered Usage: igtl::TransformMessage::Pointer original = igtl::TransformMessage::New(); igtl::MessageBase::Pointer message = GetCloneHandler("IMAGE")->Clone(original);.

Definition at line 184 of file mitkIGTLMessageFactory.cpp.

References m_CloneHandlers, MITK_ERROR, and mitkThrow.

Referenced by Clone().

◆ GetMessageTypeNewPointer()

mitk::IGTLMessageFactory::PointerToMessageBaseNew mitk::IGTLMessageFactory::GetMessageTypeNewPointer ( std::string  messageTypeName)
virtual

Get pointer to message type new function, or nullptr if the message type not registered Usage: igtl::MessageBase::Pointer message = GetMessageTypeNewPointer("IMAGE")();.

Definition at line 207 of file mitkIGTLMessageFactory.cpp.

References m_NewMethods, and MITK_ERROR.

Referenced by CreateInstance().

◆ mitkClassMacroItkParent()

mitk::IGTLMessageFactory::mitkClassMacroItkParent ( IGTLMessageFactory  ,
itk::Object   
)

◆ New()

static Pointer mitk::IGTLMessageFactory::New ( )
static

Member Data Documentation

◆ m_CloneHandlers

std::map<std::string,mitk::IGTLMessageCloneHandler::Pointer> mitk::IGTLMessageFactory::m_CloneHandlers
protected

Map igt message types and the Clone() methods.

Definition at line 135 of file mitkIGTLMessageFactory.h.

Referenced by AddMessageCloneHandler(), and GetCloneHandler().

◆ m_NewMethods

std::map<std::string, PointerToMessageBaseNew> mitk::IGTLMessageFactory::m_NewMethods
protected

Map igt message types and the New() static methods of igtl::MessageBase classes.

Definition at line 141 of file mitkIGTLMessageFactory.h.

Referenced by AddMessageNewMethod(), CreateInstance(), GetAvailableMessageRequestTypes(), and GetMessageTypeNewPointer().


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