dcmdata/include/dcmtk/dcmdata/dcfilefo.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 DcmFileFormat
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-20 16:34:08 $
00022  *  CVS/RCS Revision: $Revision: 1.38 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 
00030 #ifndef DCFILEFO_H
00031 #define DCFILEFO_H
00032 
00033 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00034 
00035 #include "dcmtk/dcmdata/dcsequen.h"
00036 #include "dcmtk/dcmdata/dcdatset.h"
00037 
00038 
00039 // forward declarations
00040 class DcmMetaInfo;
00041 class DcmInputStream;
00042 class DcmOutputStream;
00043 class DcmRepresentationParameter;
00044 
00045 
00048 class DcmFileFormat
00049   : public DcmSequenceOfItems
00050 {
00051 
00052  public:
00053 
00056     DcmFileFormat();
00057 
00061     DcmFileFormat(DcmDataset *dataset);
00062 
00066     DcmFileFormat(const DcmFileFormat &old);
00067 
00070     virtual ~DcmFileFormat();
00071 
00076     DcmFileFormat &operator=(const DcmFileFormat &obj);
00077 
00081     virtual DcmObject *clone() const
00082     {
00083       return new DcmFileFormat(*this);
00084     }
00085 
00098     virtual OFCondition copyFrom(const DcmObject& rhs);
00099 
00103     virtual DcmEVR ident() const;
00104 
00108     virtual OFCondition clear();
00109 
00113     virtual void removeInvalidGroups();
00114 
00122     virtual void print(STD_NAMESPACE ostream&out,
00123                        const size_t flags = 0,
00124                        const int level = 0,
00125                        const char *pixelFileName = NULL,
00126                        size_t *pixelCounter = NULL);
00127 
00133     virtual OFCondition validateMetaInfo(const E_TransferSyntax oxfer,
00134                                          const E_FileWriteMode writeMode = EWM_fileformat);
00135 
00139     DcmMetaInfo *getMetaInfo();
00140 
00144     DcmDataset *getDataset();
00145 
00150     DcmDataset *getAndRemoveDataset();
00151 
00162     virtual Uint32 calcElementLength(const E_TransferSyntax xfer,
00163                                      const E_EncodingType enctype);
00164 
00170     virtual OFBool canWriteXfer(const E_TransferSyntax newXfer,
00171                                 const E_TransferSyntax oldXfer = EXS_Unknown);
00172 
00182     virtual OFCondition read(DcmInputStream &inStream,
00183                              const E_TransferSyntax xfer = EXS_Unknown,
00184                              const E_GrpLenEncoding glenc = EGL_noChange,
00185                              const Uint32 maxReadLength = DCM_MaxReadLength);
00186 
00194     virtual OFCondition write(DcmOutputStream &outStream,
00195                               const E_TransferSyntax oxfer,
00196                               const E_EncodingType enctype,
00197                               DcmWriteCache *wcache);
00198 
00216     virtual OFCondition write(DcmOutputStream &outStream,
00217                               const E_TransferSyntax oxfer,
00218                               const E_EncodingType enctype,
00219                               DcmWriteCache *wcache,
00220                               const E_GrpLenEncoding glenc,
00221                               const E_PaddingEncoding padenc = EPD_noChange,
00222                               const Uint32 padlen = 0,
00223                               const Uint32 subPadlen = 0,
00224                               Uint32 instanceLength = 0,
00225                               const E_FileWriteMode writeMode = EWM_fileformat);
00226 
00233     virtual OFCondition writeXML(STD_NAMESPACE ostream&out,
00234                                  const size_t flags = 0);
00235 
00250     virtual OFCondition loadFile(const char *fileName,
00251                                  const E_TransferSyntax readXfer = EXS_Unknown,
00252                                  const E_GrpLenEncoding groupLength = EGL_noChange,
00253                                  const Uint32 maxReadLength = DCM_MaxReadLength,
00254                                  const E_FileReadMode readMode = ERM_autoDetect);
00255 
00268     virtual OFCondition saveFile(const char *fileName,
00269                                  const E_TransferSyntax writeXfer = EXS_Unknown,
00270                                  const E_EncodingType encodingType = EET_UndefinedLength,
00271                                  const E_GrpLenEncoding groupLength = EGL_recalcGL,
00272                                  const E_PaddingEncoding padEncoding = EPD_noChange,
00273                                  const Uint32 padLength = 0,
00274                                  const Uint32 subPadLength = 0,
00275                                  const E_FileWriteMode writeMode = EWM_fileformat);
00276 
00277     // methods for different pixel representations
00278 
00286     OFCondition chooseRepresentation(const E_TransferSyntax repType,
00287                                      const DcmRepresentationParameter *repParam)
00288     {
00289         return getDataset()->chooseRepresentation(repType, repParam);
00290     }
00291 
00299     OFBool hasRepresentation(const E_TransferSyntax repType,
00300                              const DcmRepresentationParameter *repParam)
00301     {
00302         return getDataset()->hasRepresentation(repType, repParam);
00303     }
00304 
00307     void removeAllButOriginalRepresentations()
00308     {
00309         getDataset()->removeAllButOriginalRepresentations();
00310     }
00311 
00315     void removeAllButCurrentRepresentations()
00316     {
00317         getDataset()->removeAllButCurrentRepresentations();
00318     }
00319 
00325     E_FileReadMode getReadMode() const
00326     {
00327         return FileReadMode;
00328     }
00329 
00335     void setReadMode(const E_FileReadMode readMode)
00336     {
00337         FileReadMode = readMode;
00338     }
00339 
00346     virtual OFCondition insertItem(DcmItem *item, const unsigned long where = DCM_EndOfListIndex);
00347 
00353     virtual DcmItem *remove(const unsigned long num);
00354 
00360     virtual DcmItem *remove(DcmItem *item);
00361 
00362   private:
00363 
00376     static OFCondition checkMetaHeaderValue(DcmMetaInfo *metainfo,
00377                                             DcmDataset *dataset,
00378                                             const DcmTagKey &atagkey,
00379                                             DcmObject *obj,
00380                                             const E_TransferSyntax oxfer,
00381                                             const E_FileWriteMode writeMode);
00382 
00387     static E_TransferSyntax lookForXfer(DcmMetaInfo *metainfo);
00388 
00390     E_FileReadMode FileReadMode;
00391 };
00392 
00393 
00394 #endif // DCFILEFO_H
00395 
00396 
00397 /*
00398 ** CVS/RCS Log:
00399 ** $Log: dcfilefo.h,v $
00400 ** Revision 1.38  2010-10-20 16:34:08  joergr
00401 ** Renamed method to avoid warnings reported by gcc with additional flags.
00402 **
00403 ** Revision 1.37  2010-10-20 16:31:25  joergr
00404 ** Added missing API documentation.
00405 **
00406 ** Revision 1.36  2010-10-14 13:15:41  joergr
00407 ** Updated copyright header. Added reference to COPYRIGHT file.
00408 **
00409 ** Revision 1.35  2010-10-08 08:37:01  joergr
00410 ** Enhanced documentation on pixel-related parameters.
00411 **
00412 ** Revision 1.34  2010-03-01 09:08:44  uli
00413 ** Removed some unnecessary include directives in the headers.
00414 **
00415 ** Revision 1.33  2010-02-22 11:39:53  uli
00416 ** Remove some unneeded includes.
00417 **
00418 ** Revision 1.32  2009-08-25 13:00:23  joergr
00419 ** Added new methods which remove all data elements with an invalid group number
00420 ** from the meta information header, dataset and/or fileformat.
00421 ** Fixed wrong comment on clear() method.
00422 **
00423 ** Revision 1.31  2009-08-21 09:18:07  joergr
00424 ** Added parameter 'writeMode' to save/write methods which allows for specifying
00425 ** whether to write a dataset or fileformat as well as whether to update the
00426 ** file meta information or to create a new file meta information header.
00427 **
00428 ** Revision 1.30  2008-07-17 11:19:48  onken
00429 ** Updated copyFrom() documentation.
00430 **
00431 ** Revision 1.29  2008-07-17 10:30:23  onken
00432 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which
00433 ** permits setting an instance's value from an existing object. Implemented
00434 ** assignment operator where necessary.
00435 **
00436 ** Revision 1.28  2008-06-23 12:09:13  joergr
00437 ** Fixed inconsistencies in Doxygen API documentation.
00438 **
00439 ** Revision 1.27  2007/11/29 14:30:19  meichel
00440 ** Write methods now handle large raw data elements (such as pixel data)
00441 **   without loading everything into memory. This allows very large images to
00442 **   be sent over a network connection, or to be copied without ever being
00443 **   fully in memory.
00444 **
00445 ** Revision 1.26  2006/08/15 15:49:56  meichel
00446 ** Updated all code in module dcmdata to correctly compile when
00447 **   all standard C++ classes remain in namespace std.
00448 **
00449 ** Revision 1.25  2005/12/08 16:28:13  meichel
00450 ** Changed include path schema for all DCMTK header files
00451 **
00452 ** Revision 1.24  2005/12/02 08:48:17  joergr
00453 ** Added new file read mode that makes it possible to distinguish between DICOM
00454 ** files, datasets and other non-DICOM files.  For this reason, the last
00455 ** parameter of method loadFile() changed from OFBool to E_FileReadMode.
00456 **
00457 ** Revision 1.23  2004/07/01 12:28:25  meichel
00458 ** Introduced virtual clone method for DcmObject and derived classes.
00459 **
00460 ** Revision 1.22  2002/12/06 12:49:10  joergr
00461 ** Enhanced "print()" function by re-working the implementation and replacing
00462 ** the boolean "showFullData" parameter by a more general integer flag.
00463 ** Added doc++ documentation.
00464 ** Made source code formatting more consistent with other modules/files.
00465 **
00466 ** Revision 1.21  2002/08/27 16:55:32  meichel
00467 ** Initial release of new DICOM I/O stream classes that add support for stream
00468 **   compression (deflated little endian explicit VR transfer syntax)
00469 **
00470 ** Revision 1.20  2002/08/20 12:18:35  meichel
00471 ** Changed parameter list of loadFile and saveFile methods in class
00472 **   DcmFileFormat. Removed loadFile and saveFile from class DcmObject.
00473 **
00474 ** Revision 1.19  2002/04/25 09:39:47  joergr
00475 ** Added support for XML output of DICOM objects.
00476 **
00477 ** Revision 1.18  2002/04/11 12:22:51  joergr
00478 ** Added new methods for loading and saving DICOM files.
00479 **
00480 ** Revision 1.17  2001/09/25 17:19:26  meichel
00481 ** Adapted dcmdata to class OFCondition
00482 **
00483 ** Revision 1.16  2001/06/01 15:48:40  meichel
00484 ** Updated copyright header
00485 **
00486 ** Revision 1.15  2000/04/14 15:31:32  meichel
00487 ** Removed default value from output stream passed to print() method.
00488 **   Required for use in multi-thread environments.
00489 **
00490 ** Revision 1.14  2000/03/08 16:26:14  meichel
00491 ** Updated copyright header.
00492 **
00493 ** Revision 1.13  2000/03/03 14:05:23  meichel
00494 ** Implemented library support for redirecting error messages into memory
00495 **   instead of printing them to stdout/stderr for GUI applications.
00496 **
00497 ** Revision 1.12  2000/02/10 10:50:51  joergr
00498 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
00499 ** pixel data/item value fields to raw files.
00500 **
00501 ** Revision 1.11  1999/03/31 09:24:38  meichel
00502 ** Updated copyright header in module dcmdata
00503 **
00504 ** Revision 1.10  1998/11/12 16:47:39  meichel
00505 ** Implemented operator= for all classes derived from DcmObject.
00506 **
00507 ** Revision 1.9  1997/07/21 08:14:39  andreas
00508 ** - New environment for encapsulated pixel representations. DcmPixelData
00509 **   can contain different representations and uses codecs to convert
00510 **   between them. Codecs are derived from the DcmCodec class. New error
00511 **   codes are introduced for handling of representations. New internal
00512 **   value representation (only for ident()) for PixelData
00513 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
00514 **   with one unique boolean type OFBool.
00515 **
00516 ** Revision 1.8  1997/05/27 13:48:27  andreas
00517 ** - Add method canWriteXfer to class DcmObject and all derived classes.
00518 **   This method checks whether it is possible to convert the original
00519 **   transfer syntax to an new transfer syntax. The check is used in the
00520 **   dcmconv utility to prohibit the change of a compressed transfer
00521 **   syntax to a uncompressed.
00522 **
00523 ** Revision 1.7  1997/05/16 08:23:47  andreas
00524 ** - Revised handling of GroupLength elements and support of
00525 **   DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding
00526 **   got additional enumeration values (for a description see dctypes.h).
00527 **   addGroupLength and removeGroupLength methods are replaced by
00528 **   computeGroupLengthAndPadding. To support Padding, the parameters of
00529 **   element and sequence write functions changed.
00530 ** - Added a new method calcElementLength to calculate the length of an
00531 **   element, item or sequence. For elements it returns the length of
00532 **   tag, length field, vr field, and value length, for item and
00533 **   sequences it returns the length of the whole item. sequence including
00534 **   the Delimitation tag (if appropriate).  It can never return
00535 **   UndefinedLength.
00536 **
00537 ** Revision 1.6  1996/08/05 08:45:21  andreas
00538 ** new print routine with additional parameters:
00539 **         - print into files
00540 **         - fix output length for elements
00541 ** corrected error in search routine with parameter ESM_fromStackTop
00542 **
00543 ** Revision 1.5  1996/07/29 15:46:23  andreas
00544 ** Add method getAndRemoveDataset to remove connection of dataset from fileformat
00545 **
00546 ** Revision 1.4  1996/01/09 11:06:15  andreas
00547 ** New Support for Visual C++
00548 ** Correct problems with inconsistent const declarations
00549 **
00550 ** Revision 1.3  1996/01/05 13:22:55  andreas
00551 ** - changed to support new streaming facilities
00552 ** - more cleanups
00553 ** - merged read / write methods for block and file transfer
00554 **
00555 */


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