Medical Imaging Interaction Toolkit  2016.11.0
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) static Pointer New()
 
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 NULL 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 NULL 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...
 

Protected Member Functions

 IGTLMessageFactory ()
 
virtual ~IGTLMessageFactory ()
 

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 37 of file mitkIGTLMessageFactory.h.

Member Typedef Documentation

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

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

Definition at line 48 of file mitkIGTLMessageFactory.h.

Constructor & Destructor Documentation

mitk::IGTLMessageFactory::IGTLMessageFactory ( )
protected

Definition at line 98 of file mitkIGTLMessageFactory.cpp.

References AddMessageNewMethod(), and mitk::New().

mitk::IGTLMessageFactory::~IGTLMessageFactory ( )
protectedvirtual

Definition at line 164 of file mitkIGTLMessageFactory.cpp.

Member Function Documentation

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 182 of file mitkIGTLMessageFactory.cpp.

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 176 of file mitkIGTLMessageFactory.cpp.

Referenced by IGTLMessageFactory().

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 168 of file mitkIGTLMessageFactory.cpp.

Pointer mitk::IGTLMessageFactory::Clone ( ) const
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 206 of file mitkIGTLMessageFactory.cpp.

References mitk::Clone().

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 NULL Usage: igtl::MessageBase::Pointer message = CreateInstance("IMAGE");

Definition at line 225 of file mitkIGTLMessageFactory.cpp.

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 260 of file mitkIGTLMessageFactory.cpp.

References MITK_ERROR.

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

Returns available get messages.

Definition at line 240 of file mitkIGTLMessageFactory.cpp.

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

Get pointer to message type clone function, or NULL 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 189 of file mitkIGTLMessageFactory.cpp.

References MITK_ERROR, and mitkThrow.

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

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

Definition at line 212 of file mitkIGTLMessageFactory.cpp.

References MITK_ERROR.

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

Member Data Documentation

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

Map igt message types and the Clone() methods.

Definition at line 139 of file mitkIGTLMessageFactory.h.

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 145 of file mitkIGTLMessageFactory.h.


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