PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
igtlPlusClientInfoMessage.cxx
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2 Program: Plus
3 Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4 See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 // Local includes
8 #include "PlusConfigure.h"
11 
12 // IGTL includes
13 #include <igtl_header.h>
14 #include <igtl_util.h>
15 
16 namespace igtl
17 {
18  //----------------------------------------------------------------------------
20  {
21  this->m_SendMessageType = "CLIENTINFO";
22  }
23 
24  //----------------------------------------------------------------------------
26  {
27  }
28 
29  //----------------------------------------------------------------------------
30  igtl::MessageBase::Pointer PlusClientInfoMessage::Clone()
31  {
32  igtl::MessageBase::Pointer clone;
33  {
34  vtkSmartPointer<vtkPlusIgtlMessageFactory> factory = vtkSmartPointer<vtkPlusIgtlMessageFactory>::New();
35  clone = dynamic_cast<igtl::MessageBase*>(factory->CreateSendMessage(this->GetMessageType(), this->GetHeaderVersion()).GetPointer());
36  }
37 
38  igtl::PlusClientInfoMessage::Pointer msg = dynamic_cast<igtl::PlusClientInfoMessage*>(clone.GetPointer());
39 
40  int bodySize = this->m_MessageSize - IGTL_HEADER_SIZE;
41  msg->InitBuffer();
42  msg->CopyHeader(this);
43  msg->AllocateBuffer(bodySize);
44  if (bodySize > 0)
45  {
46  msg->CopyBody(this);
47  }
48 
49 #if OpenIGTLink_HEADER_VERSION >= 2
50  msg->m_MetaDataHeader = this->m_MetaDataHeader;
51  msg->m_MetaDataMap = this->m_MetaDataMap;
52  msg->m_IsExtendedHeaderUnpacked = this->m_IsExtendedHeaderUnpacked;
53 #endif
54 
55  return clone;
56  }
57 
58  //----------------------------------------------------------------------------
60  {
61  this->m_ClientInfo = clientInfo;
62  std::string clientInfoXmlData;
63  this->m_ClientInfo.GetClientInfoInXmlData(clientInfoXmlData);
64  this->SetString(clientInfoXmlData);
65  }
66 
67  //----------------------------------------------------------------------------
69  {
70  if (this->m_ClientInfo.SetClientInfoFromXmlData(this->GetString()) != PLUS_SUCCESS)
71  {
72  LOG_ERROR("Failed to set Plus client info from received message!");
73  }
74  return this->m_ClientInfo;
75  }
76 }
PlusStatus SetClientInfoFromXmlData(const char *strXmlData)
void SetClientInfo(const PlusIgtlClientInfo &clientInfo)
#define PLUS_SUCCESS
Definition: PlusCommon.h:44
virtual igtl::MessageBase::Pointer Clone()
This class provides client information for vtkPlusOpenIGTLinkServer.
void GetClientInfoInXmlData(std::string &strXmlData)