dcmdata/include/dcmtk/dcmdata/dcsequen.h

00001 /*
00002  *
00003  *  Copyright (C) 1994-2010, OFFIS e.V.
00004  *  All rights reserved.  See COPYRIGHT file for details.
00005  *
00006  *  This software and supporting documentation were developed by
00007  *
00008  *    OFFIS e.V.
00009  *    R&D Division Health
00010  *    Escherweg 2
00011  *    D-26121 Oldenburg, Germany
00012  *
00013  *
00014  *  Module:  dcmdata
00015  *
00016  *  Author:  Gerd Ehlers, Andreas Barth
00017  *
00018  *  Purpose: Interface of class DcmSequenceOfItems
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-11-05 09:34:11 $
00022  *  CVS/RCS Revision: $Revision: 1.58 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 
00030 #ifndef DCSEQUEN_H
00031 #define DCSEQUEN_H
00032 
00033 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00034 
00035 #include "dcmtk/ofstd/offile.h"       /* for offile_off_t */
00036 #include "dcmtk/dcmdata/dcelem.h"
00037 #include "dcmtk/dcmdata/dctag.h"
00038 #include "dcmtk/dcmdata/dclist.h"
00039 #include "dcmtk/dcmdata/dcstack.h"
00040 
00047 class DcmSequenceOfItems : public DcmElement
00048 {
00049 public:
00050 
00057     DcmSequenceOfItems(const DcmTag &tag,
00058                        const Uint32 len = 0,
00059                        OFBool readAsUN = OFFalse);
00060 
00064     DcmSequenceOfItems(const DcmSequenceOfItems& oldSeq);
00065 
00067     virtual ~DcmSequenceOfItems();
00068 
00072     DcmSequenceOfItems &operator=(const DcmSequenceOfItems &obj);
00073 
00075     inline OFCondition error() const { return errorFlag; }
00076 
00080     virtual DcmObject *clone() const
00081     {
00082       return new DcmSequenceOfItems(*this);
00083     }
00084 
00097     virtual OFCondition copyFrom(const DcmObject& rhs);
00098 
00105     virtual DcmEVR ident() const { return EVR_SQ; }
00106 
00113     virtual OFBool isLeaf() const { return OFFalse; }
00114 
00122     virtual void print(STD_NAMESPACE ostream&out,
00123                        const size_t flags = 0,
00124                        const int level = 0,
00125                        const char *pixelFileName = NULL,
00126                        size_t *pixelCounter = NULL);
00127 
00136     virtual OFCondition checkValue(const OFString &card = "1-n",
00137                                    const OFBool oldFormat = OFFalse);
00138 
00142     virtual unsigned long getVM() { return 1L; }
00143 
00172     virtual OFCondition computeGroupLengthAndPadding
00173                             (const E_GrpLenEncoding glenc,
00174                              const E_PaddingEncoding padenc = EPD_noChange,
00175                              const E_TransferSyntax xfer = EXS_Unknown,
00176                              const E_EncodingType enctype = EET_ExplicitLength,
00177                              const Uint32 padlen = 0,
00178                              const Uint32 subPadlen = 0,
00179                              Uint32 instanceLength = 0);
00180 
00197     virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
00198                                      const E_EncodingType enctype);
00199 
00212     virtual Uint32 getLength(const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00213                              const E_EncodingType enctype = EET_UndefinedLength);
00214 
00218     virtual void transferInit();
00219 
00223     virtual void transferEnd();
00224 
00230     virtual OFBool canWriteXfer(const E_TransferSyntax oldXfer,
00231                                 const E_TransferSyntax newXfer);
00232 
00246     virtual OFCondition read(DcmInputStream &inStream,
00247                              const E_TransferSyntax xfer,
00248                              const E_GrpLenEncoding glenc = EGL_noChange,
00249                              const Uint32 maxReadLength = DCM_MaxReadLength);
00250 
00258     virtual OFCondition write(DcmOutputStream &outStream,
00259                               const E_TransferSyntax oxfer,
00260                               const E_EncodingType enctype,
00261                               DcmWriteCache *wcache);
00262 
00268     virtual OFCondition writeXML(STD_NAMESPACE ostream&out,
00269                                  const size_t flags = 0);
00270 
00278     virtual OFCondition writeSignatureFormat(DcmOutputStream &outStream,
00279                                              const E_TransferSyntax oxfer,
00280                                              const E_EncodingType enctype,
00281                                              DcmWriteCache *wcache);
00282 
00286     virtual OFBool isSignable() const;
00287 
00291     virtual OFBool containsUnknownVR() const;
00292 
00298     virtual OFBool containsExtendedCharacters(const OFBool checkAllStrings = OFFalse);
00299 
00306     virtual OFBool isAffectedBySpecificCharacterSet() const;
00307 
00311     virtual unsigned long card();
00312 
00318     virtual OFCondition prepend(DcmItem *item);
00319 
00328     virtual OFCondition insert(DcmItem *item,
00329                                unsigned long where = DCM_EndOfListIndex,
00330                                OFBool before = OFFalse);
00331 
00337     virtual OFCondition append(DcmItem *item);
00338 
00346     virtual OFCondition insertAtCurrentPos(DcmItem *item,
00347                                            OFBool before = OFFalse);
00348 
00354     virtual DcmItem *getItem(const unsigned long num);
00355 
00371     virtual OFCondition nextObject(DcmStack &stack, const OFBool intoSub);
00372 
00383     virtual DcmObject *nextInContainer(const DcmObject *obj);
00384 
00391     virtual DcmItem *remove(const unsigned long num);
00392 
00399     virtual DcmItem *remove(DcmItem *item);
00400 
00405     virtual OFBool isEmpty(const OFBool normalize = OFTrue);
00406 
00410     virtual OFCondition clear();
00411 
00416     virtual OFCondition verify(const OFBool autocorrect = OFFalse);
00417 
00439     virtual OFCondition search(const DcmTagKey &xtag,             // in
00440                                DcmStack &resultStack,             // inout
00441                                E_SearchMode mode = ESM_fromHere,  // in
00442                                OFBool searchIntoSub = OFTrue);    // in
00443 
00451     virtual OFCondition loadAllDataIntoMemory(void);
00452 
00470     virtual OFCondition getPartialValue(void *targetBuffer,
00471                                         const Uint32 offset,
00472                                         Uint32 numBytes,
00473                                         DcmFileCache *cache = NULL,
00474                                         E_ByteOrder byteOrder = gLocalByteOrder);
00475 
00476 protected:
00477 
00494     virtual OFCondition readTagAndLength(DcmInputStream &inStream,            // inout
00495                                          const E_TransferSyntax xfer,         // in
00496                                          DcmTag &tag,                         // out
00497                                          Uint32 &length);                     // out
00498 
00506     virtual OFCondition makeSubObject(DcmObject *&subObject,
00507                                       const DcmTag &newTag,
00508                                       const Uint32 newLength);
00509 
00522     OFCondition readSubItem(DcmInputStream &inStream,                         // inout
00523                             const DcmTag &newTag,                             // in
00524                             const Uint32 newLength,                           // in
00525                             const E_TransferSyntax xfer,                      // in
00526                             const E_GrpLenEncoding glenc,                     // in
00527                             const Uint32 maxReadLength = DCM_MaxReadLength);  // in
00528 
00537     virtual OFCondition searchSubFromHere(const DcmTagKey &tag,               // in
00538                                           DcmStack &resultStack,              // inout
00539                                           const OFBool searchIntoSub);        // in
00540 
00542     DcmList *itemList;
00543 
00544 private:
00545 
00555     static OFCondition writeTagAndVR(DcmOutputStream &outStream,
00556                                      const DcmTag &tag,
00557                                      DcmEVR vr,
00558                                      const E_TransferSyntax oxfer);
00559 
00564     OFBool lastItemComplete;
00565 
00570     offile_off_t fStartPosition;
00571 
00575     OFBool readAsUN_;
00576 
00577 };
00578 
00579 
00580 #endif // DCSEQUEN_H
00581 
00582 
00583 /*
00584 ** CVS/RCS Log:
00585 ** $Log: dcsequen.h,v $
00586 ** Revision 1.58  2010-11-05 09:34:11  joergr
00587 ** Added support for checking the value multiplicity "9" (see Supplement 131).
00588 **
00589 ** Revision 1.57  2010-10-14 13:15:42  joergr
00590 ** Updated copyright header. Added reference to COPYRIGHT file.
00591 **
00592 ** Revision 1.56  2010-04-23 15:28:02  joergr
00593 ** Specify an appropriate default value for the "vm" parameter of checkValue().
00594 **
00595 ** Revision 1.55  2010-04-23 14:27:30  joergr
00596 ** Added new method to all VR classes which checks whether the stored value
00597 ** conforms to the VR definition and to the specified VM.
00598 **
00599 ** Revision 1.54  2010-03-01 09:08:44  uli
00600 ** Removed some unnecessary include directives in the headers.
00601 **
00602 ** Revision 1.53  2010-02-22 11:39:54  uli
00603 ** Remove some unneeded includes.
00604 **
00605 ** Revision 1.52  2009-08-07 14:40:39  joergr
00606 ** Enhanced isEmpty() method by checking whether the data element value consists
00607 ** of non-significant characters only.
00608 **
00609 ** Revision 1.51  2009-03-25 10:22:09  joergr
00610 ** Added new method isEmpty() to DICOM object, item and sequence class.
00611 **
00612 ** Revision 1.50  2009-03-05 14:07:56  onken
00613 ** Fixed typo.
00614 **
00615 ** Revision 1.49  2009-03-05 13:35:48  onken
00616 ** Added checks for sequence and item lengths which prevents overflow in length
00617 ** field, if total length of contained items (or sequences) exceeds
00618 ** 32-bit length field. Also introduced new flag (default: enabled)
00619 ** for writing in explicit length mode, which allows for automatically
00620 ** switching encoding of only that very sequence/item to undefined
00621 ** length coding (thus permitting to actually write the file).
00622 **
00623 ** Revision 1.48  2009-02-04 17:52:17  joergr
00624 ** Fixes various type mismatches reported by MSVC introduced with OFFile class.
00625 **
00626 ** Revision 1.47  2008-12-12 11:44:40  onken
00627 ** Moved path access functions to separate classes
00628 **
00629 ** Revision 1.46  2008-12-05 13:28:14  onken
00630 ** Splitted findOrCreatePath() function API for also offering a simple API
00631 ** for non-wildcard searches.
00632 **
00633 ** Revision 1.45  2008-12-04 16:55:14  onken
00634 ** Changed findOrCreatePath() to also support wildcard as item numbers.
00635 **
00636 ** Revision 1.44  2008-10-15 12:31:20  onken
00637 ** Added findOrCreatePath() functions which allow for finding or creating a
00638 ** hierarchy of sequences, items and attributes according to a given "path"
00639 ** string.
00640 **
00641 ** Revision 1.43  2008-07-17 11:19:49  onken
00642 ** Updated copyFrom() documentation.
00643 **
00644 ** Revision 1.42  2008-07-17 10:36:56  onken
00645 ** *** empty log message ***
00646 **
00647 ** Revision 1.41  2008-07-17 10:30:23  onken
00648 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which
00649 ** permits setting an instance's value from an existing object. Implemented
00650 ** assignment operator where necessary.
00651 **
00652 ** Revision 1.40  2008-06-23 12:09:13  joergr
00653 ** Fixed inconsistencies in Doxygen API documentation.
00654 **
00655 ** Revision 1.39  2007/11/29 14:30:19  meichel
00656 ** Write methods now handle large raw data elements (such as pixel data)
00657 **   without loading everything into memory. This allows very large images to
00658 **   be sent over a network connection, or to be copied without ever being
00659 **   fully in memory.
00660 **
00661 ** Revision 1.38  2007/06/29 14:17:49  meichel
00662 ** Code clean-up: Most member variables in module dcmdata are now private,
00663 **   not protected anymore.
00664 **
00665 ** Revision 1.37  2007/02/19 15:04:34  meichel
00666 ** Removed searchErrors() methods that are not used anywhere and added
00667 **   error() methods only in the DcmObject subclasses where really used.
00668 **
00669 ** Revision 1.36  2006/12/15 14:18:07  joergr
00670 ** Added new method that checks whether a DICOM object or element is affected
00671 ** by SpecificCharacterSet (0008,0005).
00672 **
00673 ** Revision 1.35  2006/12/13 13:58:15  joergr
00674 ** Added new optional parameter "checkAllStrings" to method containsExtended
00675 ** Characters().
00676 **
00677 ** Revision 1.34  2006/08/15 15:49:56  meichel
00678 ** Updated all code in module dcmdata to correctly compile when
00679 **   all standard C++ classes remain in namespace std.
00680 **
00681 ** Revision 1.33  2006/05/30 15:00:57  joergr
00682 ** Added missing method containsExtendedCharacters().
00683 **
00684 ** Revision 1.32  2005/12/08 16:28:41  meichel
00685 ** Changed include path schema for all DCMTK header files
00686 **
00687 ** Revision 1.31  2005/05/10 15:27:14  meichel
00688 ** Added support for reading UN elements with undefined length according
00689 **   to CP 246. The global flag dcmEnableCP246Support allows to revert to the
00690 **   prior behaviour in which UN elements with undefined length were parsed
00691 **   like a normal explicit VR SQ element.
00692 **
00693 ** Revision 1.30  2004/07/01 12:28:25  meichel
00694 ** Introduced virtual clone method for DcmObject and derived classes.
00695 **
00696 ** Revision 1.29  2003/08/08 13:29:13  joergr
00697 ** Added new method insertAtCurrentPos() which allows for a much more efficient
00698 ** insertion (avoids re-searching for the correct position).
00699 **
00700 ** Revision 1.28  2002/12/06 12:49:13  joergr
00701 ** Enhanced "print()" function by re-working the implementation and replacing
00702 ** the boolean "showFullData" parameter by a more general integer flag.
00703 ** Added doc++ documentation.
00704 ** Made source code formatting more consistent with other modules/files.
00705 **
00706 ** Revision 1.27  2002/08/27 16:55:39  meichel
00707 ** Initial release of new DICOM I/O stream classes that add support for stream
00708 **   compression (deflated little endian explicit VR transfer syntax)
00709 **
00710 ** Revision 1.26  2002/04/25 09:43:56  joergr
00711 ** Added support for XML output of DICOM objects.
00712 **
00713 ** Revision 1.25  2001/11/19 15:23:10  meichel
00714 ** Cleaned up signature code to avoid some gcc warnings.
00715 **
00716 ** Revision 1.24  2001/11/16 15:54:39  meichel
00717 ** Adapted digital signature code to final text of supplement 41.
00718 **
00719 ** Revision 1.23  2001/09/25 17:19:28  meichel
00720 ** Adapted dcmdata to class OFCondition
00721 **
00722 ** Revision 1.22  2001/06/01 15:48:43  meichel
00723 ** Updated copyright header
00724 **
00725 ** Revision 1.21  2000/11/07 16:56:09  meichel
00726 ** Initial release of dcmsign module for DICOM Digital Signatures
00727 **
00728 ** Revision 1.20  2000/04/14 15:31:33  meichel
00729 ** Removed default value from output stream passed to print() method.
00730 **   Required for use in multi-thread environments.
00731 **
00732 ** Revision 1.19  2000/03/08 16:26:17  meichel
00733 ** Updated copyright header.
00734 **
00735 ** Revision 1.18  2000/03/03 14:05:25  meichel
00736 ** Implemented library support for redirecting error messages into memory
00737 **   instead of printing them to stdout/stderr for GUI applications.
00738 **
00739 ** Revision 1.17  2000/02/10 10:50:53  joergr
00740 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
00741 ** pixel data/item value fields to raw files.
00742 **
00743 ** Revision 1.16  1999/03/31 09:24:46  meichel
00744 ** Updated copyright header in module dcmdata
00745 **
00746 ** Revision 1.15  1998/11/12 16:47:44  meichel
00747 ** Implemented operator= for all classes derived from DcmObject.
00748 **
00749 ** Revision 1.14  1998/07/15 15:48:52  joergr
00750 ** Removed several compiler warnings reported by gcc 2.8.1 with
00751 ** additional options, e.g. missing copy constructors and assignment
00752 ** operators, initialization of member variables in the body of a
00753 ** constructor instead of the member initialization list, hiding of
00754 ** methods by use of identical names, uninitialized member variables,
00755 ** missing const declaration of char pointers. Replaced tabs by spaces.
00756 **
00757 ** Revision 1.13  1997/07/21 08:25:10  andreas
00758 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
00759 **   with one unique boolean type OFBool.
00760 **
00761 ** Revision 1.12  1997/07/07 07:42:05  andreas
00762 ** - Changed parameter type DcmTag & to DcmTagKey & in all search functions
00763 **   in DcmItem, DcmSequenceOfItems, DcmDirectoryRecord and DcmObject
00764 **
00765 ** Revision 1.11  1997/05/27 13:48:29  andreas
00766 ** - Add method canWriteXfer to class DcmObject and all derived classes.
00767 **   This method checks whether it is possible to convert the original
00768 **   transfer syntax to an new transfer syntax. The check is used in the
00769 **   dcmconv utility to prohibit the change of a compressed transfer
00770 **   syntax to a uncompressed.
00771 **
00772 ** Revision 1.10  1997/05/16 08:23:48  andreas
00773 ** - Revised handling of GroupLength elements and support of
00774 **   DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding
00775 **   got additional enumeration values (for a description see dctypes.h).
00776 **   addGroupLength and removeGroupLength methods are replaced by
00777 **   computeGroupLengthAndPadding. To support Padding, the parameters of
00778 **   element and sequence write functions changed.
00779 ** - Added a new method calcElementLength to calculate the length of an
00780 **   element, item or sequence. For elements it returns the length of
00781 **   tag, length field, vr field, and value length, for item and
00782 **   sequences it returns the length of the whole item. sequence including
00783 **   the Delimitation tag (if appropriate).  It can never return
00784 **   UndefinedLength.
00785 **
00786 ** Revision 1.9  1997/04/24 12:09:02  hewett
00787 ** Fixed DICOMDIR generation bug affecting ordering of
00788 ** patient/study/series/image records (item insertion into a sequence
00789 ** did produce the expected ordering).
00790 **
00791 ** Revision 1.8  1996/08/05 08:45:28  andreas
00792 ** new print routine with additional parameters:
00793 **         - print into files
00794 **         - fix output length for elements
00795 ** corrected error in search routine with parameter ESM_fromStackTop
00796 **
00797 ** Revision 1.7  1996/07/17 12:38:59  andreas
00798 ** new nextObject to iterate a DicomDataset, DicomFileFormat, Item, ...
00799 **
00800 ** Revision 1.6  1996/01/29 13:38:14  andreas
00801 ** - new put method for every VR to put value as a string
00802 ** - better and unique print methods
00803 **
00804 ** Revision 1.5  1996/01/24 09:34:56  andreas
00805 ** Support for 64 bit long
00806 **
00807 ** Revision 1.4  1996/01/09 11:06:16  andreas
00808 ** New Support for Visual C++
00809 ** Correct problems with inconsistent const declarations
00810 **
00811 ** Revision 1.3  1996/01/05 13:22:59  andreas
00812 ** - changed to support new streaming facilities
00813 ** - more cleanups
00814 ** - merged read / write methods for block and file transfer
00815 **
00816 */


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1