1 /*
2  *
3  *  Copyright (C) 2008-2012, OFFIS e.V. and ICSMED AG, Oldenburg, Germany
4  *  Copyright (C) 2013-2017, J. Riesmeier, Oldenburg, Germany
5  *  All rights reserved.  See COPYRIGHT file for details.
6  *
7  *  Header file for class DRTWedgeSequence
8  *
9  *  Generated automatically from DICOM PS 3.3-2017e
10  *  File created on 2017-12-05 09:30:54
11  *
12  */
13 
14 
15 #ifndef DRTWS_H
16 #define DRTWS_H
17 
18 #include "dcmtk/config/osconfig.h"     // make sure OS specific configuration is included first
19 
20 #include "dcmtk/ofstd/oflist.h"        // for standard list class
21 #include "dcmtk/dcmrt/drttypes.h"      // module-specific helper class
22 
23 
24 /** Interface class for WedgeSequence (300a,00d1)
25  */
26 class DCMTK_DCMRT_EXPORT DRTWedgeSequence
27   : protected DRTTypes
28 {
29 
30   public:
31 
32     /** Item class
33      */
34     class DCMTK_DCMRT_EXPORT Item
35       : protected DRTTypes
36     {
37 
38       public:
39 
40       // --- constructors, destructor and operators ---
41 
42         /** (default) constructor
43          *  @param emptyDefaultItem flag used to mark the empty default item
44          */
45         Item(const OFBool emptyDefaultItem = OFFalse);
46 
47         /** copy constructor
48          *  @param copy item object to be copied
49          */
50         Item(const Item &copy);
51 
52         /** destructor
53          */
54         virtual ~Item();
55 
56         /** assigment operator
57          *  @param copy item object to be copied
58          *  @return reference to this object
59          */
60         Item &operator=(const Item &copy);
61 
62       // --- general methods ---
63 
64         /** clear all internal member variables
65          */
66         void clear();
67 
68         /** check if item is empty
69          *  @return OFTrue if item is empty, OFFalse otherwise
70          */
71         OFBool isEmpty();
72 
73         /** check if item is valid, i.e.\ not the empty default item
74          *  @return OFTrue if item is valid, OFFalse otherwise
75          */
76         OFBool isValid() const;
77 
78       // --- input/output methods ---
79 
80         /** read elements from sequence item
81          *  @param  item    reference to DICOM sequence item from which the elements should be read
82          *  @return status, EC_Normal if successful, an error code otherwise
83          */
84         OFCondition read(DcmItem &item);
85 
86         /** write elements to sequence item
87          *  @param  item    reference to DICOM sequence item to which the elements should be written
88          *  @return status, EC_Normal if successful, an error code otherwise
89          */
90         OFCondition write(DcmItem &item);
91 
92       // --- get DICOM attribute values ---
93 
94         /** get AccessoryCode (300a,00f9)
95          *  @param  value  reference to variable in which the value should be stored
96          *  @param  pos    index of the value to get (0..vm-1), -1 for all components
97          *  @return status, EC_Normal if successful, an error code otherwise
98          */
99         OFCondition getAccessoryCode(OFString &value, const signed long pos = 0) const;
100 
101         /** get EffectiveWedgeAngle (300a,00de)
102          *  @param  value  reference to variable in which the value should be stored
103          *  @param  pos    index of the value to get (0..vm-1), -1 for all components
104          *  @return status, EC_Normal if successful, an error code otherwise
105          */
106         OFCondition getEffectiveWedgeAngle(OFString &value, const signed long pos = 0) const;
107 
108         /** get EffectiveWedgeAngle (300a,00de)
109          *  @param  value  reference to variable in which the value should be stored
110          *  @param  pos    index of the value to get (0..vm-1)
111          *  @return status, EC_Normal if successful, an error code otherwise
112          */
113         OFCondition getEffectiveWedgeAngle(Float64 &value, const unsigned long pos = 0) const;
114 
115         /** get SourceToWedgeTrayDistance (300a,00da)
116          *  @param  value  reference to variable in which the value should be stored
117          *  @param  pos    index of the value to get (0..vm-1), -1 for all components
118          *  @return status, EC_Normal if successful, an error code otherwise
119          */
120         OFCondition getSourceToWedgeTrayDistance(OFString &value, const signed long pos = 0) const;
121 
122         /** get SourceToWedgeTrayDistance (300a,00da)
123          *  @param  value  reference to variable in which the value should be stored
124          *  @param  pos    index of the value to get (0..vm-1)
125          *  @return status, EC_Normal if successful, an error code otherwise
126          */
127         OFCondition getSourceToWedgeTrayDistance(Float64 &value, const unsigned long pos = 0) const;
128 
129         /** get WedgeAngle (300a,00d5)
130          *  @param  value  reference to variable in which the value should be stored
131          *  @param  pos    index of the value to get (0..vm-1), -1 for all components
132          *  @return status, EC_Normal if successful, an error code otherwise
133          */
134         OFCondition getWedgeAngle(OFString &value, const signed long pos = 0) const;
135 
136         /** get WedgeAngle (300a,00d5)
137          *  @param  value  reference to variable in which the value should be stored
138          *  @param  pos    index of the value to get (0..vm-1)
139          *  @return status, EC_Normal if successful, an error code otherwise
140          */
141         OFCondition getWedgeAngle(Sint32 &value, const unsigned long pos = 0) const;
142 
143         /** get WedgeFactor (300a,00d6)
144          *  @param  value  reference to variable in which the value should be stored
145          *  @param  pos    index of the value to get (0..vm-1), -1 for all components
146          *  @return status, EC_Normal if successful, an error code otherwise
147          */
148         OFCondition getWedgeFactor(OFString &value, const signed long pos = 0) const;
149 
150         /** get WedgeFactor (300a,00d6)
151          *  @param  value  reference to variable in which the value should be stored
152          *  @param  pos    index of the value to get (0..vm-1)
153          *  @return status, EC_Normal if successful, an error code otherwise
154          */
155         OFCondition getWedgeFactor(Float64 &value, const unsigned long pos = 0) const;
156 
157         /** get WedgeID (300a,00d4)
158          *  @param  value  reference to variable in which the value should be stored
159          *  @param  pos    index of the value to get (0..vm-1), -1 for all components
160          *  @return status, EC_Normal if successful, an error code otherwise
161          */
162         OFCondition getWedgeID(OFString &value, const signed long pos = 0) const;
163 
164         /** get WedgeNumber (300a,00d2)
165          *  @param  value  reference to variable in which the value should be stored
166          *  @param  pos    index of the value to get (0..vm-1), -1 for all components
167          *  @return status, EC_Normal if successful, an error code otherwise
168          */
169         OFCondition getWedgeNumber(OFString &value, const signed long pos = 0) const;
170 
171         /** get WedgeNumber (300a,00d2)
172          *  @param  value  reference to variable in which the value should be stored
173          *  @param  pos    index of the value to get (0..vm-1)
174          *  @return status, EC_Normal if successful, an error code otherwise
175          */
176         OFCondition getWedgeNumber(Sint32 &value, const unsigned long pos = 0) const;
177 
178         /** get WedgeOrientation (300a,00d8)
179          *  @param  value  reference to variable in which the value should be stored
180          *  @param  pos    index of the value to get (0..vm-1), -1 for all components
181          *  @return status, EC_Normal if successful, an error code otherwise
182          */
183         OFCondition getWedgeOrientation(OFString &value, const signed long pos = 0) const;
184 
185         /** get WedgeOrientation (300a,00d8)
186          *  @param  value  reference to variable in which the value should be stored
187          *  @param  pos    index of the value to get (0..vm-1)
188          *  @return status, EC_Normal if successful, an error code otherwise
189          */
190         OFCondition getWedgeOrientation(Float64 &value, const unsigned long pos = 0) const;
191 
192         /** get WedgeType (300a,00d3)
193          *  @param  value  reference to variable in which the value should be stored
194          *  @param  pos    index of the value to get (0..vm-1), -1 for all components
195          *  @return status, EC_Normal if successful, an error code otherwise
196          */
197         OFCondition getWedgeType(OFString &value, const signed long pos = 0) const;
198 
199       // --- set DICOM attribute values ---
200 
201         /** set AccessoryCode (300a,00f9)
202          *  @param  value  value to be set (single value only) or "" for no value
203          *  @param  check  check 'value' for conformance with VR (LO) and VM (1) if enabled
204          *  @return status, EC_Normal if successful, an error code otherwise
205          */
206         OFCondition setAccessoryCode(const OFString &value, const OFBool check = OFTrue);
207 
208         /** set EffectiveWedgeAngle (300a,00de)
209          *  @param  value  value to be set (single value only) or "" for no value
210          *  @param  check  check 'value' for conformance with VR (DS) and VM (1) if enabled
211          *  @return status, EC_Normal if successful, an error code otherwise
212          */
213         OFCondition setEffectiveWedgeAngle(const OFString &value, const OFBool check = OFTrue);
214 
215         /** set SourceToWedgeTrayDistance (300a,00da)
216          *  @param  value  value to be set (single value only) or "" for no value
217          *  @param  check  check 'value' for conformance with VR (DS) and VM (1) if enabled
218          *  @return status, EC_Normal if successful, an error code otherwise
219          */
220         OFCondition setSourceToWedgeTrayDistance(const OFString &value, const OFBool check = OFTrue);
221 
222         /** set WedgeAngle (300a,00d5)
223          *  @param  value  value to be set (single value only) or "" for no value
224          *  @param  check  check 'value' for conformance with VR (IS) and VM (1) if enabled
225          *  @return status, EC_Normal if successful, an error code otherwise
226          */
227         OFCondition setWedgeAngle(const OFString &value, const OFBool check = OFTrue);
228 
229         /** set WedgeFactor (300a,00d6)
230          *  @param  value  value to be set (single value only) or "" for no value
231          *  @param  check  check 'value' for conformance with VR (DS) and VM (1) if enabled
232          *  @return status, EC_Normal if successful, an error code otherwise
233          */
234         OFCondition setWedgeFactor(const OFString &value, const OFBool check = OFTrue);
235 
236         /** set WedgeID (300a,00d4)
237          *  @param  value  value to be set (single value only) or "" for no value
238          *  @param  check  check 'value' for conformance with VR (SH) and VM (1) if enabled
239          *  @return status, EC_Normal if successful, an error code otherwise
240          */
241         OFCondition setWedgeID(const OFString &value, const OFBool check = OFTrue);
242 
243         /** set WedgeNumber (300a,00d2)
244          *  @param  value  value to be set (single value only) or "" for no value
245          *  @param  check  check 'value' for conformance with VR (IS) and VM (1) if enabled
246          *  @return status, EC_Normal if successful, an error code otherwise
247          */
248         OFCondition setWedgeNumber(const OFString &value, const OFBool check = OFTrue);
249 
250         /** set WedgeOrientation (300a,00d8)
251          *  @param  value  value to be set (single value only) or "" for no value
252          *  @param  check  check 'value' for conformance with VR (DS) and VM (1) if enabled
253          *  @return status, EC_Normal if successful, an error code otherwise
254          */
255         OFCondition setWedgeOrientation(const OFString &value, const OFBool check = OFTrue);
256 
257         /** set WedgeType (300a,00d3)
258          *  @param  value  value to be set (single value only) or "" for no value
259          *  @param  check  check 'value' for conformance with VR (CS) and VM (1) if enabled
260          *  @return status, EC_Normal if successful, an error code otherwise
261          */
262         OFCondition setWedgeType(const OFString &value, const OFBool check = OFTrue);
263 
264       private:
265 
266         /// internal flag used to mark the empty default item
267         /*const*/ OFBool EmptyDefaultItem;
268 
269         /// AccessoryCode (300a,00f9) vr=LO, vm=1, type=3
270         DcmLongString AccessoryCode;
271         /// EffectiveWedgeAngle (300a,00de) vr=DS, vm=1, type=3
272         DcmDecimalString EffectiveWedgeAngle;
273         /// SourceToWedgeTrayDistance (300a,00da) vr=DS, vm=1, type=3
274         DcmDecimalString SourceToWedgeTrayDistance;
275         /// WedgeAngle (300a,00d5) vr=IS, vm=1, type=2
276         DcmIntegerString WedgeAngle;
277         /// WedgeFactor (300a,00d6) vr=DS, vm=1, type=2
278         DcmDecimalString WedgeFactor;
279         /// WedgeID (300a,00d4) vr=SH, vm=1, type=3
280         DcmShortString WedgeID;
281         /// WedgeNumber (300a,00d2) vr=IS, vm=1, type=1
282         DcmIntegerString WedgeNumber;
283         /// WedgeOrientation (300a,00d8) vr=DS, vm=1, type=2
284         DcmDecimalString WedgeOrientation;
285         /// WedgeType (300a,00d3) vr=CS, vm=1, type=2
286         DcmCodeString WedgeType;
287 
288     };
289 
290   // --- constructors, destructor and operators ---
291 
292     /** (default) constructor
293      *  @param emptyDefaultSequence internal flag used to mark the empty default sequence
294      */
295     DRTWedgeSequence(const OFBool emptyDefaultSequence = OFFalse);
296 
297     /** copy constructor
298      *  @param copy sequence object to be copied
299      */
300     DRTWedgeSequence(const DRTWedgeSequence &copy);
301 
302     /** destructor
303      */
304     virtual ~DRTWedgeSequence();
305 
306     /** assigment operator
307      *  @param copy sequence object to be copied
308      *  @return reference to this object
309      */
310     DRTWedgeSequence &operator=(const DRTWedgeSequence &copy);
311 
312   // --- general methods ---
313 
314     /** clear all internal member variables
315      */
316     void clear();
317 
318     /** check if sequence is empty
319      *  @return OFTrue if sequence is empty, OFFalse otherwise
320      */
321     OFBool isEmpty();
322 
323     /** check if sequence is valid, i.e.\ not the empty default sequence
324      *  @return OFTrue if sequence is valid, OFFalse otherwise
325      */
326     OFBool isValid() const;
327 
328     /** get number of items in the sequence
329      *  @return number of items
330      */
331     size_t getNumberOfItems() const;
332 
333     /** goto first item in the sequence
334      *  @return status, EC_Normal if successful, an error code otherwise
335      */
336     OFCondition gotoFirstItem();
337 
338     /** goto next item in the sequence
339      *  @return status, EC_Normal if successful, an error code otherwise
340      */
341     OFCondition gotoNextItem();
342 
343     /** goto particular item in the sequence
344      *  @param  num  number of the item to be selected (0..num-1)
345      *  @return status, EC_Normal if successful, an error code otherwise
346      */
347     OFCondition gotoItem(const size_t num);
348 
349     /** get current item in the sequence
350      *  @param  item  reference to item pointer (result variable)
351      *  @return status, EC_Normal if successful, an error code otherwise
352      */
353     OFCondition getCurrentItem(Item *&item) const;
354 
355     /** get current item in the sequence
356      *  @return reference to specified item if successful, empty default item otherwise
357      */
358     Item &getCurrentItem();
359 
360     /** get current item in the sequence
361      *  @return const reference to specified item if successful, empty default item otherwise
362      */
363     const Item &getCurrentItem() const;
364 
365     /** get particular item in the sequence
366      *  @param  num   number of the item to be retrieved (0..num-1)
367      *  @param  item  reference to item pointer (result variable)
368      *  @return status, EC_Normal if successful, an error code otherwise
369      */
370     OFCondition getItem(const size_t num, Item *&item);
371 
372     /** get particular item in the sequence
373      *  @param  num  number of the item to be retrieved (0..num-1)
374      *  @return reference to specified item if successful, empty default item otherwise
375      */
376     Item &getItem(const size_t num);
377 
378     /** get particular item in the sequence
379      *  @param  num  number of the item to be retrieved (0..num-1)
380      *  @return const reference to specified item if successful, empty default item otherwise
381      */
382     const Item &getItem(const size_t num) const;
383 
384     /** get particular item in the sequence
385      *  @param  num  number of the item to be retrieved (0..num-1)
386      *  @return reference to specified item if successful, empty default item otherwise
387      */
388     Item &operator[](const size_t num);
389 
390     /** get particular item in the sequence
391      *  @param  num  number of the item to be retrieved (0..num-1)
392      *  @return const reference to specified item if successful, empty default item otherwise
393      */
394     const Item &operator[](const size_t num) const;
395 
396     /** add new item to the end of this sequence
397      *  @param  item  reference to new item pointer (result variable)
398      *  @return status, EC_Normal if successful, an error code otherwise
399      */
400     OFCondition addItem(Item *&item);
401 
402     /** insert new item into the sequence
403      *  @param  pos   position where the new item is to be inserted (0..num)
404      *  @param  item  reference to new item pointer (result variable)
405      *  @return status, EC_Normal if successful, an error code otherwise
406      */
407     OFCondition insertItem(const size_t pos, Item *&item);
408 
409     /** remove particular item from the sequence
410      *  @param  pos  position of the item to be removed (0..num-1)
411      *  @return status, EC_Normal if successful, an error code otherwise
412      */
413     OFCondition removeItem(const size_t pos);
414 
415   // --- input/output methods ---
416 
417     /** read sequence of items from dataset
418      *  @param  dataset     reference to DICOM dataset from which the sequence should be read
419      *  @param  card        cardinality (valid range for number of items)
420      *  @param  type        value type (valid value: "1", "1C", "2" or something else which is not checked)
421      *  @param  moduleName  optional module/sequence name to be printed (default: "RT object" if NULL)
422      *  @return status, EC_Normal if successful, an error code otherwise
423      */
424     OFCondition read(DcmItem &dataset,
425                      const OFString &card,
426                      const OFString &type,
427                      const char *moduleName = NULL);
428 
429     /** write sequence of items to dataset
430      *  @param  dataset     reference to DICOM dataset to which the sequence should be written
431      *  @param  card        cardinality (valid range for number of items)
432      *  @param  type        value type (valid value: "1", "2" or something else which is not checked)
433      *  @param  moduleName  optional module/sequence name to be printed (default: "RT object" if NULL)
434      *  @return status, EC_Normal if successful, an error code otherwise
435      */
436     OFCondition write(DcmItem &dataset,
437                       const OFString &card,
438                       const OFString &type,
439                       const char *moduleName = NULL);
440 
441   protected:
442 
443     /** goto particular item in the sequence
444      *  @param  num       number of the item to be selected (0..num-1)
445      *  @param  iterator  list iterator storing the position of the item
446      *  @return status, EC_Normal if successful, an error code otherwise
447      */
448     OFCondition gotoItem(const size_t num,
449                          OFListIterator(Item *) &iterator);
450 
451     /** goto particular item in the sequence
452      *  @param  num       number of the item to be selected (0..num-1)
453      *  @param  iterator  list iterator storing the position of the item
454      *  @return status, EC_Normal if successful, an error code otherwise
455      */
456     OFCondition gotoItem(const size_t num,
457                          OFListConstIterator(Item *) &iterator) const;
458 
459   private:
460 
461     /// internal flag used to mark the empty default sequence
462     /*const*/ OFBool EmptyDefaultSequence;
463 
464     /// list of items in this sequence
465     OFList<Item *>         SequenceOfItems;
466     /// currently selected item
467     OFListIterator(Item *) CurrentItem;
468     /// empty default item
469     Item                   EmptyItem;
470 
471 };
472 
473 
474 #endif
475