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 DRTMappingResourceIdentificationSequence
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 DRTMRIS_H
16 #define DRTMRIS_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 MappingResourceIdentificationSequence (0008,0124)
25  */
26 class DCMTK_DCMRT_EXPORT DRTMappingResourceIdentificationSequence
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 MappingResource (0008,0105)
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 getMappingResource(OFString &value, const signed long pos = 0) const;
100 
101         /** get MappingResourceName (0008,0122)
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 getMappingResourceName(OFString &value, const signed long pos = 0) const;
107 
108         /** get MappingResourceUID (0008,0118)
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), -1 for all components
111          *  @return status, EC_Normal if successful, an error code otherwise
112          */
113         OFCondition getMappingResourceUID(OFString &value, const signed long pos = 0) const;
114 
115       // --- set DICOM attribute values ---
116 
117         /** set MappingResource (0008,0105)
118          *  @param  value  value to be set (single value only) or "" for no value
119          *  @param  check  check 'value' for conformance with VR (CS) and VM (1) if enabled
120          *  @return status, EC_Normal if successful, an error code otherwise
121          */
122         OFCondition setMappingResource(const OFString &value, const OFBool check = OFTrue);
123 
124         /** set MappingResourceName (0008,0122)
125          *  @param  value  value to be set (single value only) or "" for no value
126          *  @param  check  check 'value' for conformance with VR (LO) and VM (1) if enabled
127          *  @return status, EC_Normal if successful, an error code otherwise
128          */
129         OFCondition setMappingResourceName(const OFString &value, const OFBool check = OFTrue);
130 
131         /** set MappingResourceUID (0008,0118)
132          *  @param  value  value to be set (single value only) or "" for no value
133          *  @param  check  check 'value' for conformance with VR (UI) and VM (1) if enabled
134          *  @return status, EC_Normal if successful, an error code otherwise
135          */
136         OFCondition setMappingResourceUID(const OFString &value, const OFBool check = OFTrue);
137 
138       private:
139 
140         /// internal flag used to mark the empty default item
141         /*const*/ OFBool EmptyDefaultItem;
142 
143         /// MappingResource (0008,0105) vr=CS, vm=1, type=1
144         DcmCodeString MappingResource;
145         /// MappingResourceName (0008,0122) vr=LO, vm=1, type=3
146         DcmLongString MappingResourceName;
147         /// MappingResourceUID (0008,0118) vr=UI, vm=1, type=3
148         DcmUniqueIdentifier MappingResourceUID;
149 
150     };
151 
152   // --- constructors, destructor and operators ---
153 
154     /** (default) constructor
155      *  @param emptyDefaultSequence internal flag used to mark the empty default sequence
156      */
157     DRTMappingResourceIdentificationSequence(const OFBool emptyDefaultSequence = OFFalse);
158 
159     /** copy constructor
160      *  @param copy sequence object to be copied
161      */
162     DRTMappingResourceIdentificationSequence(const DRTMappingResourceIdentificationSequence &copy);
163 
164     /** destructor
165      */
166     virtual ~DRTMappingResourceIdentificationSequence();
167 
168     /** assigment operator
169      *  @param copy sequence object to be copied
170      *  @return reference to this object
171      */
172     DRTMappingResourceIdentificationSequence &operator=(const DRTMappingResourceIdentificationSequence &copy);
173 
174   // --- general methods ---
175 
176     /** clear all internal member variables
177      */
178     void clear();
179 
180     /** check if sequence is empty
181      *  @return OFTrue if sequence is empty, OFFalse otherwise
182      */
183     OFBool isEmpty();
184 
185     /** check if sequence is valid, i.e.\ not the empty default sequence
186      *  @return OFTrue if sequence is valid, OFFalse otherwise
187      */
188     OFBool isValid() const;
189 
190     /** get number of items in the sequence
191      *  @return number of items
192      */
193     size_t getNumberOfItems() const;
194 
195     /** goto first item in the sequence
196      *  @return status, EC_Normal if successful, an error code otherwise
197      */
198     OFCondition gotoFirstItem();
199 
200     /** goto next item in the sequence
201      *  @return status, EC_Normal if successful, an error code otherwise
202      */
203     OFCondition gotoNextItem();
204 
205     /** goto particular item in the sequence
206      *  @param  num  number of the item to be selected (0..num-1)
207      *  @return status, EC_Normal if successful, an error code otherwise
208      */
209     OFCondition gotoItem(const size_t num);
210 
211     /** get current item in the sequence
212      *  @param  item  reference to item pointer (result variable)
213      *  @return status, EC_Normal if successful, an error code otherwise
214      */
215     OFCondition getCurrentItem(Item *&item) const;
216 
217     /** get current item in the sequence
218      *  @return reference to specified item if successful, empty default item otherwise
219      */
220     Item &getCurrentItem();
221 
222     /** get current item in the sequence
223      *  @return const reference to specified item if successful, empty default item otherwise
224      */
225     const Item &getCurrentItem() const;
226 
227     /** get particular item in the sequence
228      *  @param  num   number of the item to be retrieved (0..num-1)
229      *  @param  item  reference to item pointer (result variable)
230      *  @return status, EC_Normal if successful, an error code otherwise
231      */
232     OFCondition getItem(const size_t num, Item *&item);
233 
234     /** get particular item in the sequence
235      *  @param  num  number of the item to be retrieved (0..num-1)
236      *  @return reference to specified item if successful, empty default item otherwise
237      */
238     Item &getItem(const size_t num);
239 
240     /** get particular item in the sequence
241      *  @param  num  number of the item to be retrieved (0..num-1)
242      *  @return const reference to specified item if successful, empty default item otherwise
243      */
244     const Item &getItem(const size_t num) const;
245 
246     /** get particular item in the sequence
247      *  @param  num  number of the item to be retrieved (0..num-1)
248      *  @return reference to specified item if successful, empty default item otherwise
249      */
250     Item &operator[](const size_t num);
251 
252     /** get particular item in the sequence
253      *  @param  num  number of the item to be retrieved (0..num-1)
254      *  @return const reference to specified item if successful, empty default item otherwise
255      */
256     const Item &operator[](const size_t num) const;
257 
258     /** add new item to the end of this sequence
259      *  @param  item  reference to new item pointer (result variable)
260      *  @return status, EC_Normal if successful, an error code otherwise
261      */
262     OFCondition addItem(Item *&item);
263 
264     /** insert new item into the sequence
265      *  @param  pos   position where the new item is to be inserted (0..num)
266      *  @param  item  reference to new item pointer (result variable)
267      *  @return status, EC_Normal if successful, an error code otherwise
268      */
269     OFCondition insertItem(const size_t pos, Item *&item);
270 
271     /** remove particular item from the sequence
272      *  @param  pos  position of the item to be removed (0..num-1)
273      *  @return status, EC_Normal if successful, an error code otherwise
274      */
275     OFCondition removeItem(const size_t pos);
276 
277   // --- input/output methods ---
278 
279     /** read sequence of items from dataset
280      *  @param  dataset     reference to DICOM dataset from which the sequence should be read
281      *  @param  card        cardinality (valid range for number of items)
282      *  @param  type        value type (valid value: "1", "1C", "2" or something else which is not checked)
283      *  @param  moduleName  optional module/sequence name to be printed (default: "RT object" if NULL)
284      *  @return status, EC_Normal if successful, an error code otherwise
285      */
286     OFCondition read(DcmItem &dataset,
287                      const OFString &card,
288                      const OFString &type,
289                      const char *moduleName = NULL);
290 
291     /** write sequence of items to dataset
292      *  @param  dataset     reference to DICOM dataset to which the sequence should be written
293      *  @param  card        cardinality (valid range for number of items)
294      *  @param  type        value type (valid value: "1", "2" or something else which is not checked)
295      *  @param  moduleName  optional module/sequence name to be printed (default: "RT object" if NULL)
296      *  @return status, EC_Normal if successful, an error code otherwise
297      */
298     OFCondition write(DcmItem &dataset,
299                       const OFString &card,
300                       const OFString &type,
301                       const char *moduleName = NULL);
302 
303   protected:
304 
305     /** goto particular item in the sequence
306      *  @param  num       number of the item to be selected (0..num-1)
307      *  @param  iterator  list iterator storing the position of the item
308      *  @return status, EC_Normal if successful, an error code otherwise
309      */
310     OFCondition gotoItem(const size_t num,
311                          OFListIterator(Item *) &iterator);
312 
313     /** goto particular item in the sequence
314      *  @param  num       number of the item to be selected (0..num-1)
315      *  @param  iterator  list iterator storing the position of the item
316      *  @return status, EC_Normal if successful, an error code otherwise
317      */
318     OFCondition gotoItem(const size_t num,
319                          OFListConstIterator(Item *) &iterator) const;
320 
321   private:
322 
323     /// internal flag used to mark the empty default sequence
324     /*const*/ OFBool EmptyDefaultSequence;
325 
326     /// list of items in this sequence
327     OFList<Item *>         SequenceOfItems;
328     /// currently selected item
329     OFListIterator(Item *) CurrentItem;
330     /// empty default item
331     Item                   EmptyItem;
332 
333 };
334 
335 
336 #endif
337