dcmdata/include/dcmtk/dcmdata/dcdirrec.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 DcmDirectoryRecord
00019  *
00020  *  Last Update:      $Author: uli $
00021  *  Update Date:      $Date: 2010-11-15 13:58:43 $
00022  *  CVS/RCS Revision: $Revision: 1.47 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 #ifndef DCDIRREC_H
00030 #define DCDIRREC_H
00031 
00032 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00033 
00034 #include "dcmtk/dcmdata/dcitem.h"
00035 #include "dcmtk/dcmdata/dcsequen.h"
00036 #include "dcmtk/dcmdata/dcfilefo.h"
00037 
00038 
00040 typedef enum {
00042     ERT_root = 0,
00044     ERT_Curve = 1,
00046     ERT_FilmBox = 2,
00048     ERT_FilmSession = 3,
00050     ERT_Image = 4,
00052     ERT_ImageBox = 5,
00054     ERT_Interpretation = 6,
00056     ERT_ModalityLut = 7,
00058     ERT_Mrdr = 8,
00060     ERT_Overlay = 9,
00062     ERT_Patient = 10,
00064     ERT_PrintQueue = 11,
00066     ERT_Private = 12,
00068     ERT_Results = 13,
00070     ERT_Series = 14,
00072     ERT_Study = 15,
00074     ERT_StudyComponent = 16,
00076     ERT_Topic = 17,
00078     ERT_Visit = 18,
00080     ERT_VoiLut = 19,
00082     ERT_SRDocument = 20,
00084     ERT_Presentation = 21,
00086     ERT_Waveform = 22,
00088     ERT_RTDose = 23,
00090     ERT_RTStructureSet = 24,
00092     ERT_RTPlan = 25,
00094     ERT_RTTreatRecord = 26,
00096     ERT_StoredPrint = 27,
00098     ERT_KeyObjectDoc = 28,
00100     ERT_Registration = 29,
00102     ERT_Fiducial = 30,
00104     ERT_RawData = 31,
00106     ERT_Spectroscopy = 32,
00108     ERT_EncapDoc = 33,
00110     ERT_ValueMap = 34,
00112     ERT_HangingProtocol = 35,
00114     ERT_Stereometric = 36,
00116     ERT_HL7StrucDoc = 37,
00118     ERT_Palette = 38,
00120     ERT_Surface = 39,
00122     ERT_Measurement = 40,
00124     ERT_Implant = 41,
00126     ERT_ImplantGroup = 42,
00128     ERT_ImplantAssy = 43
00129 } E_DirRecType;
00130 
00131 
00132 class DcmDicomDir;
00133 
00136 class DcmDirectoryRecord : public DcmItem
00137 {
00138 
00139     friend class DcmDicomDir;
00140 
00141 public:
00143     DcmDirectoryRecord();
00144 
00149     DcmDirectoryRecord(const DcmTag &tag,
00150                        const Uint32 len);
00151 
00157     DcmDirectoryRecord(const E_DirRecType recordType,
00158                        const char *referencedFileID,   // DICOM format with '\\'
00159                        const char *sourceFileName);    // OS Format
00160 
00166     DcmDirectoryRecord(const char *recordTypeName,
00167                        const char *referencedFileID,   // DICOM Format with '\\'
00168                        const char *sourceFileName);    // OS Format
00169 
00173     DcmDirectoryRecord(const DcmDirectoryRecord &oldDirRec);
00174 
00178     DcmDirectoryRecord &operator=(const DcmDirectoryRecord &obj);
00179 
00181     virtual ~DcmDirectoryRecord();
00182 
00186     virtual DcmObject *clone() const
00187     {
00188       return new DcmDirectoryRecord(*this);
00189     }
00190 
00203     virtual OFCondition copyFrom(const DcmObject& rhs);
00204 
00211     virtual DcmEVR ident() const;
00212 
00214     inline OFCondition error() const { return errorFlag; }
00215 
00223     virtual void print(STD_NAMESPACE ostream&out,
00224                        const size_t flags = 0,
00225                        const int level = 0,
00226                        const char *pixelFileName = NULL,
00227                        size_t *pixelCounter = NULL);
00228 
00229 
00243     virtual OFCondition read(DcmInputStream & inStream,
00244                              const E_TransferSyntax xfer,
00245                              const E_GrpLenEncoding glenc = EGL_noChange,
00246                              const Uint32 maxReadLength = DCM_MaxReadLength);
00247 
00253     virtual OFCondition writeXML(STD_NAMESPACE ostream&out,
00254                                  const size_t flags = 0);
00255 
00256 
00261     virtual OFCondition verify(const OFBool autocorrect = OFFalse);
00262 
00284     virtual OFCondition search(const DcmTagKey &xtag,               // in
00285                                DcmStack &resultStack,               // inout
00286                                E_SearchMode mode = ESM_fromHere,    // in
00287                                OFBool searchIntoSub = OFTrue);      // in
00288 
00290     virtual E_DirRecType getRecordType();
00291 
00296     virtual DcmDirectoryRecord* getReferencedMRDR();
00297 
00302     virtual OFCondition assignToMRDR(DcmDirectoryRecord *mrdr );    // in
00303 
00312     virtual OFCondition assignToSOPFile(const char *referencedFileID,
00313                                         const char *sourceFileName);
00314 
00316     virtual unsigned long cardSub();
00317 
00324     virtual OFCondition insertSub(DcmDirectoryRecord* dirRec,
00325                                   unsigned long where = DCM_EndOfListIndex,
00326                                   OFBool before = OFFalse);
00327 
00335     virtual OFCondition insertSubAtCurrentPos(DcmDirectoryRecord *dirRec,
00336                                               OFBool before = OFFalse);
00337 
00343     virtual DcmDirectoryRecord* getSub(const unsigned long num);
00344 
00349     virtual DcmDirectoryRecord* nextSub(const DcmDirectoryRecord *dirRec);
00350 
00357     virtual DcmDirectoryRecord* removeSub(const unsigned long num);
00358 
00365     virtual DcmDirectoryRecord* removeSub(DcmDirectoryRecord *dirRec);
00366 
00371     virtual OFCondition deleteSubAndPurgeFile(const unsigned long num);
00372 
00377     virtual OFCondition deleteSubAndPurgeFile(DcmDirectoryRecord *dirRec);
00378 
00380     virtual OFCondition clearSub();
00381 
00385     virtual void setRecordsOriginFile(const char *fname);
00386 
00388     virtual const char* getRecordsOriginFile();
00389 
00391     Uint32 getFileOffset() const;
00392 
00393 protected:
00394 
00395     // side-effect-free conversion routines:
00396     E_DirRecType        recordNameToType(const char *recordTypeName);
00397     char*               buildFileName(const char *origName, char *destName);
00398     OFCondition         checkHierarchy(const E_DirRecType upperRecord,
00399                                        const E_DirRecType lowerRecord);
00400 
00401     // access to data elements within the Directory Records:
00402     OFCondition         setRecordType(E_DirRecType newType);
00403     E_DirRecType        lookForRecordType();
00404     OFCondition         setReferencedFileID( const char *referencedFileID);
00405     const char*         lookForReferencedFileID();
00406     DcmDirectoryRecord* lookForReferencedMRDR();
00407     const char*         getReferencedFileName();      // local or in MRDR
00408     OFCondition         setRecordInUseFlag(const Uint16 newFlag);
00409     Uint16              lookForRecordInUseFlag();
00410     Uint32              setFileOffset(Uint32 position);
00411 
00412 
00413     // access to MRDR data element:
00414     OFCondition         setNumberOfReferences(Uint32 newRefNum);
00415     Uint32              lookForNumberOfReferences();
00416     Uint32              increaseRefNum();
00417     Uint32              decreaseRefNum();
00418 
00419     // misc:
00420     OFCondition         fillElementsAndReadSOP(const char *referencedFileID,
00421                                                const char *sourceFileName);
00422     OFCondition         masterInsertSub(DcmDirectoryRecord *dirRec,
00423                                         const unsigned long where = DCM_EndOfListIndex);
00424     OFCondition         purgeReferencedFile();
00425 
00426 private:
00427 
00429     char *recordsOriginFile;
00430 
00432     DcmSequenceOfItems *lowerLevelList;
00433 
00435     E_DirRecType DirRecordType;
00436 
00438     DcmDirectoryRecord *referencedMRDR;
00439 
00441     Uint32 numberOfReferences;
00442 
00444     Uint32 offsetInFile;
00445 
00446 };
00447 
00448 
00449 #endif // DCDIRREC_H
00450 
00451 
00452 /*
00453 ** CVS/RCS Log:
00454 ** $Log: dcdirrec.h,v $
00455 ** Revision 1.47  2010-11-15 13:58:43  uli
00456 ** Fixed some errors in doxygen comments.
00457 **
00458 ** Revision 1.46  2010-11-05 13:11:11  joergr
00459 ** Added support for new directory record types IMPLANT, IMPLANT GROUP and
00460 ** IMPLANT ASSY from Supplement 131 (Implant Templates).
00461 **
00462 ** Revision 1.45  2010-10-14 13:15:40  joergr
00463 ** Updated copyright header. Added reference to COPYRIGHT file.
00464 **
00465 ** Revision 1.44  2010-10-01 08:06:16  joergr
00466 ** Added new directory record type MEASUREMENT from Supplement 144.
00467 **
00468 ** Revision 1.43  2010-09-30 16:43:18  joergr
00469 ** Added new directory record types HL7 STRUC DOC, PALETTE and SURFACE.
00470 **
00471 ** Revision 1.42  2010-03-01 09:08:44  uli
00472 ** Removed some unnecessary include directives in the headers.
00473 **
00474 ** Revision 1.41  2010-02-22 11:39:53  uli
00475 ** Remove some unneeded includes.
00476 **
00477 ** Revision 1.40  2008-07-17 11:19:48  onken
00478 ** Updated copyFrom() documentation.
00479 **
00480 ** Revision 1.39  2008-07-17 10:30:23  onken
00481 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which
00482 ** permits setting an instance's value from an existing object. Implemented
00483 ** assignment operator where necessary.
00484 **
00485 ** Revision 1.38  2008-06-03 13:41:40  meichel
00486 ** DcmDirectoryRecord::getFileOffset() is now const and public.
00487 **
00488 ** Revision 1.37  2007/11/29 14:30:35  meichel
00489 ** Updated doxygen API documentation
00490 **
00491 ** Revision 1.36  2007/06/29 14:17:49  meichel
00492 ** Code clean-up: Most member variables in module dcmdata are now private,
00493 **   not protected anymore.
00494 **
00495 ** Revision 1.35  2007/02/19 15:04:34  meichel
00496 ** Removed searchErrors() methods that are not used anywhere and added
00497 **   error() methods only in the DcmObject subclasses where really used.
00498 **
00499 ** Revision 1.34  2006/08/16 09:41:26  joergr
00500 ** Added missing CVS log entry.
00501 **
00502 ** Revision 1.33  2006/08/15 15:49:56  meichel
00503 ** Updated all code in module dcmdata to correctly compile when
00504 **   all standard C++ classes remain in namespace std.
00505 **
00506 ** Revision 1.32  2006/07/27 13:05:05  joergr
00507 ** Added support for DICOMDIR record type "STEREOMETRIC" (CP 628).
00508 ** Renamed ERT_StructReport to ERT_SRDocument.
00509 **
00510 ** Revision 1.31  2006/05/11 17:48:53  joergr
00511 ** Fixed wrong CVS log entry.
00512 **
00513 ** Revision 1.30  2006/05/11 08:53:36  joergr
00514 ** Added "offset" attribute to DICOMDIR record items.
00515 **
00516 ** Revision 1.29  2005/12/08 16:28:10  meichel
00517 ** Changed include path schema for all DCMTK header files
00518 **
00519 ** Revision 1.28  2005/10/27 13:30:20  joergr
00520 ** Added support for Encapsulated Document, Real World Value Mapping and
00521 ** Hanging Protocol objects to DICOMDIR tools.
00522 **
00523 ** Revision 1.27  2004/07/01 12:28:25  meichel
00524 ** Introduced virtual clone method for DcmObject and derived classes.
00525 **
00526 ** Revision 1.26  2004/02/13 17:36:46  joergr
00527 ** Added support for new directory records RAW DATA and SPECTROSCOPY introduced
00528 ** with CP 343.
00529 **
00530 ** Revision 1.25  2004/02/13 14:10:57  joergr
00531 ** Added support for new directory records REGISTRATION and FIDUCIAL introduced
00532 ** with supplement 73 (Spatial Registration Storage SOP Classes).
00533 **
00534 ** Revision 1.24  2003/08/08 14:14:04  joergr
00535 ** Translated remaining German comments.
00536 **
00537 ** Revision 1.23  2003/08/08 14:04:16  joergr
00538 ** Added two new methods insertSubAtCurrentPos() and nextSub() which allow for
00539 ** a much more efficient insertion (avoids re-searching for correct position).
00540 **
00541 ** Revision 1.22  2002/12/06 12:49:09  joergr
00542 ** Enhanced "print()" function by re-working the implementation and replacing
00543 ** the boolean "showFullData" parameter by a more general integer flag.
00544 ** Added doc++ documentation.
00545 ** Made source code formatting more consistent with other modules/files.
00546 **
00547 ** Revision 1.21  2002/08/27 16:55:31  meichel
00548 ** Initial release of new DICOM I/O stream classes that add support for stream
00549 **   compression (deflated little endian explicit VR transfer syntax)
00550 **
00551 ** Revision 1.20  2001/09/25 17:19:25  meichel
00552 ** Adapted dcmdata to class OFCondition
00553 **
00554 ** Revision 1.19  2001/06/20 14:59:15  joergr
00555 ** Added support for new SOP class Key Object Selection Document (suppl. 59).
00556 **
00557 ** Revision 1.18  2001/06/01 15:48:39  meichel
00558 ** Updated copyright header
00559 **
00560 ** Revision 1.17  2000/12/14 12:47:20  joergr
00561 ** Updated for 2000 edition of the DICOM standard (added: SR, PR, WV, SP, RT).
00562 **
00563 ** Revision 1.16  2000/04/14 16:02:23  meichel
00564 ** Removed default value from output stream passed to print() method.
00565 **   Required for use in multi-thread environments.
00566 **
00567 ** Revision 1.15  2000/03/08 16:26:14  meichel
00568 ** Updated copyright header.
00569 **
00570 ** Revision 1.14  2000/03/03 14:05:23  meichel
00571 ** Implemented library support for redirecting error messages into memory
00572 **   instead of printing them to stdout/stderr for GUI applications.
00573 **
00574 ** Revision 1.13  2000/02/10 10:50:50  joergr
00575 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
00576 ** pixel data/item value fields to raw files.
00577 **
00578 ** Revision 1.12  1999/03/31 09:24:36  meichel
00579 ** Updated copyright header in module dcmdata
00580 **
00581 ** Revision 1.11  1999/03/22 14:10:57  meichel
00582 ** Added support for Structured Reports to dcmgpdir.
00583 **   Added preliminary support for including sequences into a DICOMDIR.
00584 **
00585 ** Revision 1.10  1998/07/15 15:48:46  joergr
00586 ** Removed several compiler warnings reported by gcc 2.8.1 with
00587 ** additional options, e.g. missing copy constructors and assignment
00588 ** operators, initialization of member variables in the body of a
00589 ** constructor instead of the member initialization list, hiding of
00590 ** methods by use of identical names, uninitialized member variables,
00591 ** missing const declaration of char pointers. Replaced tabs by spaces.
00592 **
00593 ** Revision 1.9  1997/07/21 08:00:45  andreas
00594 ** - Corrected error in DcmDirectoryRecord::write since this routine can
00595 **   change the length of the record after this is calculated in the
00596 **   sequence.
00597 ** - DcmDirectoryRecord can be build with a referenced Name and a source
00598 **   filename. These name now can differ (lower case - upper case
00599 **   characters).
00600 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
00601 **   with one unique boolean type OFBool.
00602 **
00603 ** Revision 1.8  1997/07/07 07:42:04  andreas
00604 ** - Changed parameter type DcmTag & to DcmTagKey & in all search functions
00605 **   in DcmItem, DcmSequenceOfItems, DcmDirectoryRecord and DcmObject
00606 **
00607 ** Revision 1.7  1997/05/16 08:31:21  andreas
00608 ** - Revised handling of GroupLength elements and support of
00609 **   DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding
00610 **   got additional enumeration values (for a description see dctypes.h).
00611 **   addGroupLength and removeGroupLength methods are replaced by
00612 **   computeGroupLengthAndPadding. To support Padding, the parameters of
00613 **   element and sequence write functions changed.
00614 **
00615 ** Revision 1.6  1997/05/09 13:12:02  hewett
00616 ** Added a member variable and associated get/set methods to DcmDirectoryRecord
00617 ** to allow the origin of a directory record to be noted.
00618 **
00619 ** Revision 1.5  1997/05/06 09:22:35  hewett
00620 ** Added a "before" flag to the insertion of items for compatibility with
00621 ** insertion in normal Sequences.
00622 **
00623 ** Revision 1.4  1997/03/26 16:56:25  hewett
00624 ** Removed the DcmDirectoryRecord member function fillTypeElements since it
00625 ** did nothing useful.  Smoothed out some poor indentation.
00626 **
00627 ** Revision 1.3  1996/08/05 08:45:20  andreas
00628 ** new print routine with additional parameters:
00629 **         - print into files
00630 **         - fix output length for elements
00631 ** corrected error in search routine with parameter ESM_fromStackTop
00632 **
00633 ** Revision 1.2  1996/01/05 13:22:54  andreas
00634 ** - changed to support new streaming facilities
00635 ** - more cleanups
00636 ** - merged read / write methods for block and file transfer
00637 **
00638 */


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