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 * Source file for class DRTBlockSequenceInRTBeamsModule
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 #include "dcmtk/config/osconfig.h" // make sure OS specific configuration is included first
16
17 #include "dcmtk/dcmrt/seq/drtbl2.h"
18
19
20 // --- item class ---
21
Item(const OFBool emptyDefaultItem)22 DRTBlockSequenceInRTBeamsModule::Item::Item(const OFBool emptyDefaultItem)
23 : EmptyDefaultItem(emptyDefaultItem),
24 AccessoryCode(DCM_AccessoryCode),
25 BlockData(DCM_BlockData),
26 BlockDivergence(DCM_BlockDivergence),
27 BlockMountingPosition(DCM_BlockMountingPosition),
28 BlockName(DCM_BlockName),
29 BlockNumber(DCM_BlockNumber),
30 BlockNumberOfPoints(DCM_BlockNumberOfPoints),
31 BlockThickness(DCM_BlockThickness),
32 BlockTransmission(DCM_BlockTransmission),
33 BlockTrayID(DCM_BlockTrayID),
34 BlockType(DCM_BlockType),
35 MaterialID(DCM_MaterialID),
36 SourceToBlockTrayDistance(DCM_SourceToBlockTrayDistance),
37 TrayAccessoryCode(DCM_TrayAccessoryCode)
38 {
39 }
40
41
Item(const Item & copy)42 DRTBlockSequenceInRTBeamsModule::Item::Item(const Item ©)
43 : EmptyDefaultItem(copy.EmptyDefaultItem),
44 AccessoryCode(copy.AccessoryCode),
45 BlockData(copy.BlockData),
46 BlockDivergence(copy.BlockDivergence),
47 BlockMountingPosition(copy.BlockMountingPosition),
48 BlockName(copy.BlockName),
49 BlockNumber(copy.BlockNumber),
50 BlockNumberOfPoints(copy.BlockNumberOfPoints),
51 BlockThickness(copy.BlockThickness),
52 BlockTransmission(copy.BlockTransmission),
53 BlockTrayID(copy.BlockTrayID),
54 BlockType(copy.BlockType),
55 MaterialID(copy.MaterialID),
56 SourceToBlockTrayDistance(copy.SourceToBlockTrayDistance),
57 TrayAccessoryCode(copy.TrayAccessoryCode)
58 {
59 }
60
61
~Item()62 DRTBlockSequenceInRTBeamsModule::Item::~Item()
63 {
64 }
65
66
operator =(const Item & copy)67 DRTBlockSequenceInRTBeamsModule::Item &DRTBlockSequenceInRTBeamsModule::Item::operator=(const Item ©)
68 {
69 if (this != ©)
70 {
71 EmptyDefaultItem = copy.EmptyDefaultItem;
72 AccessoryCode = copy.AccessoryCode;
73 BlockData = copy.BlockData;
74 BlockDivergence = copy.BlockDivergence;
75 BlockMountingPosition = copy.BlockMountingPosition;
76 BlockName = copy.BlockName;
77 BlockNumber = copy.BlockNumber;
78 BlockNumberOfPoints = copy.BlockNumberOfPoints;
79 BlockThickness = copy.BlockThickness;
80 BlockTransmission = copy.BlockTransmission;
81 BlockTrayID = copy.BlockTrayID;
82 BlockType = copy.BlockType;
83 MaterialID = copy.MaterialID;
84 SourceToBlockTrayDistance = copy.SourceToBlockTrayDistance;
85 TrayAccessoryCode = copy.TrayAccessoryCode;
86 }
87 return *this;
88 }
89
90
clear()91 void DRTBlockSequenceInRTBeamsModule::Item::clear()
92 {
93 if (!EmptyDefaultItem)
94 {
95 /* clear all DICOM attributes */
96 BlockTrayID.clear();
97 TrayAccessoryCode.clear();
98 AccessoryCode.clear();
99 SourceToBlockTrayDistance.clear();
100 BlockType.clear();
101 BlockDivergence.clear();
102 BlockMountingPosition.clear();
103 BlockNumber.clear();
104 BlockName.clear();
105 MaterialID.clear();
106 BlockThickness.clear();
107 BlockTransmission.clear();
108 BlockNumberOfPoints.clear();
109 BlockData.clear();
110 }
111 }
112
113
isEmpty()114 OFBool DRTBlockSequenceInRTBeamsModule::Item::isEmpty()
115 {
116 return BlockTrayID.isEmpty() &&
117 TrayAccessoryCode.isEmpty() &&
118 AccessoryCode.isEmpty() &&
119 SourceToBlockTrayDistance.isEmpty() &&
120 BlockType.isEmpty() &&
121 BlockDivergence.isEmpty() &&
122 BlockMountingPosition.isEmpty() &&
123 BlockNumber.isEmpty() &&
124 BlockName.isEmpty() &&
125 MaterialID.isEmpty() &&
126 BlockThickness.isEmpty() &&
127 BlockTransmission.isEmpty() &&
128 BlockNumberOfPoints.isEmpty() &&
129 BlockData.isEmpty();
130 }
131
132
isValid() const133 OFBool DRTBlockSequenceInRTBeamsModule::Item::isValid() const
134 {
135 return !EmptyDefaultItem;
136 }
137
138
read(DcmItem & item)139 OFCondition DRTBlockSequenceInRTBeamsModule::Item::read(DcmItem &item)
140 {
141 OFCondition result = EC_IllegalCall;
142 if (!EmptyDefaultItem)
143 {
144 /* re-initialize object */
145 clear();
146 getAndCheckElementFromDataset(item, BlockTrayID, "1", "3", "BlockSequence");
147 getAndCheckElementFromDataset(item, TrayAccessoryCode, "1", "3", "BlockSequence");
148 getAndCheckElementFromDataset(item, AccessoryCode, "1", "3", "BlockSequence");
149 getAndCheckElementFromDataset(item, SourceToBlockTrayDistance, "1", "2", "BlockSequence");
150 getAndCheckElementFromDataset(item, BlockType, "1", "1", "BlockSequence");
151 getAndCheckElementFromDataset(item, BlockDivergence, "1", "2", "BlockSequence");
152 getAndCheckElementFromDataset(item, BlockMountingPosition, "1", "3", "BlockSequence");
153 getAndCheckElementFromDataset(item, BlockNumber, "1", "1", "BlockSequence");
154 getAndCheckElementFromDataset(item, BlockName, "1", "3", "BlockSequence");
155 getAndCheckElementFromDataset(item, MaterialID, "1", "2", "BlockSequence");
156 getAndCheckElementFromDataset(item, BlockThickness, "1", "2C", "BlockSequence");
157 getAndCheckElementFromDataset(item, BlockTransmission, "1", "2C", "BlockSequence");
158 getAndCheckElementFromDataset(item, BlockNumberOfPoints, "1", "2", "BlockSequence");
159 getAndCheckElementFromDataset(item, BlockData, "2-2n", "2", "BlockSequence");
160 result = EC_Normal;
161 }
162 return result;
163 }
164
165
write(DcmItem & item)166 OFCondition DRTBlockSequenceInRTBeamsModule::Item::write(DcmItem &item)
167 {
168 OFCondition result = EC_IllegalCall;
169 if (!EmptyDefaultItem)
170 {
171 result = EC_Normal;
172 addElementToDataset(result, item, new DcmShortString(BlockTrayID), "1", "3", "BlockSequence");
173 addElementToDataset(result, item, new DcmLongString(TrayAccessoryCode), "1", "3", "BlockSequence");
174 addElementToDataset(result, item, new DcmLongString(AccessoryCode), "1", "3", "BlockSequence");
175 addElementToDataset(result, item, new DcmDecimalString(SourceToBlockTrayDistance), "1", "2", "BlockSequence");
176 addElementToDataset(result, item, new DcmCodeString(BlockType), "1", "1", "BlockSequence");
177 addElementToDataset(result, item, new DcmCodeString(BlockDivergence), "1", "2", "BlockSequence");
178 addElementToDataset(result, item, new DcmCodeString(BlockMountingPosition), "1", "3", "BlockSequence");
179 addElementToDataset(result, item, new DcmIntegerString(BlockNumber), "1", "1", "BlockSequence");
180 addElementToDataset(result, item, new DcmLongString(BlockName), "1", "3", "BlockSequence");
181 addElementToDataset(result, item, new DcmShortString(MaterialID), "1", "2", "BlockSequence");
182 addElementToDataset(result, item, new DcmDecimalString(BlockThickness), "1", "2C", "BlockSequence");
183 addElementToDataset(result, item, new DcmDecimalString(BlockTransmission), "1", "2C", "BlockSequence");
184 addElementToDataset(result, item, new DcmIntegerString(BlockNumberOfPoints), "1", "2", "BlockSequence");
185 addElementToDataset(result, item, new DcmDecimalString(BlockData), "2-2n", "2", "BlockSequence");
186 }
187 return result;
188 }
189
190
getAccessoryCode(OFString & value,const signed long pos) const191 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getAccessoryCode(OFString &value, const signed long pos) const
192 {
193 if (EmptyDefaultItem)
194 return EC_IllegalCall;
195 else
196 return getStringValueFromElement(AccessoryCode, value, pos);
197 }
198
199
getBlockData(OFString & value,const signed long pos) const200 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockData(OFString &value, const signed long pos) const
201 {
202 if (EmptyDefaultItem)
203 return EC_IllegalCall;
204 else
205 return getStringValueFromElement(BlockData, value, pos);
206 }
207
208
getBlockData(Float64 & value,const unsigned long pos) const209 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockData(Float64 &value, const unsigned long pos) const
210 {
211 if (EmptyDefaultItem)
212 return EC_IllegalCall;
213 else
214 return OFconst_cast(DcmDecimalString &, BlockData).getFloat64(value, pos);
215 }
216
217
getBlockData(OFVector<Float64> & value) const218 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockData(OFVector<Float64> &value) const
219 {
220 if (EmptyDefaultItem)
221 return EC_IllegalCall;
222 else
223 return OFconst_cast(DcmDecimalString &, BlockData).getFloat64Vector(value);
224 }
225
226
getBlockDivergence(OFString & value,const signed long pos) const227 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockDivergence(OFString &value, const signed long pos) const
228 {
229 if (EmptyDefaultItem)
230 return EC_IllegalCall;
231 else
232 return getStringValueFromElement(BlockDivergence, value, pos);
233 }
234
235
getBlockMountingPosition(OFString & value,const signed long pos) const236 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockMountingPosition(OFString &value, const signed long pos) const
237 {
238 if (EmptyDefaultItem)
239 return EC_IllegalCall;
240 else
241 return getStringValueFromElement(BlockMountingPosition, value, pos);
242 }
243
244
getBlockName(OFString & value,const signed long pos) const245 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockName(OFString &value, const signed long pos) const
246 {
247 if (EmptyDefaultItem)
248 return EC_IllegalCall;
249 else
250 return getStringValueFromElement(BlockName, value, pos);
251 }
252
253
getBlockNumber(OFString & value,const signed long pos) const254 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockNumber(OFString &value, const signed long pos) const
255 {
256 if (EmptyDefaultItem)
257 return EC_IllegalCall;
258 else
259 return getStringValueFromElement(BlockNumber, value, pos);
260 }
261
262
getBlockNumber(Sint32 & value,const unsigned long pos) const263 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockNumber(Sint32 &value, const unsigned long pos) const
264 {
265 if (EmptyDefaultItem)
266 return EC_IllegalCall;
267 else
268 return OFconst_cast(DcmIntegerString &, BlockNumber).getSint32(value, pos);
269 }
270
271
getBlockNumberOfPoints(OFString & value,const signed long pos) const272 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockNumberOfPoints(OFString &value, const signed long pos) const
273 {
274 if (EmptyDefaultItem)
275 return EC_IllegalCall;
276 else
277 return getStringValueFromElement(BlockNumberOfPoints, value, pos);
278 }
279
280
getBlockNumberOfPoints(Sint32 & value,const unsigned long pos) const281 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockNumberOfPoints(Sint32 &value, const unsigned long pos) const
282 {
283 if (EmptyDefaultItem)
284 return EC_IllegalCall;
285 else
286 return OFconst_cast(DcmIntegerString &, BlockNumberOfPoints).getSint32(value, pos);
287 }
288
289
getBlockThickness(OFString & value,const signed long pos) const290 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockThickness(OFString &value, const signed long pos) const
291 {
292 if (EmptyDefaultItem)
293 return EC_IllegalCall;
294 else
295 return getStringValueFromElement(BlockThickness, value, pos);
296 }
297
298
getBlockThickness(Float64 & value,const unsigned long pos) const299 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockThickness(Float64 &value, const unsigned long pos) const
300 {
301 if (EmptyDefaultItem)
302 return EC_IllegalCall;
303 else
304 return OFconst_cast(DcmDecimalString &, BlockThickness).getFloat64(value, pos);
305 }
306
307
getBlockTransmission(OFString & value,const signed long pos) const308 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockTransmission(OFString &value, const signed long pos) const
309 {
310 if (EmptyDefaultItem)
311 return EC_IllegalCall;
312 else
313 return getStringValueFromElement(BlockTransmission, value, pos);
314 }
315
316
getBlockTransmission(Float64 & value,const unsigned long pos) const317 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockTransmission(Float64 &value, const unsigned long pos) const
318 {
319 if (EmptyDefaultItem)
320 return EC_IllegalCall;
321 else
322 return OFconst_cast(DcmDecimalString &, BlockTransmission).getFloat64(value, pos);
323 }
324
325
getBlockTrayID(OFString & value,const signed long pos) const326 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockTrayID(OFString &value, const signed long pos) const
327 {
328 if (EmptyDefaultItem)
329 return EC_IllegalCall;
330 else
331 return getStringValueFromElement(BlockTrayID, value, pos);
332 }
333
334
getBlockType(OFString & value,const signed long pos) const335 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getBlockType(OFString &value, const signed long pos) const
336 {
337 if (EmptyDefaultItem)
338 return EC_IllegalCall;
339 else
340 return getStringValueFromElement(BlockType, value, pos);
341 }
342
343
getMaterialID(OFString & value,const signed long pos) const344 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getMaterialID(OFString &value, const signed long pos) const
345 {
346 if (EmptyDefaultItem)
347 return EC_IllegalCall;
348 else
349 return getStringValueFromElement(MaterialID, value, pos);
350 }
351
352
getSourceToBlockTrayDistance(OFString & value,const signed long pos) const353 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getSourceToBlockTrayDistance(OFString &value, const signed long pos) const
354 {
355 if (EmptyDefaultItem)
356 return EC_IllegalCall;
357 else
358 return getStringValueFromElement(SourceToBlockTrayDistance, value, pos);
359 }
360
361
getSourceToBlockTrayDistance(Float64 & value,const unsigned long pos) const362 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getSourceToBlockTrayDistance(Float64 &value, const unsigned long pos) const
363 {
364 if (EmptyDefaultItem)
365 return EC_IllegalCall;
366 else
367 return OFconst_cast(DcmDecimalString &, SourceToBlockTrayDistance).getFloat64(value, pos);
368 }
369
370
getTrayAccessoryCode(OFString & value,const signed long pos) const371 OFCondition DRTBlockSequenceInRTBeamsModule::Item::getTrayAccessoryCode(OFString &value, const signed long pos) const
372 {
373 if (EmptyDefaultItem)
374 return EC_IllegalCall;
375 else
376 return getStringValueFromElement(TrayAccessoryCode, value, pos);
377 }
378
379
setAccessoryCode(const OFString & value,const OFBool check)380 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setAccessoryCode(const OFString &value, const OFBool check)
381 {
382 OFCondition result = EC_IllegalCall;
383 if (!EmptyDefaultItem)
384 {
385 result = (check) ? DcmLongString::checkStringValue(value, "1") : EC_Normal;
386 if (result.good())
387 result = AccessoryCode.putOFStringArray(value);
388 }
389 return result;
390 }
391
392
setBlockData(const OFString & value,const OFBool check)393 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setBlockData(const OFString &value, const OFBool check)
394 {
395 OFCondition result = EC_IllegalCall;
396 if (!EmptyDefaultItem)
397 {
398 result = (check) ? DcmDecimalString::checkStringValue(value, "2-2n") : EC_Normal;
399 if (result.good())
400 result = BlockData.putOFStringArray(value);
401 }
402 return result;
403 }
404
405
setBlockDivergence(const OFString & value,const OFBool check)406 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setBlockDivergence(const OFString &value, const OFBool check)
407 {
408 OFCondition result = EC_IllegalCall;
409 if (!EmptyDefaultItem)
410 {
411 result = (check) ? DcmCodeString::checkStringValue(value, "1") : EC_Normal;
412 if (result.good())
413 result = BlockDivergence.putOFStringArray(value);
414 }
415 return result;
416 }
417
418
setBlockMountingPosition(const OFString & value,const OFBool check)419 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setBlockMountingPosition(const OFString &value, const OFBool check)
420 {
421 OFCondition result = EC_IllegalCall;
422 if (!EmptyDefaultItem)
423 {
424 result = (check) ? DcmCodeString::checkStringValue(value, "1") : EC_Normal;
425 if (result.good())
426 result = BlockMountingPosition.putOFStringArray(value);
427 }
428 return result;
429 }
430
431
setBlockName(const OFString & value,const OFBool check)432 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setBlockName(const OFString &value, const OFBool check)
433 {
434 OFCondition result = EC_IllegalCall;
435 if (!EmptyDefaultItem)
436 {
437 result = (check) ? DcmLongString::checkStringValue(value, "1") : EC_Normal;
438 if (result.good())
439 result = BlockName.putOFStringArray(value);
440 }
441 return result;
442 }
443
444
setBlockNumber(const OFString & value,const OFBool check)445 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setBlockNumber(const OFString &value, const OFBool check)
446 {
447 OFCondition result = EC_IllegalCall;
448 if (!EmptyDefaultItem)
449 {
450 result = (check) ? DcmIntegerString::checkStringValue(value, "1") : EC_Normal;
451 if (result.good())
452 result = BlockNumber.putOFStringArray(value);
453 }
454 return result;
455 }
456
457
setBlockNumberOfPoints(const OFString & value,const OFBool check)458 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setBlockNumberOfPoints(const OFString &value, const OFBool check)
459 {
460 OFCondition result = EC_IllegalCall;
461 if (!EmptyDefaultItem)
462 {
463 result = (check) ? DcmIntegerString::checkStringValue(value, "1") : EC_Normal;
464 if (result.good())
465 result = BlockNumberOfPoints.putOFStringArray(value);
466 }
467 return result;
468 }
469
470
setBlockThickness(const OFString & value,const OFBool check)471 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setBlockThickness(const OFString &value, const OFBool check)
472 {
473 OFCondition result = EC_IllegalCall;
474 if (!EmptyDefaultItem)
475 {
476 result = (check) ? DcmDecimalString::checkStringValue(value, "1") : EC_Normal;
477 if (result.good())
478 result = BlockThickness.putOFStringArray(value);
479 }
480 return result;
481 }
482
483
setBlockTransmission(const OFString & value,const OFBool check)484 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setBlockTransmission(const OFString &value, const OFBool check)
485 {
486 OFCondition result = EC_IllegalCall;
487 if (!EmptyDefaultItem)
488 {
489 result = (check) ? DcmDecimalString::checkStringValue(value, "1") : EC_Normal;
490 if (result.good())
491 result = BlockTransmission.putOFStringArray(value);
492 }
493 return result;
494 }
495
496
setBlockTrayID(const OFString & value,const OFBool check)497 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setBlockTrayID(const OFString &value, const OFBool check)
498 {
499 OFCondition result = EC_IllegalCall;
500 if (!EmptyDefaultItem)
501 {
502 result = (check) ? DcmShortString::checkStringValue(value, "1") : EC_Normal;
503 if (result.good())
504 result = BlockTrayID.putOFStringArray(value);
505 }
506 return result;
507 }
508
509
setBlockType(const OFString & value,const OFBool check)510 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setBlockType(const OFString &value, const OFBool check)
511 {
512 OFCondition result = EC_IllegalCall;
513 if (!EmptyDefaultItem)
514 {
515 result = (check) ? DcmCodeString::checkStringValue(value, "1") : EC_Normal;
516 if (result.good())
517 result = BlockType.putOFStringArray(value);
518 }
519 return result;
520 }
521
522
setMaterialID(const OFString & value,const OFBool check)523 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setMaterialID(const OFString &value, const OFBool check)
524 {
525 OFCondition result = EC_IllegalCall;
526 if (!EmptyDefaultItem)
527 {
528 result = (check) ? DcmShortString::checkStringValue(value, "1") : EC_Normal;
529 if (result.good())
530 result = MaterialID.putOFStringArray(value);
531 }
532 return result;
533 }
534
535
setSourceToBlockTrayDistance(const OFString & value,const OFBool check)536 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setSourceToBlockTrayDistance(const OFString &value, const OFBool check)
537 {
538 OFCondition result = EC_IllegalCall;
539 if (!EmptyDefaultItem)
540 {
541 result = (check) ? DcmDecimalString::checkStringValue(value, "1") : EC_Normal;
542 if (result.good())
543 result = SourceToBlockTrayDistance.putOFStringArray(value);
544 }
545 return result;
546 }
547
548
setTrayAccessoryCode(const OFString & value,const OFBool check)549 OFCondition DRTBlockSequenceInRTBeamsModule::Item::setTrayAccessoryCode(const OFString &value, const OFBool check)
550 {
551 OFCondition result = EC_IllegalCall;
552 if (!EmptyDefaultItem)
553 {
554 result = (check) ? DcmLongString::checkStringValue(value, "1") : EC_Normal;
555 if (result.good())
556 result = TrayAccessoryCode.putOFStringArray(value);
557 }
558 return result;
559 }
560
561
562 // --- sequence class ---
563
DRTBlockSequenceInRTBeamsModule(const OFBool emptyDefaultSequence)564 DRTBlockSequenceInRTBeamsModule::DRTBlockSequenceInRTBeamsModule(const OFBool emptyDefaultSequence)
565 : EmptyDefaultSequence(emptyDefaultSequence),
566 SequenceOfItems(),
567 CurrentItem(),
568 EmptyItem(OFTrue /*emptyDefaultItem*/)
569 {
570 CurrentItem = SequenceOfItems.end();
571 }
572
573
DRTBlockSequenceInRTBeamsModule(const DRTBlockSequenceInRTBeamsModule & copy)574 DRTBlockSequenceInRTBeamsModule::DRTBlockSequenceInRTBeamsModule(const DRTBlockSequenceInRTBeamsModule ©)
575 : EmptyDefaultSequence(copy.EmptyDefaultSequence),
576 SequenceOfItems(),
577 CurrentItem(),
578 EmptyItem(OFTrue /*emptyDefaultItem*/)
579 {
580 /* create a copy of the internal sequence of items */
581 Item *item = NULL;
582 OFListConstIterator(Item *) current = copy.SequenceOfItems.begin();
583 const OFListConstIterator(Item *) last = copy.SequenceOfItems.end();
584 while (current != last)
585 {
586 item = new Item(**current);
587 if (item != NULL)
588 {
589 SequenceOfItems.push_back(item);
590 } else {
591 /* memory exhausted, there is nothing we can do about it */
592 break;
593 }
594 ++current;
595 }
596 CurrentItem = SequenceOfItems.begin();
597 }
598
599
operator =(const DRTBlockSequenceInRTBeamsModule & copy)600 DRTBlockSequenceInRTBeamsModule &DRTBlockSequenceInRTBeamsModule::operator=(const DRTBlockSequenceInRTBeamsModule ©)
601 {
602 if (this != ©)
603 {
604 clear();
605 EmptyDefaultSequence = copy.EmptyDefaultSequence;
606 /* create a copy of the internal sequence of items */
607 Item *item = NULL;
608 OFListConstIterator(Item *) current = copy.SequenceOfItems.begin();
609 const OFListConstIterator(Item *) last = copy.SequenceOfItems.end();
610 while (current != last)
611 {
612 item = new Item(**current);
613 if (item != NULL)
614 {
615 SequenceOfItems.push_back(item);
616 } else {
617 /* memory exhausted, there is nothing we can do about it */
618 break;
619 }
620 ++current;
621 }
622 CurrentItem = SequenceOfItems.begin();
623 }
624 return *this;
625 }
626
627
~DRTBlockSequenceInRTBeamsModule()628 DRTBlockSequenceInRTBeamsModule::~DRTBlockSequenceInRTBeamsModule()
629 {
630 clear();
631 }
632
633
clear()634 void DRTBlockSequenceInRTBeamsModule::clear()
635 {
636 if (!EmptyDefaultSequence)
637 {
638 CurrentItem = SequenceOfItems.begin();
639 const OFListConstIterator(Item *) last = SequenceOfItems.end();
640 /* delete all items and free memory */
641 while (CurrentItem != last)
642 {
643 delete (*CurrentItem);
644 CurrentItem = SequenceOfItems.erase(CurrentItem);
645 }
646 /* make sure that the list is empty */
647 SequenceOfItems.clear();
648 CurrentItem = SequenceOfItems.end();
649 }
650 }
651
652
isEmpty()653 OFBool DRTBlockSequenceInRTBeamsModule::isEmpty()
654 {
655 return SequenceOfItems.empty();
656 }
657
658
isValid() const659 OFBool DRTBlockSequenceInRTBeamsModule::isValid() const
660 {
661 return !EmptyDefaultSequence;
662 }
663
664
getNumberOfItems() const665 size_t DRTBlockSequenceInRTBeamsModule::getNumberOfItems() const
666 {
667 return SequenceOfItems.size();
668 }
669
670
gotoFirstItem()671 OFCondition DRTBlockSequenceInRTBeamsModule::gotoFirstItem()
672 {
673 OFCondition result = EC_IllegalCall;
674 if (!SequenceOfItems.empty())
675 {
676 CurrentItem = SequenceOfItems.begin();
677 result = EC_Normal;
678 }
679 return result;
680 }
681
682
gotoNextItem()683 OFCondition DRTBlockSequenceInRTBeamsModule::gotoNextItem()
684 {
685 OFCondition result = EC_IllegalCall;
686 if (CurrentItem != SequenceOfItems.end())
687 {
688 ++CurrentItem;
689 result = EC_Normal;
690 }
691 return result;
692 }
693
694
gotoItem(const size_t num,OFListIterator (Item *)& iterator)695 OFCondition DRTBlockSequenceInRTBeamsModule::gotoItem(const size_t num, OFListIterator(Item *) &iterator)
696 {
697 OFCondition result = EC_IllegalCall;
698 if (!SequenceOfItems.empty())
699 {
700 size_t idx = num + 1;
701 iterator = SequenceOfItems.begin();
702 const OFListConstIterator(Item *) last = SequenceOfItems.end();
703 while ((--idx > 0) && (iterator != last))
704 ++iterator;
705 /* specified list item found? */
706 if ((idx == 0) && (iterator != last))
707 result = EC_Normal;
708 else
709 result = EC_IllegalParameter;
710 }
711 return result;
712 }
713
714
gotoItem(const size_t num,OFListConstIterator (Item *)& iterator) const715 OFCondition DRTBlockSequenceInRTBeamsModule::gotoItem(const size_t num, OFListConstIterator(Item *) &iterator) const
716 {
717 OFCondition result = EC_IllegalCall;
718 if (!SequenceOfItems.empty())
719 {
720 size_t idx = num + 1;
721 iterator = SequenceOfItems.begin();
722 const OFListConstIterator(Item *) last = SequenceOfItems.end();
723 while ((--idx > 0) && (iterator != last))
724 ++iterator;
725 /* specified list item found? */
726 if ((idx == 0) && (iterator != last))
727 result = EC_Normal;
728 else
729 result = EC_IllegalParameter;
730 }
731 return result;
732 }
733
734
gotoItem(const size_t num)735 OFCondition DRTBlockSequenceInRTBeamsModule::gotoItem(const size_t num)
736 {
737 return gotoItem(num, CurrentItem);
738 }
739
740
getCurrentItem(Item * & item) const741 OFCondition DRTBlockSequenceInRTBeamsModule::getCurrentItem(Item *&item) const
742 {
743 OFCondition result = EC_IllegalCall;
744 if (CurrentItem != SequenceOfItems.end())
745 {
746 item = *CurrentItem;
747 result = EC_Normal;
748 }
749 return result;
750 }
751
752
getCurrentItem()753 DRTBlockSequenceInRTBeamsModule::Item &DRTBlockSequenceInRTBeamsModule::getCurrentItem()
754 {
755 if (CurrentItem != SequenceOfItems.end())
756 return **CurrentItem;
757 else
758 return EmptyItem;
759 }
760
761
getCurrentItem() const762 const DRTBlockSequenceInRTBeamsModule::Item &DRTBlockSequenceInRTBeamsModule::getCurrentItem() const
763 {
764 if (CurrentItem != SequenceOfItems.end())
765 return **CurrentItem;
766 else
767 return EmptyItem;
768 }
769
770
getItem(const size_t num,Item * & item)771 OFCondition DRTBlockSequenceInRTBeamsModule::getItem(const size_t num, Item *&item)
772 {
773 OFListIterator(Item *) iterator;
774 OFCondition result = gotoItem(num, iterator);
775 if (result.good())
776 item = *iterator;
777 return result;
778 }
779
780
getItem(const size_t num)781 DRTBlockSequenceInRTBeamsModule::Item &DRTBlockSequenceInRTBeamsModule::getItem(const size_t num)
782 {
783 OFListIterator(Item *) iterator;
784 if (gotoItem(num, iterator).good())
785 return **iterator;
786 else
787 return EmptyItem;
788 }
789
790
getItem(const size_t num) const791 const DRTBlockSequenceInRTBeamsModule::Item &DRTBlockSequenceInRTBeamsModule::getItem(const size_t num) const
792 {
793 OFListConstIterator(Item *) iterator;
794 if (gotoItem(num, iterator).good())
795 return **iterator;
796 else
797 return EmptyItem;
798 }
799
800
operator [](const size_t num)801 DRTBlockSequenceInRTBeamsModule::Item &DRTBlockSequenceInRTBeamsModule::operator[](const size_t num)
802 {
803 return getItem(num);
804 }
805
806
operator [](const size_t num) const807 const DRTBlockSequenceInRTBeamsModule::Item &DRTBlockSequenceInRTBeamsModule::operator[](const size_t num) const
808 {
809 return getItem(num);
810 }
811
812
addItem(Item * & item)813 OFCondition DRTBlockSequenceInRTBeamsModule::addItem(Item *&item)
814 {
815 OFCondition result = EC_IllegalCall;
816 if (!EmptyDefaultSequence)
817 {
818 item = new Item();
819 if (item != NULL)
820 {
821 SequenceOfItems.push_back(item);
822 result = EC_Normal;
823 } else
824 result = EC_MemoryExhausted;
825 }
826 return result;
827 }
828
829
insertItem(const size_t pos,Item * & item)830 OFCondition DRTBlockSequenceInRTBeamsModule::insertItem(const size_t pos, Item *&item)
831 {
832 OFCondition result = EC_IllegalCall;
833 if (!EmptyDefaultSequence)
834 {
835 OFListIterator(Item *) iterator;
836 result = gotoItem(pos, iterator);
837 if (result.good())
838 {
839 item = new Item();
840 if (item != NULL)
841 {
842 SequenceOfItems.insert(iterator, 1, item);
843 result = EC_Normal;
844 } else
845 result = EC_MemoryExhausted;
846 } else
847 result = addItem(item);
848 }
849 return result;
850 }
851
852
removeItem(const size_t pos)853 OFCondition DRTBlockSequenceInRTBeamsModule::removeItem(const size_t pos)
854 {
855 OFCondition result = EC_IllegalCall;
856 if (!EmptyDefaultSequence)
857 {
858 OFListIterator(Item *) iterator;
859 if (gotoItem(pos, iterator).good())
860 {
861 delete *iterator;
862 iterator = SequenceOfItems.erase(iterator);
863 result = EC_Normal;
864 } else
865 result = EC_IllegalParameter;
866 }
867 return result;
868 }
869
870
read(DcmItem & dataset,const OFString & card,const OFString & type,const char * moduleName)871 OFCondition DRTBlockSequenceInRTBeamsModule::read(DcmItem &dataset,
872 const OFString &card,
873 const OFString &type,
874 const char *moduleName)
875 {
876 OFCondition result = EC_IllegalCall;
877 if (!EmptyDefaultSequence)
878 {
879 /* re-initialize object */
880 clear();
881 /* retrieve sequence element from dataset */
882 DcmSequenceOfItems *sequence;
883 result = dataset.findAndGetSequence(DCM_BlockSequence, sequence);
884 if (sequence != NULL)
885 {
886 if (checkElementValue(*sequence, card, type, result, moduleName))
887 {
888 DcmStack stack;
889 OFBool first = OFTrue;
890 /* iterate over all sequence items */
891 while (result.good() && sequence->nextObject(stack, first /*intoSub*/).good())
892 {
893 DcmItem *ditem = OFstatic_cast(DcmItem *, stack.top());
894 if (ditem != NULL)
895 {
896 Item *item = new Item();
897 if (item != NULL)
898 {
899 result = item->read(*ditem);
900 if (result.good())
901 {
902 /* append new item to the end of the list */
903 SequenceOfItems.push_back(item);
904 first = OFFalse;
905 }
906 } else
907 result = EC_MemoryExhausted;
908 } else
909 result = EC_CorruptedData;
910 }
911 }
912 } else {
913 DcmSequenceOfItems element(DCM_BlockSequence);
914 checkElementValue(element, card, type, result, moduleName);
915 }
916 }
917 return result;
918 }
919
920
write(DcmItem & dataset,const OFString & card,const OFString & type,const char * moduleName)921 OFCondition DRTBlockSequenceInRTBeamsModule::write(DcmItem &dataset,
922 const OFString &card,
923 const OFString &type,
924 const char *moduleName)
925 {
926 OFCondition result = EC_IllegalCall;
927 if (!EmptyDefaultSequence)
928 {
929 result = EC_MemoryExhausted;
930 DcmSequenceOfItems *sequence = new DcmSequenceOfItems(DCM_BlockSequence);
931 if (sequence != NULL)
932 {
933 result = EC_Normal;
934 /* an empty optional sequence is not written */
935 if ((type == "2") || !SequenceOfItems.empty())
936 {
937 OFListIterator(Item *) iterator = SequenceOfItems.begin();
938 const OFListConstIterator(Item *) last = SequenceOfItems.end();
939 /* iterate over all sequence items */
940 while (result.good() && (iterator != last))
941 {
942 DcmItem *item = new DcmItem();
943 if (item != NULL)
944 {
945 /* append new item to the end of the sequence */
946 result = sequence->append(item);
947 if (result.good())
948 {
949 result = (*iterator)->write(*item);
950 ++iterator;
951 } else
952 delete item;
953 } else
954 result = EC_MemoryExhausted;
955 }
956 if (result.good())
957 {
958 /* insert sequence element into the dataset */
959 result = dataset.insert(sequence, OFTrue /*replaceOld*/);
960 }
961 if (DCM_dcmrtLogger.isEnabledFor(OFLogger::WARN_LOG_LEVEL))
962 checkElementValue(*sequence, card, type, result, moduleName);
963 if (result.good())
964 {
965 /* forget reference to sequence object (avoid deletion below) */
966 sequence = NULL;
967 }
968 }
969 else if (type == "1")
970 {
971 /* empty type 1 sequence not allowed */
972 result = RT_EC_InvalidValue;
973 if (DCM_dcmrtLogger.isEnabledFor(OFLogger::WARN_LOG_LEVEL))
974 checkElementValue(*sequence, card, type, result, moduleName);
975 }
976 /* delete sequence (if not inserted into the dataset) */
977 delete sequence;
978 }
979 }
980 return result;
981 }
982
983
984 // end of source file
985