OFFIS DCMTK  Version 3.6.0
dcsequen.h
1 /*
2  *
3  * Copyright (C) 1994-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmdata
15  *
16  * Author: Gerd Ehlers, Andreas Barth
17  *
18  * Purpose: Interface of class DcmSequenceOfItems
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-11-05 09:34:11 $
22  * CVS/RCS Revision: $Revision: 1.58 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DCSEQUEN_H
31 #define DCSEQUEN_H
32 
33 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
34 
35 #include "dcmtk/ofstd/offile.h" /* for offile_off_t */
36 #include "dcmtk/dcmdata/dcelem.h"
37 #include "dcmtk/dcmdata/dctag.h"
38 #include "dcmtk/dcmdata/dclist.h"
39 #include "dcmtk/dcmdata/dcstack.h"
40 
48 {
49 public:
50 
57  DcmSequenceOfItems(const DcmTag &tag,
58  const Uint32 len = 0,
59  OFBool readAsUN = OFFalse);
60 
65 
67  virtual ~DcmSequenceOfItems();
68 
73 
75  inline OFCondition error() const { return errorFlag; }
76 
80  virtual DcmObject *clone() const
81  {
82  return new DcmSequenceOfItems(*this);
83  }
84 
97  virtual OFCondition copyFrom(const DcmObject& rhs);
98 
105  virtual DcmEVR ident() const { return EVR_SQ; }
106 
113  virtual OFBool isLeaf() const { return OFFalse; }
114 
122  virtual void print(STD_NAMESPACE ostream&out,
123  const size_t flags = 0,
124  const int level = 0,
125  const char *pixelFileName = NULL,
126  size_t *pixelCounter = NULL);
127 
136  virtual OFCondition checkValue(const OFString &card = "1-n",
137  const OFBool oldFormat = OFFalse);
138 
142  virtual unsigned long getVM() { return 1L; }
143 
173  (const E_GrpLenEncoding glenc,
174  const E_PaddingEncoding padenc = EPD_noChange,
175  const E_TransferSyntax xfer = EXS_Unknown,
176  const E_EncodingType enctype = EET_ExplicitLength,
177  const Uint32 padlen = 0,
178  const Uint32 subPadlen = 0,
179  Uint32 instanceLength = 0);
180 
197  virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
198  const E_EncodingType enctype);
199 
212  virtual Uint32 getLength(const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
213  const E_EncodingType enctype = EET_UndefinedLength);
214 
218  virtual void transferInit();
219 
223  virtual void transferEnd();
224 
230  virtual OFBool canWriteXfer(const E_TransferSyntax oldXfer,
231  const E_TransferSyntax newXfer);
232 
246  virtual OFCondition read(DcmInputStream &inStream,
247  const E_TransferSyntax xfer,
248  const E_GrpLenEncoding glenc = EGL_noChange,
249  const Uint32 maxReadLength = DCM_MaxReadLength);
250 
258  virtual OFCondition write(DcmOutputStream &outStream,
259  const E_TransferSyntax oxfer,
260  const E_EncodingType enctype,
261  DcmWriteCache *wcache);
262 
268  virtual OFCondition writeXML(STD_NAMESPACE ostream&out,
269  const size_t flags = 0);
270 
279  const E_TransferSyntax oxfer,
280  const E_EncodingType enctype,
281  DcmWriteCache *wcache);
282 
286  virtual OFBool isSignable() const;
287 
291  virtual OFBool containsUnknownVR() const;
292 
298  virtual OFBool containsExtendedCharacters(const OFBool checkAllStrings = OFFalse);
299 
306  virtual OFBool isAffectedBySpecificCharacterSet() const;
307 
311  virtual unsigned long card();
312 
318  virtual OFCondition prepend(DcmItem *item);
319 
328  virtual OFCondition insert(DcmItem *item,
329  unsigned long where = DCM_EndOfListIndex,
330  OFBool before = OFFalse);
331 
337  virtual OFCondition append(DcmItem *item);
338 
346  virtual OFCondition insertAtCurrentPos(DcmItem *item,
347  OFBool before = OFFalse);
348 
354  virtual DcmItem *getItem(const unsigned long num);
355 
371  virtual OFCondition nextObject(DcmStack &stack, const OFBool intoSub);
372 
383  virtual DcmObject *nextInContainer(const DcmObject *obj);
384 
391  virtual DcmItem *remove(const unsigned long num);
392 
399  virtual DcmItem *remove(DcmItem *item);
400 
405  virtual OFBool isEmpty(const OFBool normalize = OFTrue);
406 
410  virtual OFCondition clear();
411 
416  virtual OFCondition verify(const OFBool autocorrect = OFFalse);
417 
439  virtual OFCondition search(const DcmTagKey &xtag, // in
440  DcmStack &resultStack, // inout
441  E_SearchMode mode = ESM_fromHere, // in
442  OFBool searchIntoSub = OFTrue); // in
443 
451  virtual OFCondition loadAllDataIntoMemory(void);
452 
470  virtual OFCondition getPartialValue(void *targetBuffer,
471  const Uint32 offset,
472  Uint32 numBytes,
473  DcmFileCache *cache = NULL,
474  E_ByteOrder byteOrder = gLocalByteOrder);
475 
476 protected:
477 
494  virtual OFCondition readTagAndLength(DcmInputStream &inStream, // inout
495  const E_TransferSyntax xfer, // in
496  DcmTag &tag, // out
497  Uint32 &length); // out
498 
506  virtual OFCondition makeSubObject(DcmObject *&subObject,
507  const DcmTag &newTag,
508  const Uint32 newLength);
509 
522  OFCondition readSubItem(DcmInputStream &inStream, // inout
523  const DcmTag &newTag, // in
524  const Uint32 newLength, // in
525  const E_TransferSyntax xfer, // in
526  const E_GrpLenEncoding glenc, // in
527  const Uint32 maxReadLength = DCM_MaxReadLength); // in
528 
537  virtual OFCondition searchSubFromHere(const DcmTagKey &tag, // in
538  DcmStack &resultStack, // inout
539  const OFBool searchIntoSub); // in
540 
543 
544 private:
545 
555  static OFCondition writeTagAndVR(DcmOutputStream &outStream,
556  const DcmTag &tag,
557  DcmEVR vr,
558  const E_TransferSyntax oxfer);
559 
565 
570  offile_off_t fStartPosition;
571 
575  OFBool readAsUN_;
576 
577 };
578 
579 
580 #endif // DCSEQUEN_H
581 
582 
583 /*
584 ** CVS/RCS Log:
585 ** $Log: dcsequen.h,v $
586 ** Revision 1.58 2010-11-05 09:34:11 joergr
587 ** Added support for checking the value multiplicity "9" (see Supplement 131).
588 **
589 ** Revision 1.57 2010-10-14 13:15:42 joergr
590 ** Updated copyright header. Added reference to COPYRIGHT file.
591 **
592 ** Revision 1.56 2010-04-23 15:28:02 joergr
593 ** Specify an appropriate default value for the "vm" parameter of checkValue().
594 **
595 ** Revision 1.55 2010-04-23 14:27:30 joergr
596 ** Added new method to all VR classes which checks whether the stored value
597 ** conforms to the VR definition and to the specified VM.
598 **
599 ** Revision 1.54 2010-03-01 09:08:44 uli
600 ** Removed some unnecessary include directives in the headers.
601 **
602 ** Revision 1.53 2010-02-22 11:39:54 uli
603 ** Remove some unneeded includes.
604 **
605 ** Revision 1.52 2009-08-07 14:40:39 joergr
606 ** Enhanced isEmpty() method by checking whether the data element value consists
607 ** of non-significant characters only.
608 **
609 ** Revision 1.51 2009-03-25 10:22:09 joergr
610 ** Added new method isEmpty() to DICOM object, item and sequence class.
611 **
612 ** Revision 1.50 2009-03-05 14:07:56 onken
613 ** Fixed typo.
614 **
615 ** Revision 1.49 2009-03-05 13:35:48 onken
616 ** Added checks for sequence and item lengths which prevents overflow in length
617 ** field, if total length of contained items (or sequences) exceeds
618 ** 32-bit length field. Also introduced new flag (default: enabled)
619 ** for writing in explicit length mode, which allows for automatically
620 ** switching encoding of only that very sequence/item to undefined
621 ** length coding (thus permitting to actually write the file).
622 **
623 ** Revision 1.48 2009-02-04 17:52:17 joergr
624 ** Fixes various type mismatches reported by MSVC introduced with OFFile class.
625 **
626 ** Revision 1.47 2008-12-12 11:44:40 onken
627 ** Moved path access functions to separate classes
628 **
629 ** Revision 1.46 2008-12-05 13:28:14 onken
630 ** Splitted findOrCreatePath() function API for also offering a simple API
631 ** for non-wildcard searches.
632 **
633 ** Revision 1.45 2008-12-04 16:55:14 onken
634 ** Changed findOrCreatePath() to also support wildcard as item numbers.
635 **
636 ** Revision 1.44 2008-10-15 12:31:20 onken
637 ** Added findOrCreatePath() functions which allow for finding or creating a
638 ** hierarchy of sequences, items and attributes according to a given "path"
639 ** string.
640 **
641 ** Revision 1.43 2008-07-17 11:19:49 onken
642 ** Updated copyFrom() documentation.
643 **
644 ** Revision 1.42 2008-07-17 10:36:56 onken
645 ** *** empty log message ***
646 **
647 ** Revision 1.41 2008-07-17 10:30:23 onken
648 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which
649 ** permits setting an instance's value from an existing object. Implemented
650 ** assignment operator where necessary.
651 **
652 ** Revision 1.40 2008-06-23 12:09:13 joergr
653 ** Fixed inconsistencies in Doxygen API documentation.
654 **
655 ** Revision 1.39 2007/11/29 14:30:19 meichel
656 ** Write methods now handle large raw data elements (such as pixel data)
657 ** without loading everything into memory. This allows very large images to
658 ** be sent over a network connection, or to be copied without ever being
659 ** fully in memory.
660 **
661 ** Revision 1.38 2007/06/29 14:17:49 meichel
662 ** Code clean-up: Most member variables in module dcmdata are now private,
663 ** not protected anymore.
664 **
665 ** Revision 1.37 2007/02/19 15:04:34 meichel
666 ** Removed searchErrors() methods that are not used anywhere and added
667 ** error() methods only in the DcmObject subclasses where really used.
668 **
669 ** Revision 1.36 2006/12/15 14:18:07 joergr
670 ** Added new method that checks whether a DICOM object or element is affected
671 ** by SpecificCharacterSet (0008,0005).
672 **
673 ** Revision 1.35 2006/12/13 13:58:15 joergr
674 ** Added new optional parameter "checkAllStrings" to method containsExtended
675 ** Characters().
676 **
677 ** Revision 1.34 2006/08/15 15:49:56 meichel
678 ** Updated all code in module dcmdata to correctly compile when
679 ** all standard C++ classes remain in namespace std.
680 **
681 ** Revision 1.33 2006/05/30 15:00:57 joergr
682 ** Added missing method containsExtendedCharacters().
683 **
684 ** Revision 1.32 2005/12/08 16:28:41 meichel
685 ** Changed include path schema for all DCMTK header files
686 **
687 ** Revision 1.31 2005/05/10 15:27:14 meichel
688 ** Added support for reading UN elements with undefined length according
689 ** to CP 246. The global flag dcmEnableCP246Support allows to revert to the
690 ** prior behaviour in which UN elements with undefined length were parsed
691 ** like a normal explicit VR SQ element.
692 **
693 ** Revision 1.30 2004/07/01 12:28:25 meichel
694 ** Introduced virtual clone method for DcmObject and derived classes.
695 **
696 ** Revision 1.29 2003/08/08 13:29:13 joergr
697 ** Added new method insertAtCurrentPos() which allows for a much more efficient
698 ** insertion (avoids re-searching for the correct position).
699 **
700 ** Revision 1.28 2002/12/06 12:49:13 joergr
701 ** Enhanced "print()" function by re-working the implementation and replacing
702 ** the boolean "showFullData" parameter by a more general integer flag.
703 ** Added doc++ documentation.
704 ** Made source code formatting more consistent with other modules/files.
705 **
706 ** Revision 1.27 2002/08/27 16:55:39 meichel
707 ** Initial release of new DICOM I/O stream classes that add support for stream
708 ** compression (deflated little endian explicit VR transfer syntax)
709 **
710 ** Revision 1.26 2002/04/25 09:43:56 joergr
711 ** Added support for XML output of DICOM objects.
712 **
713 ** Revision 1.25 2001/11/19 15:23:10 meichel
714 ** Cleaned up signature code to avoid some gcc warnings.
715 **
716 ** Revision 1.24 2001/11/16 15:54:39 meichel
717 ** Adapted digital signature code to final text of supplement 41.
718 **
719 ** Revision 1.23 2001/09/25 17:19:28 meichel
720 ** Adapted dcmdata to class OFCondition
721 **
722 ** Revision 1.22 2001/06/01 15:48:43 meichel
723 ** Updated copyright header
724 **
725 ** Revision 1.21 2000/11/07 16:56:09 meichel
726 ** Initial release of dcmsign module for DICOM Digital Signatures
727 **
728 ** Revision 1.20 2000/04/14 15:31:33 meichel
729 ** Removed default value from output stream passed to print() method.
730 ** Required for use in multi-thread environments.
731 **
732 ** Revision 1.19 2000/03/08 16:26:17 meichel
733 ** Updated copyright header.
734 **
735 ** Revision 1.18 2000/03/03 14:05:25 meichel
736 ** Implemented library support for redirecting error messages into memory
737 ** instead of printing them to stdout/stderr for GUI applications.
738 **
739 ** Revision 1.17 2000/02/10 10:50:53 joergr
740 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
741 ** pixel data/item value fields to raw files.
742 **
743 ** Revision 1.16 1999/03/31 09:24:46 meichel
744 ** Updated copyright header in module dcmdata
745 **
746 ** Revision 1.15 1998/11/12 16:47:44 meichel
747 ** Implemented operator= for all classes derived from DcmObject.
748 **
749 ** Revision 1.14 1998/07/15 15:48:52 joergr
750 ** Removed several compiler warnings reported by gcc 2.8.1 with
751 ** additional options, e.g. missing copy constructors and assignment
752 ** operators, initialization of member variables in the body of a
753 ** constructor instead of the member initialization list, hiding of
754 ** methods by use of identical names, uninitialized member variables,
755 ** missing const declaration of char pointers. Replaced tabs by spaces.
756 **
757 ** Revision 1.13 1997/07/21 08:25:10 andreas
758 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
759 ** with one unique boolean type OFBool.
760 **
761 ** Revision 1.12 1997/07/07 07:42:05 andreas
762 ** - Changed parameter type DcmTag & to DcmTagKey & in all search functions
763 ** in DcmItem, DcmSequenceOfItems, DcmDirectoryRecord and DcmObject
764 **
765 ** Revision 1.11 1997/05/27 13:48:29 andreas
766 ** - Add method canWriteXfer to class DcmObject and all derived classes.
767 ** This method checks whether it is possible to convert the original
768 ** transfer syntax to an new transfer syntax. The check is used in the
769 ** dcmconv utility to prohibit the change of a compressed transfer
770 ** syntax to a uncompressed.
771 **
772 ** Revision 1.10 1997/05/16 08:23:48 andreas
773 ** - Revised handling of GroupLength elements and support of
774 ** DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding
775 ** got additional enumeration values (for a description see dctypes.h).
776 ** addGroupLength and removeGroupLength methods are replaced by
777 ** computeGroupLengthAndPadding. To support Padding, the parameters of
778 ** element and sequence write functions changed.
779 ** - Added a new method calcElementLength to calculate the length of an
780 ** element, item or sequence. For elements it returns the length of
781 ** tag, length field, vr field, and value length, for item and
782 ** sequences it returns the length of the whole item. sequence including
783 ** the Delimitation tag (if appropriate). It can never return
784 ** UndefinedLength.
785 **
786 ** Revision 1.9 1997/04/24 12:09:02 hewett
787 ** Fixed DICOMDIR generation bug affecting ordering of
788 ** patient/study/series/image records (item insertion into a sequence
789 ** did produce the expected ordering).
790 **
791 ** Revision 1.8 1996/08/05 08:45:28 andreas
792 ** new print routine with additional parameters:
793 ** - print into files
794 ** - fix output length for elements
795 ** corrected error in search routine with parameter ESM_fromStackTop
796 **
797 ** Revision 1.7 1996/07/17 12:38:59 andreas
798 ** new nextObject to iterate a DicomDataset, DicomFileFormat, Item, ...
799 **
800 ** Revision 1.6 1996/01/29 13:38:14 andreas
801 ** - new put method for every VR to put value as a string
802 ** - better and unique print methods
803 **
804 ** Revision 1.5 1996/01/24 09:34:56 andreas
805 ** Support for 64 bit long
806 **
807 ** Revision 1.4 1996/01/09 11:06:16 andreas
808 ** New Support for Visual C++
809 ** Correct problems with inconsistent const declarations
810 **
811 ** Revision 1.3 1996/01/05 13:22:59 andreas
812 ** - changed to support new streaming facilities
813 ** - more cleanups
814 ** - merged read / write methods for block and file transfer
815 **
816 */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2