File: igtlCommandMessage.h

package info (click to toggle)
openigtlink 3.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,080 kB
  • sloc: cpp: 20,076; ansic: 6,704; sh: 227; perl: 74; makefile: 46
file content (131 lines) | stat: -rw-r--r-- 3,686 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*=========================================================================

  Program:   The OpenIGTLink Library
  Language:  C++
  Web page:  http://openigtlink.org/

  Copyright (c) Insight Software Consortium. All rights reserved.

  This software is distributed WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#ifndef __igtlCommandMessage_h
#define __igtlCommandMessage_h

#include "igtlObject.h"
#include "igtlMacro.h"
#include "igtlMath.h"
#include "igtlMessageBase.h"
#include "igtl_command.h"

namespace igtl
{

class IGTLCommon_EXPORT CommandMessage : public MessageBase
{
public:
  static const int validEncodings[257];

public:
  typedef CommandMessage            Self;
  typedef MessageBase               Superclass;
  typedef SmartPointer<Self>        Pointer;
  typedef SmartPointer<const Self>  ConstPointer;

  igtlTypeMacro(igtl::CommandMessage, igtl::MessageBase)
  igtlNewMacro(igtl::CommandMessage);

public:

  /// Sets the command ID
  int        SetCommandId(igtlUint32 aId);

  /// Sets the command name
  int        SetCommandName(const char* aCommandName);

  /// Sets the command name by std::string
  int        SetCommandName(const std::string& aCommandName);

  /// Sets the string by character array.
  int        SetCommandContent(const char* string);

  /// Sets the string by std::string.
  int        SetCommandContent(const std::string & string);

  /// Sets the encoding of the string. For character encoding, please refer IANA Character Sets
  /// (http://www.iana.org/assignments/character-sets).
  /// US-ASCII (ANSI-X3.4-1968; MIBenum = 3) is strongly recommended.
  int        SetContentEncoding(igtlUint16 enc);

  /// Gets the command ID
  igtlUint32  GetCommandId() const;

  /// Get the command name
  std::string GetCommandName() const;

  /// Gets the string.
  std::string GetCommandContent() const;

  /// Gets the length of the command content
  igtlUint32 GetCommandContentLength() const;

  /// Gets the encoding of the string. The returned value is defined in
  /// IANA Character Sets (http://www.iana.org/assignments/character-sets).
  igtlUint16  GetContentEncoding() const;

protected:
  CommandMessage();
  ~CommandMessage();

protected:
  virtual int  CalculateContentBufferSize();
  virtual int  PackContent();
  virtual int  UnpackContent();

  /// The unique ID of the command
  igtlUint32   m_CommandId;

  /// The name of the command
  igtlUint8    m_CommandName[IGTL_COMMAND_NAME_SIZE];

  /// The encoding of the command string.
  /// The value is defined in IANA Character Sets (http://www.iana.org/assignments/character-sets).
  igtlUint16   m_Encoding;

  /// The command stored as an XML encoded string.
  std::string  m_Command;
};

class IGTLCommon_EXPORT RTSCommandMessage : public CommandMessage
{
public:
  typedef RTSCommandMessage            Self;
  typedef CommandMessage               Superclass;
  typedef SmartPointer<Self>           Pointer;
  typedef SmartPointer<const Self>     ConstPointer;

  igtlTypeMacro(igtl::RTSCommandMessage, igtl::CommandMessage)
  igtlNewMacro(igtl::RTSCommandMessage);

public:

  /// Sets the error string
  int        SetCommandErrorString(const char* aCommandName);

  /// Sets the error string by std::string
  int        SetCommandErrorString(const std::string& aCommandName);

  /// Get the error string
  std::string GetCommandErrorString() const;

protected:
  RTSCommandMessage();
  ~RTSCommandMessage();
};

} // namespace igtl

#endif // _igtlCommandMessage_h