dcdicdir.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 DcmDicomDir
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:28:07 $
00026  *  Source File:      $Source: /share/dicom/cvs-depot/dcmtk/dcmdata/include/dcmtk/dcmdata/dcdicdir.h,v $
00027  *  CVS/RCS Revision: $Revision: 1.19 $
00028  *  Status:           $State: Exp $
00029  *
00030  *  CVS/RCS Log at end of file
00031  *
00032  */
00033 
00034 #ifndef DCDICDIR_H
00035 #define DCDICDIR_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/dctypes.h"
00041 #include "dcmtk/dcmdata/dcitem.h"
00042 #include "dcmtk/dcmdata/dcfilefo.h"
00043 #include "dcmtk/dcmdata/dcsequen.h"
00044 #include "dcmtk/dcmdata/dcdirrec.h"
00045 #include "dcmtk/dcmdata/dcvrulup.h"
00046 
00047 
00048 #define DEFAULT_DICOMDIR_NAME  "DICOMDIR"
00049 #define TEMPNAME_TEMPLATE      "DDXXXXXX"
00050 #define DICOMDIR_BACKUP_SUFFIX ".$$$"
00051 #define DICOMDIR_DEFAULT_TRANSFERSYNTAX  EXS_LittleEndianExplicit
00052 
00053 
00054 typedef struct
00055 {
00056     DcmItem *item;
00057     Uint32  fileOffset;
00058 } ItemOffset;
00059 
00060 
00061 class DcmDicomDir
00062 {
00063   private:
00064 
00065  // --- declarations to avoid compiler warnings
00066 
00067     DcmDicomDir &operator=(const DcmDicomDir &);
00068     DcmDicomDir( const DcmDicomDir &newDir );
00069 
00070   protected:
00071     OFCondition errorFlag;
00072     char * dicomDirFileName;
00073     OFBool modified;              // wird wo gebraucht ?
00074     OFBool mustCreateNewDir;
00075     DcmFileFormat * DirFile;
00076     DcmDirectoryRecord * RootRec;
00077     DcmSequenceOfItems * MRDRSeq;
00078 
00079     // Manipulation der internen Datenelemente:
00080     OFCondition createNewElements(const char* fileSetID);  // in
00081     DcmDataset& getDataset(void);
00082 
00083     // Seiteneffekt-freie Methoden zur Manipulation und Konversion:
00084     DcmSequenceOfItems&    getDirRecSeq(      DcmDataset &dset );   // inout
00085     DcmUnsignedLongOffset* lookForOffsetElem( DcmObject *obj,       // in
00086                                               const DcmTagKey &offsetTag );// in
00087     DcmDirectoryRecord*    recurseMatchFile(  DcmDirectoryRecord* startRec,// in
00088                                               char *filename );            // in
00089     DcmDirectoryRecord*    searchMatchFile(   DcmSequenceOfItems& recSeq,  // in
00090                                               char *filename );            // in
00091     OFCondition resolveGivenOffsets( DcmObject *startPoint,         // inout
00092                                      ItemOffset *itOffsets,         // in
00093                                      const unsigned long numOffsets,  // in
00094                                      const DcmTagKey &offsetTag );  // in
00095     OFCondition resolveAllOffsets(   DcmDataset &dset );            // inout
00096     OFCondition linkMRDRtoRecord(    DcmDirectoryRecord *dRec );    // inout
00097     OFCondition moveRecordToTree(    DcmDirectoryRecord *startRec,  // in
00098                                      DcmSequenceOfItems &fromDirSQ, // inout
00099                                      DcmDirectoryRecord *toRecord );// inout
00100     OFCondition moveMRDRbetweenSQs(  DcmSequenceOfItems &fromSQ,    // in
00101                                      DcmSequenceOfItems &toDirSQ ); // inout
00102     Uint32     lengthUntilSQ(       DcmDataset &dset,              // in
00103                                      E_TransferSyntax oxfer,        // in
00104                                      E_EncodingType enctype );      // in
00105     Uint32     lengthOfRecord(      DcmItem *item,                 // in
00106                                      E_TransferSyntax oxfer,        // in
00107                                      E_EncodingType enctype );      // in
00108     OFCondition convertGivenPointer( DcmObject *startPoint,         // inout
00109                                      ItemOffset *itOffsets,         // in
00110                                      const unsigned long numOffsets,  // in
00111                                      const DcmTagKey &offsetTag );  // in
00112     OFCondition convertAllPointer(   DcmDataset &dset,              // inout
00113                                      Uint32 beginOfFileSet,        // in
00114                                      E_TransferSyntax oxfer,        // in
00115                                      E_EncodingType enctype );      // in
00116     OFCondition copyRecordPtrToSQ(   DcmDirectoryRecord *record,    // in
00117                                      DcmSequenceOfItems &toDirSQ,   // inout
00118                                      DcmDirectoryRecord **firstRec, // out
00119                                      DcmDirectoryRecord **lastRec );// out
00120     OFCondition insertMediaSOPUID(   DcmMetaInfo &metaInfo );       // inout
00121     OFCondition countMRDRRefs(       DcmDirectoryRecord *startRec,  // in
00122                                      ItemOffset *refCounter,        // inout
00123                                      const unsigned long numCounters );   // in
00124     OFCondition checkMRDRRefCounter( DcmDirectoryRecord *startRec,  // in
00125                                      ItemOffset *refCounter,        // inout
00126                                      const unsigned long numCounters );    // in
00127 
00128     // komplette Reorganisation der verwalteten Directory Records (Seiteneffekt)
00129     OFCondition convertLinearToTree();
00130     OFCondition convertTreeToLinear( Uint32 beginOfFileSet,         // in
00131                                      E_TransferSyntax oxfer,        // in
00132                                      E_EncodingType enctype,        // in
00133                                      E_GrpLenEncoding glenc,        // in
00134                                      DcmSequenceOfItems &unresRecs);// inout
00135 
00136 public:
00137     DcmDicomDir();
00138     DcmDicomDir( const char *fileName,
00139                  const char *fileSetID = NULL );  // only used for new DICOMDIR
00140     virtual ~DcmDicomDir();
00141 
00142     virtual void print(ostream &out,
00143                        const size_t flags = 0,
00144                        const int level = 0,
00145                        const char *pixelFileName = NULL,
00146                        size_t *pixelCounter = NULL);
00147 
00148     virtual OFCondition         error();
00149     virtual DcmFileFormat&      getDirFileFormat();
00150     virtual const char*         getDirFileName();
00151     virtual DcmDirectoryRecord& getRootRecord();
00152     virtual DcmSequenceOfItems& getMRDRSequence();
00153     virtual DcmDirectoryRecord* matchFilename(     char *filename );
00154     virtual DcmDirectoryRecord* matchOrCreateMRDR( char *filename );
00155     virtual OFCondition         write(const E_TransferSyntax oxfer
00156                                             = DICOMDIR_DEFAULT_TRANSFERSYNTAX,
00157                                       const E_EncodingType enctype
00158                                             = EET_UndefinedLength,
00159                                       const E_GrpLenEncoding glenc
00160                                             = EGL_withoutGL );
00161 // PENDING: DICOM-konform, aber unvollstaendig
00162     virtual OFCondition         verify( OFBool autocorrect = OFFalse );
00163 };
00164 
00165 #endif // DCDICDIR_H
00166 
00167 /*
00168 ** CVS/RCS Log:
00169 ** $Log: dcdicdir.h,v $
00170 ** Revision 1.19  2005/12/08 16:28:07  meichel
00171 ** Changed include path schema for all DCMTK header files
00172 **
00173 ** Revision 1.18  2005/11/07 16:59:24  meichel
00174 ** Cleaned up some copy constructors in the DcmObject hierarchy.
00175 **
00176 ** Revision 1.17  2003/08/14 09:00:56  meichel
00177 ** Adapted type casts to new-style typecast operators defined in ofcast.h
00178 **
00179 ** Revision 1.16  2002/12/06 12:49:09  joergr
00180 ** Enhanced "print()" function by re-working the implementation and replacing
00181 ** the boolean "showFullData" parameter by a more general integer flag.
00182 ** Added doc++ documentation.
00183 ** Made source code formatting more consistent with other modules/files.
00184 **
00185 ** Revision 1.15  2001/09/25 17:19:25  meichel
00186 ** Adapted dcmdata to class OFCondition
00187 **
00188 ** Revision 1.14  2001/06/01 15:48:36  meichel
00189 ** Updated copyright header
00190 **
00191 ** Revision 1.13  2000/04/14 15:31:31  meichel
00192 ** Removed default value from output stream passed to print() method.
00193 **   Required for use in multi-thread environments.
00194 **
00195 ** Revision 1.12  2000/03/08 16:26:12  meichel
00196 ** Updated copyright header.
00197 **
00198 ** Revision 1.11  2000/03/03 14:05:23  meichel
00199 ** Implemented library support for redirecting error messages into memory
00200 **   instead of printing them to stdout/stderr for GUI applications.
00201 **
00202 ** Revision 1.10  2000/02/10 10:50:50  joergr
00203 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
00204 ** pixel data/item value fields to raw files.
00205 **
00206 ** Revision 1.9  1999/03/31 09:24:34  meichel
00207 ** Updated copyright header in module dcmdata
00208 **
00209 ** Revision 1.8  1998/07/15 15:48:44  joergr
00210 ** Removed several compiler warnings reported by gcc 2.8.1 with
00211 ** additional options, e.g. missing copy constructors and assignment
00212 ** operators, initialization of member variables in the body of a
00213 ** constructor instead of the member initialization list, hiding of
00214 ** methods by use of identical names, uninitialized member variables,
00215 ** missing const declaration of char pointers. Replaced tabs by spaces.
00216 **
00217 ** Revision 1.7  1997/09/11 15:02:16  hewett
00218 ** Changed DcmDicomDir constructor to take const char* arguments.
00219 **
00220 ** Revision 1.6  1997/07/21 08:25:06  andreas
00221 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
00222 **   with one unique boolean type OFBool.
00223 **
00224 ** Revision 1.5  1997/05/16 08:31:19  andreas
00225 ** - Revised handling of GroupLength elements and support of
00226 **   DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding
00227 **   got additional enumeration values (for a description see dctypes.h).
00228 **   addGroupLength and removeGroupLength methods are replaced by
00229 **   computeGroupLengthAndPadding. To support Padding, the parameters of
00230 **   element and sequence write functions changed.
00231 **
00232 ** Revision 1.4  1997/04/24 12:08:28  hewett
00233 ** Fixed DICOMDIR generation bug affecting inclusion of Group Length
00234 ** attributes (file offsets were not being computed correctly).
00235 **
00236 ** Revision 1.3  1996/08/05 08:45:18  andreas
00237 ** new print routine with additional parameters:
00238 **         - print into files
00239 **         - fix output length for elements
00240 ** corrected error in search routine with parameter ESM_fromStackTop
00241 **
00242 ** Revision 1.2  1996/01/05 13:22:54  andreas
00243 ** - changed to support new streaming facilities
00244 ** - more cleanups
00245 ** - merged read / write methods for block and file transfer
00246 **
00247 */
00248 


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