PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusVersionCommand.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 #include "PlusConfigure.h"
10 #include "vtkPlusVersionCommand.h"
11 
13 
14 namespace
15 {
16  static const std::string VERSION_CMD = "Version";
17 }
18 
19 //----------------------------------------------------------------------------
21 {
22  // It handles only one command, set its name by default
23  this->SetName(VERSION_CMD);
24 }
25 
26 //----------------------------------------------------------------------------
28 {
29 
30 }
31 
32 //----------------------------------------------------------------------------
34 {
35  this->SetName(VERSION_CMD);
36 }
37 
38 //----------------------------------------------------------------------------
39 void vtkPlusVersionCommand::GetCommandNames(std::list<std::string>& cmdNames)
40 {
41  cmdNames.clear();
42  cmdNames.push_back(VERSION_CMD);
43 }
44 
45 //----------------------------------------------------------------------------
46 std::string vtkPlusVersionCommand::GetDescription(const std::string& commandName)
47 {
48  std::string desc;
49  if (commandName.empty() || igsioCommon::IsEqualInsensitive(commandName, VERSION_CMD))
50  {
51  desc += VERSION_CMD;
52  desc += ": Send and receive version to/from the device.";
53  }
54  return desc;
55 }
56 
57 //----------------------------------------------------------------------------
59 {
60  igtl::MessageBase::MetaDataMap metadata;
61  metadata["PlusVersion"] = std::pair<IANA_ENCODING_TYPE, std::string>(IANA_TYPE_US_ASCII, PlusCommon::GetPlusLibVersionString());
62 #if defined(_MSC_VER) && _MSC_VER < 1700
63  metadata["IGTLProtocolVersion"] = std::pair<IANA_ENCODING_TYPE, std::string>(IANA_TYPE_US_ASCII, igsioCommon::ToString<int>(this->CommandProcessor->GetPlusServer()->GetIGTLProtocolVersion()));
64  metadata["IGTLHeaderVersion"] = std::pair<IANA_ENCODING_TYPE, std::string>(IANA_TYPE_US_ASCII, igsioCommon::ToString<int>(this->CommandProcessor->GetPlusServer()->GetIGTLHeaderVersion()));
65 #else
66  metadata["IGTLProtocolVersion"] = std::pair<IANA_ENCODING_TYPE, std::string>(IANA_TYPE_US_ASCII, std::to_string(this->CommandProcessor->GetPlusServer()->GetIGTLProtocolVersion()));
67  metadata["IGTLHeaderVersion"] = std::pair<IANA_ENCODING_TYPE, std::string>(IANA_TYPE_US_ASCII, std::to_string(this->CommandProcessor->GetPlusServer()->GetIGTLHeaderVersion()));
68 #endif
69  this->QueueCommandResponse(PLUS_SUCCESS, "Success.", "", &metadata);
70  return PLUS_SUCCESS;
71 }
virtual PlusStatus Execute()
virtual int GetIGTLProtocolVersion()
igsioStatus PlusStatus
Definition: PlusCommon.h:40
virtual std::string GetDescription(const std::string &commandName)
std::string to_string(ClariusAvailability avail)
virtual vtkPlusOpenIGTLinkServer * GetPlusServer()
vtkStandardNewMacro(vtkPlusVersionCommand)
vtkPlusCommandProcessor * CommandProcessor
#define PLUS_SUCCESS
Definition: PlusCommon.h:44
virtual int GetIGTLHeaderVersion()
void QueueCommandResponse(PlusStatus status, const std::string &message, const std::string &error="", const igtl::MessageBase::MetaDataMap *metaData=nullptr)
virtual void GetCommandNames(std::list< std::string > &cmdNames)
This command sends and receives version information to/from a client.
vtkPlusCommonExport std::string GetPlusLibVersionString()
Definition: PlusCommon.cxx:30