dcsequen.h

00001 /*
00002  *
00003  *  Copyright (C) 1994-2005, OFFIS
00004  *
00005  *  This software and supporting documentation were developed by
00006  *
00007  *    Kuratorium OFFIS e.V.
00008  *    Healthcare Information and Communication Systems
00009  *    Escherweg 2
00010  *    D-26121 Oldenburg, Germany
00011  *
00012  *  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  AND OFFIS MAKES NO  WARRANTY
00013  *  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE,  ITS  MERCHANTABILITY  OR
00014  *  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES  OR
00015  *  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
00016  *  PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
00017  *
00018  *  Module:  dcmdata
00019  *
00020  *  Author:  Gerd Ehlers, Andreas Barth
00021  *
00022  *  Purpose: Interface of class DcmSequenceOfItems
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:28:41 $
00026  *  Source File:      $Source: /share/dicom/cvs-depot/dcmtk/dcmdata/include/dcmtk/dcmdata/dcsequen.h,v $
00027  *  CVS/RCS Revision: $Revision: 1.32 $
00028  *  Status:           $State: Exp $
00029  *
00030  *  CVS/RCS Log at end of file
00031  *
00032  */
00033 
00034 #ifndef DCSEQUEN_H
00035 #define DCSEQUEN_H
00036 
00037 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00038 
00039 #include "dcmtk/ofstd/ofconsol.h"
00040 #include "dcmtk/dcmdata/dcerror.h"
00041 #include "dcmtk/dcmdata/dctypes.h"
00042 #include "dcmtk/dcmdata/dcobject.h"
00043 #include "dcmtk/dcmdata/dcitem.h"
00044 #include "dcmtk/dcmdata/dctag.h"
00045 #include "dcmtk/dcmdata/dclist.h"
00046 #include "dcmtk/dcmdata/dcstack.h"
00047 
00048 
00049 //
00050 // CLASS DcmSequenceOfItems
00051 // A sequence has no explicit value. Therefore, it should be derived from
00052 // DcmObject. Since a sequence is created in an (pseudo)-item and items collect
00053 // sequences of elements the sequence Tag is derived from element.
00054 
00055 class DcmSequenceOfItems : public DcmElement
00056 {
00057 protected:
00058     DcmList *itemList;
00059     OFBool lastItemComplete;
00060     Uint32 fStartPosition;
00061 
00062     virtual OFCondition readTagAndLength(DcmInputStream &inStream,            // inout
00063                                          const E_TransferSyntax xfer,         // in
00064                                          DcmTag &tag,                         // out
00065                                          Uint32 &length);                     // out
00066 
00067     virtual OFCondition makeSubObject(DcmObject *&subObject,
00068                                       const DcmTag &mewTag,
00069                                       const Uint32 newLength);
00070 
00071     OFCondition readSubItem(DcmInputStream &inStream,                         // inout
00072                             const DcmTag &newTag,                             // in
00073                             const Uint32 newLength,                           // in
00074                             const E_TransferSyntax xfer,                      // in
00075                             const E_GrpLenEncoding glenc,                     // in
00076                             const Uint32 maxReadLength = DCM_MaxReadLength);  // in
00077 
00078     virtual OFCondition searchSubFromHere(const DcmTagKey &tag,               // in
00079                                           DcmStack &resultStack,              // inout
00080                                           const OFBool searchIntoSub);        // in
00081 
00082 
00083 public:
00084     DcmSequenceOfItems(const DcmTag &tag, const Uint32 len = 0, OFBool readAsUN = OFFalse);
00085     DcmSequenceOfItems(const DcmSequenceOfItems& oldSeq);
00086     virtual ~DcmSequenceOfItems();
00087 
00088     DcmSequenceOfItems &operator=(const DcmSequenceOfItems &obj);
00089 
00093     virtual DcmObject *clone() const
00094     {
00095       return new DcmSequenceOfItems(*this);
00096     }
00097 
00098     virtual DcmEVR ident() const { return EVR_SQ; }
00099     virtual OFBool isLeaf() const { return OFFalse; }
00100 
00101     virtual void print(ostream &out,
00102                        const size_t flags = 0,
00103                        const int level = 0,
00104                        const char *pixelFileName = NULL,
00105                        size_t *pixelCounter = NULL);
00106 
00107     virtual unsigned long getVM() { return 1L; }
00108 
00109     virtual OFCondition computeGroupLengthAndPadding
00110                             (const E_GrpLenEncoding glenc,
00111                              const E_PaddingEncoding padenc = EPD_noChange,
00112                              const E_TransferSyntax xfer = EXS_Unknown,
00113                              const E_EncodingType enctype = EET_ExplicitLength,
00114                              const Uint32 padlen = 0,
00115                              const Uint32 subPadlen = 0,
00116                              Uint32 instanceLength = 0);
00117 
00118     virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
00119                                      const E_EncodingType enctype);
00120 
00121     virtual Uint32 getLength(const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00122                              const E_EncodingType enctype = EET_UndefinedLength);
00123 
00124     virtual void transferInit();
00125     virtual void transferEnd();
00126 
00127     virtual OFBool canWriteXfer(const E_TransferSyntax oldXfer,
00128                                 const E_TransferSyntax newXfer);
00129 
00130     virtual OFCondition read(DcmInputStream &inStream,
00131                              const E_TransferSyntax xfer,
00132                              const E_GrpLenEncoding glenc = EGL_noChange,
00133                              const Uint32 maxReadLength = DCM_MaxReadLength);
00134 
00135     virtual OFCondition write(DcmOutputStream &outStream,
00136                               const E_TransferSyntax oxfer,
00137                               const E_EncodingType enctype = EET_UndefinedLength);
00138 
00144     virtual OFCondition writeXML(ostream &out,
00145                                  const size_t flags = 0);
00146 
00149     virtual OFCondition writeSignatureFormat(DcmOutputStream &outStream,
00150                                              const E_TransferSyntax oxfer,
00151                                              const E_EncodingType enctype = EET_UndefinedLength);
00152 
00156     virtual OFBool isSignable() const;
00157 
00161     virtual OFBool containsUnknownVR() const;
00162 
00163     virtual unsigned long card();
00164 
00165     virtual OFCondition prepend(DcmItem *item);
00166     virtual OFCondition insert(DcmItem *item,
00167                                unsigned long where = DCM_EndOfListIndex,
00168                                OFBool before = OFFalse);
00169     virtual OFCondition append(DcmItem *item);
00170 
00178     virtual OFCondition insertAtCurrentPos(DcmItem *item,
00179                                            OFBool before = OFFalse);
00180 
00181     virtual DcmItem *getItem(const unsigned long num);
00182     virtual OFCondition nextObject(DcmStack &stack, const OFBool intoSub);
00183     virtual DcmObject *nextInContainer(const DcmObject *obj);
00184     virtual DcmItem *remove(const unsigned long num);
00185     virtual DcmItem *remove(DcmItem *item);
00186     virtual OFCondition clear();
00187     virtual OFCondition verify(const OFBool autocorrect = OFFalse);
00188     virtual OFCondition search(const DcmTagKey &xtag,             // in
00189                                DcmStack &resultStack,             // inout
00190                                E_SearchMode mode = ESM_fromHere,  // in
00191                                OFBool searchIntoSub = OFTrue);    // in
00192     virtual OFCondition searchErrors(DcmStack &resultStack);      // inout
00193     virtual OFCondition loadAllDataIntoMemory(void);
00194 
00195 private:
00196 
00197   /* static helper method used in writeSignatureFormat().
00198    * This function resembles DcmObject::writeTagAndLength()
00199    * but only writes the tag, VR and reserved field.
00200    * @param outStream stream to write to
00201    * @param tag attribute tag
00202    * @param vr attribute VR as reported by getVR
00203    * @param oxfer output transfer syntax
00204    * @return EC_Normal if successful, an error code otherwise
00205    */
00206   static OFCondition writeTagAndVR(DcmOutputStream &outStream,
00207                                    const DcmTag &tag,
00208                                    DcmEVR vr,
00209                                    const E_TransferSyntax oxfer);
00210 
00214   OFBool readAsUN_;
00215 
00216 };
00217 
00218 
00219 #endif // DCSEQUEN_H
00220 
00221 
00222 /*
00223 ** CVS/RCS Log:
00224 ** $Log: dcsequen.h,v $
00225 ** Revision 1.32  2005/12/08 16:28:41  meichel
00226 ** Changed include path schema for all DCMTK header files
00227 **
00228 ** Revision 1.31  2005/05/10 15:27:14  meichel
00229 ** Added support for reading UN elements with undefined length according
00230 **   to CP 246. The global flag dcmEnableCP246Support allows to revert to the
00231 **   prior behaviour in which UN elements with undefined length were parsed
00232 **   like a normal explicit VR SQ element.
00233 **
00234 ** Revision 1.30  2004/07/01 12:28:25  meichel
00235 ** Introduced virtual clone method for DcmObject and derived classes.
00236 **
00237 ** Revision 1.29  2003/08/08 13:29:13  joergr
00238 ** Added new method insertAtCurrentPos() which allows for a much more efficient
00239 ** insertion (avoids re-searching for the correct position).
00240 **
00241 ** Revision 1.28  2002/12/06 12:49:13  joergr
00242 ** Enhanced "print()" function by re-working the implementation and replacing
00243 ** the boolean "showFullData" parameter by a more general integer flag.
00244 ** Added doc++ documentation.
00245 ** Made source code formatting more consistent with other modules/files.
00246 **
00247 ** Revision 1.27  2002/08/27 16:55:39  meichel
00248 ** Initial release of new DICOM I/O stream classes that add support for stream
00249 **   compression (deflated little endian explicit VR transfer syntax)
00250 **
00251 ** Revision 1.26  2002/04/25 09:43:56  joergr
00252 ** Added support for XML output of DICOM objects.
00253 **
00254 ** Revision 1.25  2001/11/19 15:23:10  meichel
00255 ** Cleaned up signature code to avoid some gcc warnings.
00256 **
00257 ** Revision 1.24  2001/11/16 15:54:39  meichel
00258 ** Adapted digital signature code to final text of supplement 41.
00259 **
00260 ** Revision 1.23  2001/09/25 17:19:28  meichel
00261 ** Adapted dcmdata to class OFCondition
00262 **
00263 ** Revision 1.22  2001/06/01 15:48:43  meichel
00264 ** Updated copyright header
00265 **
00266 ** Revision 1.21  2000/11/07 16:56:09  meichel
00267 ** Initial release of dcmsign module for DICOM Digital Signatures
00268 **
00269 ** Revision 1.20  2000/04/14 15:31:33  meichel
00270 ** Removed default value from output stream passed to print() method.
00271 **   Required for use in multi-thread environments.
00272 **
00273 ** Revision 1.19  2000/03/08 16:26:17  meichel
00274 ** Updated copyright header.
00275 **
00276 ** Revision 1.18  2000/03/03 14:05:25  meichel
00277 ** Implemented library support for redirecting error messages into memory
00278 **   instead of printing them to stdout/stderr for GUI applications.
00279 **
00280 ** Revision 1.17  2000/02/10 10:50:53  joergr
00281 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
00282 ** pixel data/item value fields to raw files.
00283 **
00284 ** Revision 1.16  1999/03/31 09:24:46  meichel
00285 ** Updated copyright header in module dcmdata
00286 **
00287 ** Revision 1.15  1998/11/12 16:47:44  meichel
00288 ** Implemented operator= for all classes derived from DcmObject.
00289 **
00290 ** Revision 1.14  1998/07/15 15:48:52  joergr
00291 ** Removed several compiler warnings reported by gcc 2.8.1 with
00292 ** additional options, e.g. missing copy constructors and assignment
00293 ** operators, initialization of member variables in the body of a
00294 ** constructor instead of the member initialization list, hiding of
00295 ** methods by use of identical names, uninitialized member variables,
00296 ** missing const declaration of char pointers. Replaced tabs by spaces.
00297 **
00298 ** Revision 1.13  1997/07/21 08:25:10  andreas
00299 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
00300 **   with one unique boolean type OFBool.
00301 **
00302 ** Revision 1.12  1997/07/07 07:42:05  andreas
00303 ** - Changed parameter type DcmTag & to DcmTagKey & in all search functions
00304 **   in DcmItem, DcmSequenceOfItems, DcmDirectoryRecord and DcmObject
00305 **
00306 ** Revision 1.11  1997/05/27 13:48:29  andreas
00307 ** - Add method canWriteXfer to class DcmObject and all derived classes.
00308 **   This method checks whether it is possible to convert the original
00309 **   transfer syntax to an new transfer syntax. The check is used in the
00310 **   dcmconv utility to prohibit the change of a compressed transfer
00311 **   syntax to a uncompressed.
00312 **
00313 ** Revision 1.10  1997/05/16 08:23:48  andreas
00314 ** - Revised handling of GroupLength elements and support of
00315 **   DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding
00316 **   got additional enumeration values (for a description see dctypes.h).
00317 **   addGroupLength and removeGroupLength methods are replaced by
00318 **   computeGroupLengthAndPadding. To support Padding, the parameters of
00319 **   element and sequence write functions changed.
00320 ** - Added a new method calcElementLength to calculate the length of an
00321 **   element, item or sequence. For elements it returns the length of
00322 **   tag, length field, vr field, and value length, for item and
00323 **   sequences it returns the length of the whole item. sequence including
00324 **   the Delimitation tag (if appropriate).  It can never return
00325 **   UndefinedLength.
00326 **
00327 ** Revision 1.9  1997/04/24 12:09:02  hewett
00328 ** Fixed DICOMDIR generation bug affecting ordering of
00329 ** patient/study/series/image records (item insertion into a sequence
00330 ** did produce the expected ordering).
00331 **
00332 ** Revision 1.8  1996/08/05 08:45:28  andreas
00333 ** new print routine with additional parameters:
00334 **         - print into files
00335 **         - fix output length for elements
00336 ** corrected error in search routine with parameter ESM_fromStackTop
00337 **
00338 ** Revision 1.7  1996/07/17 12:38:59  andreas
00339 ** new nextObject to iterate a DicomDataset, DicomFileFormat, Item, ...
00340 **
00341 ** Revision 1.6  1996/01/29 13:38:14  andreas
00342 ** - new put method for every VR to put value as a string
00343 ** - better and unique print methods
00344 **
00345 ** Revision 1.5  1996/01/24 09:34:56  andreas
00346 ** Support for 64 bit long
00347 **
00348 ** Revision 1.4  1996/01/09 11:06:16  andreas
00349 ** New Support for Visual C++
00350 ** Correct problems with inconsistent const declarations
00351 **
00352 ** Revision 1.3  1996/01/05 13:22:59  andreas
00353 ** - changed to support new streaming facilities
00354 ** - more cleanups
00355 ** - merged read / write methods for block and file transfer
00356 **
00357 */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5