Odil
A C++11 library for the DICOM standard
Message.h
Go to the documentation of this file.
1 /*************************************************************************
2  * odil - Copyright (C) Universite de Strasbourg
3  * Distributed under the terms of the CeCILL-B license, as published by
4  * the CEA-CNRS-INRIA. Refer to the LICENSE file or to
5  * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
6  * for details.
7  ************************************************************************/
8 
9 #ifndef _dcfa5213_ad7e_4194_8b4b_e630aa0df2e8
10 #define _dcfa5213_ad7e_4194_8b4b_e630aa0df2e8
11 
12 #include "odil/DataSet.h"
13 #include "odil/odil.h"
14 #include "odil/registry.h"
15 #include "odil/Value.h"
16 
17 namespace odil
18 {
19 
20 namespace message
21 {
22 
23 #define ODIL_MESSAGE_MANDATORY_FIELD_MACRO(name, tag, TValueType, function) \
24  \
25  TValueType const & get_##name() const \
26  { \
27  auto const & data = this->_command_set.function(tag); \
28  if(data.empty()) \
29  { \
30  throw Exception("Empty element"); \
31  } \
32  return data[0]; \
33  } \
34  \
35  void set_##name(TValueType const & value) \
36  { \
37  if(!this->_command_set.has(tag)) \
38  { \
39  this->_command_set.add(tag); \
40  } \
41  this->_command_set.function(tag) = { value }; \
42  }
43 
44 #define ODIL_MESSAGE_OPTIONAL_FIELD_MACRO(name, tag, TValueType, function) \
45  ODIL_MESSAGE_MANDATORY_FIELD_MACRO(name, tag, TValueType, function) \
46  bool has_##name() const \
47  { \
48  return this->_command_set.has(tag);; \
49  } \
50  void delete_##name() \
51  { \
52  this->_command_set.remove(tag); \
53  }
54 
55 #define ODIL_MESSAGE_SET_OPTIONAL_FIELD_MACRO(dataset, name, tag, function) \
56  if(dataset.has(tag)) \
57  { \
58  this->set_##name(dataset.function(tag, 0)); \
59  }
60 
61 #define ODIL_MESSAGE_MANDATORY_FIELD_INTEGER_MACRO(name, tag) \
62  ODIL_MESSAGE_MANDATORY_FIELD_MACRO(name, tag, Value::Integer, as_int)
63 
64 #define ODIL_MESSAGE_MANDATORY_FIELD_STRING_MACRO(name, tag) \
65  ODIL_MESSAGE_MANDATORY_FIELD_MACRO(name, tag, Value::String, as_string)
66 
67 #define ODIL_MESSAGE_OPTIONAL_FIELD_INTEGER_MACRO(name, tag) \
68  ODIL_MESSAGE_OPTIONAL_FIELD_MACRO(name, tag, Value::Integer, as_int)
69 
70 #define ODIL_MESSAGE_OPTIONAL_FIELD_STRING_MACRO(name, tag) \
71  ODIL_MESSAGE_OPTIONAL_FIELD_MACRO(name, tag, Value::String, as_string)
72 
77 {
78 public:
79  struct Command
80  {
81  enum Type
82  {
83  C_STORE_RQ = 0x0001,
84  C_STORE_RSP = 0x8001,
85 
86  C_FIND_RQ = 0x0020,
87  C_FIND_RSP = 0x8020,
88 
89  C_CANCEL_RQ = 0x0FFF,
90 
91  C_GET_RQ = 0x0010,
92  C_GET_RSP = 0x8010,
93 
94  C_MOVE_RQ = 0x0021,
95  C_MOVE_RSP = 0x8021,
96 
97  C_ECHO_RQ = 0x0030,
98  C_ECHO_RSP = 0x8030,
99 
100  N_EVENT_REPORT_RQ = 0x0100,
101  N_EVENT_REPORT_RSP = 0x8100,
102 
103  N_GET_RQ = 0x0110,
104  N_GET_RSP = 0x8110,
105 
106  N_SET_RQ = 0x0120,
107  N_SET_RSP = 0x8120,
108 
109  N_ACTION_RQ = 0x0130,
110  N_ACTION_RSP = 0x8130,
111 
112  N_CREATE_RQ = 0x0140,
113  N_CREATE_RSP = 0x8140,
114 
115  N_DELETE_RQ = 0x0150,
116  N_DELETE_RSP = 0x8150,
117  };
118  };
119 
120  struct Priority
121  {
122  enum Type
123  {
124  LOW = 0x0002,
125  MEDIUM = 0x0000,
126  HIGH = 0x0001,
127  };
128  };
129 
130  struct DataSetType
131  {
132  enum Type
133  {
134  PRESENT = 0x0000,
135  ABSENT = 0x0101,
136  };
137  };
138 
140  Message();
141 
143  Message(DataSet const & command_set);
144 
146  Message(DataSet && command_set);
147 
149  Message(DataSet const & command_set, DataSet const & data_set);
150 
152  Message(DataSet && command_set, DataSet && data_set);
153 
155  virtual ~Message();
156 
158  DataSet const & get_command_set() const;
159 
161  bool has_data_set() const;
162 
167  DataSet const & get_data_set() const;
168 
173  DataSet & get_data_set();
174 
176  void set_data_set(DataSet const & data_set);
177 
179  void set_data_set(DataSet && data_set);
180 
182  void delete_data_set();
183 
185  command_field, registry::CommandField)
186 
187 protected:
190 
193 };
194 
195 }
196 
197 }
198 
199 #endif // _dcfa5213_ad7e_4194_8b4b_e630aa0df2e8
Type
Definition: Message.h:132
DICOM Data set.
Definition: DataSet.h:29
#define ODIL_MESSAGE_MANDATORY_FIELD_INTEGER_MACRO(name, tag)
Definition: Message.h:61
Base class for all DIMSE messages.
Definition: Message.h:76
DataSet _command_set
Command set of the message.
Definition: Message.h:189
Tag const CommandField(0x0000, 0x0100)
Definition: Association.h:24
Definition: Message.h:130
Type
Definition: Message.h:122
#define ODIL_API
Definition: odil.h:28
Type
Definition: Message.h:81
Definition: Message.h:79
DataSet _data_set
Data set of the message.
Definition: Message.h:192
Definition: Message.h:120