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 DcmDirectoryRecord 00023 * 00024 * Last Update: $Author: meichel $ 00025 * Update Date: $Date: 2005/12/08 16:28:10 $ 00026 * CVS/RCS Revision: $Revision: 1.29 $ 00027 * Status: $State: Exp $ 00028 * 00029 * CVS/RCS Log at end of file 00030 * 00031 */ 00032 00033 #ifndef DCDIRREC_H 00034 #define DCDIRREC_H 00035 00036 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00037 00038 #include "dcmtk/ofstd/ofconsol.h" 00039 #include "dcmtk/dcmdata/dcerror.h" 00040 #include "dcmtk/dcmdata/dctypes.h" 00041 #include "dcmtk/dcmdata/dcitem.h" 00042 #include "dcmtk/dcmdata/dcsequen.h" 00043 #include "dcmtk/dcmdata/dcfilefo.h" 00044 00045 00046 typedef enum { 00047 ERT_root = 0, 00048 ERT_Curve = 1, 00049 ERT_FilmBox = 2, 00050 ERT_FilmSession = 3, 00051 ERT_Image = 4, 00052 ERT_ImageBox = 5, 00053 ERT_Interpretation = 6, 00054 ERT_ModalityLut = 7, 00055 ERT_Mrdr = 8, 00056 ERT_Overlay = 9, 00057 ERT_Patient = 10, 00058 ERT_PrintQueue = 11, 00059 ERT_Private = 12, 00060 ERT_Results = 13, 00061 ERT_Series = 14, 00062 ERT_Study = 15, 00063 ERT_StudyComponent = 16, 00064 ERT_Topic = 17, 00065 ERT_Visit = 18, 00066 ERT_VoiLut = 19, 00067 ERT_StructReport = 20, 00068 ERT_Presentation = 21, 00069 ERT_Waveform = 22, 00070 ERT_RTDose = 23, 00071 ERT_RTStructureSet = 24, 00072 ERT_RTPlan = 25, 00073 ERT_RTTreatRecord = 26, 00074 ERT_StoredPrint = 27, 00075 ERT_KeyObjectDoc = 28, 00076 ERT_Registration = 29, 00077 ERT_Fiducial = 30, 00078 ERT_RawData = 31, 00079 ERT_Spectroscopy = 32, 00080 ERT_EncapDoc = 33, 00081 ERT_ValueMap = 34, 00082 ERT_HangingProtocol = 35 00083 } E_DirRecType; 00084 00085 00086 class DcmDicomDir; 00087 00088 00089 class DcmDirectoryRecord : public DcmItem 00090 { 00091 00092 friend class DcmDicomDir; 00093 00094 private: 00095 char *recordsOriginFile; 00096 00097 // --- declarations to avoid compiler warnings 00098 00099 DcmDirectoryRecord &operator=(const DcmDirectoryRecord &); 00100 00101 protected: 00102 DcmSequenceOfItems *lowerLevelList; 00103 E_DirRecType DirRecordType; 00104 DcmDirectoryRecord *referencedMRDR; 00105 Uint32 numberOfReferences; 00106 Uint32 offsetInFile; 00107 00108 // side-effect-free conversion routines: 00109 E_DirRecType recordNameToType(const char *recordTypeName); 00110 char* buildFileName(const char *origName, char *destName); 00111 OFCondition checkHierarchy(const E_DirRecType upperRecord, 00112 const E_DirRecType lowerRecord); 00113 00114 // access to data elements within the Directory Records: 00115 OFCondition setRecordType(E_DirRecType newType); 00116 E_DirRecType lookForRecordType(); 00117 OFCondition setReferencedFileID( const char *referencedFileID); 00118 const char* lookForReferencedFileID(); 00119 DcmDirectoryRecord* lookForReferencedMRDR(); 00120 const char* getReferencedFileName(); // local or in MRDR 00121 OFCondition setRecordInUseFlag(const Uint16 newFlag); 00122 Uint16 lookForRecordInUseFlag(); 00123 Uint32 getFileOffset(); 00124 Uint32 setFileOffset(Uint32 position); 00125 00126 00127 // access to MRDR data element: 00128 OFCondition setNumberOfReferences(Uint32 newRefNum); 00129 Uint32 lookForNumberOfReferences(); 00130 Uint32 increaseRefNum(); 00131 Uint32 decreaseRefNum(); 00132 00133 // misc: 00134 OFCondition fillElementsAndReadSOP(const char *referencedFileID, 00135 const char *sourceFileName); 00136 OFCondition masterInsertSub(DcmDirectoryRecord *dirRec, 00137 const unsigned long where = DCM_EndOfListIndex); 00138 OFCondition purgeReferencedFile(); 00139 00140 public: 00141 DcmDirectoryRecord(); 00142 DcmDirectoryRecord(const DcmTag &tag, 00143 const Uint32 len); 00144 DcmDirectoryRecord(const E_DirRecType recordType, 00145 const char *referencedFileID, // DICOM format with '\\' 00146 const char *sourceFileName); // OS Format 00147 00148 DcmDirectoryRecord(const char *recordTypeName, 00149 const char *referencedFileID, // DICOM Format with '\\' 00150 const char *sourceFileName); // OS Format 00151 00152 DcmDirectoryRecord(const DcmDirectoryRecord &oldDirRec); 00153 virtual ~DcmDirectoryRecord(); 00154 00158 virtual DcmObject *clone() const 00159 { 00160 return new DcmDirectoryRecord(*this); 00161 } 00162 00163 virtual DcmEVR ident() const; 00164 00165 virtual void print(ostream &out, 00166 const size_t flags = 0, 00167 const int level = 0, 00168 const char *pixelFileName = NULL, 00169 size_t *pixelCounter = NULL); 00170 00171 virtual OFCondition read(DcmInputStream & inStream, 00172 const E_TransferSyntax xfer, 00173 const E_GrpLenEncoding glenc = EGL_noChange, 00174 const Uint32 maxReadLength = DCM_MaxReadLength); 00175 00176 virtual OFCondition verify(const OFBool autocorrect = OFFalse); 00177 virtual OFCondition search(const DcmTagKey &xtag, // in 00178 DcmStack &resultStack, // inout 00179 E_SearchMode mode = ESM_fromHere, // in 00180 OFBool searchIntoSub = OFTrue); // in 00181 virtual OFCondition searchErrors(DcmStack &resultStack); // inout 00182 00183 virtual E_DirRecType getRecordType(); 00184 virtual DcmDirectoryRecord* getReferencedMRDR(); 00185 virtual OFCondition assignToMRDR(DcmDirectoryRecord *mrdr ); // in 00186 virtual OFCondition assignToSOPFile(const char *referencedFileID, 00187 const char *sourceFileName); 00188 00189 // manipulation of the lower-level Directory Entities: 00190 virtual unsigned long cardSub(); 00191 00192 virtual OFCondition insertSub(DcmDirectoryRecord* dirRec, 00193 unsigned long where = DCM_EndOfListIndex, 00194 OFBool before = OFFalse); 00195 00203 virtual OFCondition insertSubAtCurrentPos(DcmDirectoryRecord *dirRec, 00204 OFBool before = OFFalse); 00205 00206 virtual DcmDirectoryRecord* getSub(const unsigned long num); 00207 00212 virtual DcmDirectoryRecord* nextSub(const DcmDirectoryRecord *dirRec); 00213 00214 virtual DcmDirectoryRecord* removeSub(const unsigned long num); 00215 virtual DcmDirectoryRecord* removeSub(DcmDirectoryRecord *dirRec); 00216 virtual OFCondition deleteSubAndPurgeFile(const unsigned long num); 00217 virtual OFCondition deleteSubAndPurgeFile(DcmDirectoryRecord *dirRec); 00218 virtual OFCondition clearSub(); 00219 00220 // note the records origin file 00221 virtual void setRecordsOriginFile(const char *fname); 00222 virtual const char* getRecordsOriginFile(); 00223 00224 }; 00225 00226 00227 #endif // DCDIRREC_H 00228 00229 00230 /* 00231 ** CVS/RCS Log: 00232 ** $Log: dcdirrec.h,v $ 00233 ** Revision 1.29 2005/12/08 16:28:10 meichel 00234 ** Changed include path schema for all DCMTK header files 00235 ** 00236 ** Revision 1.28 2005/10/27 13:30:20 joergr 00237 ** Added support for Encapsulated Document, Real World Value Mapping and 00238 ** Hanging Protocol objects to DICOMDIR tools. 00239 ** 00240 ** Revision 1.27 2004/07/01 12:28:25 meichel 00241 ** Introduced virtual clone method for DcmObject and derived classes. 00242 ** 00243 ** Revision 1.26 2004/02/13 17:36:46 joergr 00244 ** Added support for new directory records RAW DATA and SPECTROSCOPY introduced 00245 ** with CP 343. 00246 ** 00247 ** Revision 1.25 2004/02/13 14:10:57 joergr 00248 ** Added support for new directory records REGISTRATION and FIDUCIAL introduced 00249 ** with supplement 73 (Spatial Registration Storage SOP Classes). 00250 ** 00251 ** Revision 1.24 2003/08/08 14:14:04 joergr 00252 ** Translated remaining German comments. 00253 ** 00254 ** Revision 1.23 2003/08/08 14:04:16 joergr 00255 ** Added two new methods insertSubAtCurrentPos() and nextSub() which allow for 00256 ** a much more efficient insertion (avoids re-searching for correct position). 00257 ** 00258 ** Revision 1.22 2002/12/06 12:49:09 joergr 00259 ** Enhanced "print()" function by re-working the implementation and replacing 00260 ** the boolean "showFullData" parameter by a more general integer flag. 00261 ** Added doc++ documentation. 00262 ** Made source code formatting more consistent with other modules/files. 00263 ** 00264 ** Revision 1.21 2002/08/27 16:55:31 meichel 00265 ** Initial release of new DICOM I/O stream classes that add support for stream 00266 ** compression (deflated little endian explicit VR transfer syntax) 00267 ** 00268 ** Revision 1.20 2001/09/25 17:19:25 meichel 00269 ** Adapted dcmdata to class OFCondition 00270 ** 00271 ** Revision 1.19 2001/06/20 14:59:15 joergr 00272 ** Added support for new SOP class Key Object Selection Document (suppl. 59). 00273 ** 00274 ** Revision 1.18 2001/06/01 15:48:39 meichel 00275 ** Updated copyright header 00276 ** 00277 ** Revision 1.17 2000/12/14 12:47:20 joergr 00278 ** Updated for 2000 edition of the DICOM standard (added: SR, PR, WV, SP, RT). 00279 ** 00280 ** Revision 1.16 2000/04/14 16:02:23 meichel 00281 ** Removed default value from output stream passed to print() method. 00282 ** Required for use in multi-thread environments. 00283 ** 00284 ** Revision 1.15 2000/03/08 16:26:14 meichel 00285 ** Updated copyright header. 00286 ** 00287 ** Revision 1.14 2000/03/03 14:05:23 meichel 00288 ** Implemented library support for redirecting error messages into memory 00289 ** instead of printing them to stdout/stderr for GUI applications. 00290 ** 00291 ** Revision 1.13 2000/02/10 10:50:50 joergr 00292 ** Added new feature to dcmdump (enhanced print method of dcmdata): write 00293 ** pixel data/item value fields to raw files. 00294 ** 00295 ** Revision 1.12 1999/03/31 09:24:36 meichel 00296 ** Updated copyright header in module dcmdata 00297 ** 00298 ** Revision 1.11 1999/03/22 14:10:57 meichel 00299 ** Added support for Structured Reports to dcmgpdir. 00300 ** Added preliminary support for including sequences into a DICOMDIR. 00301 ** 00302 ** Revision 1.10 1998/07/15 15:48:46 joergr 00303 ** Removed several compiler warnings reported by gcc 2.8.1 with 00304 ** additional options, e.g. missing copy constructors and assignment 00305 ** operators, initialization of member variables in the body of a 00306 ** constructor instead of the member initialization list, hiding of 00307 ** methods by use of identical names, uninitialized member variables, 00308 ** missing const declaration of char pointers. Replaced tabs by spaces. 00309 ** 00310 ** Revision 1.9 1997/07/21 08:00:45 andreas 00311 ** - Corrected error in DcmDirectoryRecord::write since this routine can 00312 ** change the length of the record after this is calculated in the 00313 ** sequence. 00314 ** - DcmDirectoryRecord can be build with a referenced Name and a source 00315 ** filename. These name now can differ (lower case - upper case 00316 ** characters). 00317 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL) 00318 ** with one unique boolean type OFBool. 00319 ** 00320 ** Revision 1.8 1997/07/07 07:42:04 andreas 00321 ** - Changed parameter type DcmTag & to DcmTagKey & in all search functions 00322 ** in DcmItem, DcmSequenceOfItems, DcmDirectoryRecord and DcmObject 00323 ** 00324 ** Revision 1.7 1997/05/16 08:31:21 andreas 00325 ** - Revised handling of GroupLength elements and support of 00326 ** DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding 00327 ** got additional enumeration values (for a description see dctypes.h). 00328 ** addGroupLength and removeGroupLength methods are replaced by 00329 ** computeGroupLengthAndPadding. To support Padding, the parameters of 00330 ** element and sequence write functions changed. 00331 ** 00332 ** Revision 1.6 1997/05/09 13:12:02 hewett 00333 ** Added a member variable and associated get/set methods to DcmDirectoryRecord 00334 ** to allow the origin of a directory record to be noted. 00335 ** 00336 ** Revision 1.5 1997/05/06 09:22:35 hewett 00337 ** Added a "before" flag to the insertion of items for compatibility with 00338 ** insertion in normal Sequences. 00339 ** 00340 ** Revision 1.4 1997/03/26 16:56:25 hewett 00341 ** Removed the DcmDirectoryRecord member function fillTypeElements since it 00342 ** did nothing useful. Smoothed out some poor indentation. 00343 ** 00344 ** Revision 1.3 1996/08/05 08:45:20 andreas 00345 ** new print routine with additional parameters: 00346 ** - print into files 00347 ** - fix output length for elements 00348 ** corrected error in search routine with parameter ESM_fromStackTop 00349 ** 00350 ** Revision 1.2 1996/01/05 13:22:54 andreas 00351 ** - changed to support new streaming facilities 00352 ** - more cleanups 00353 ** - merged read / write methods for block and file transfer 00354 ** 00355 */