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