dccodec.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:  Andreas Barth
00021  *
00022  *  Purpose: Interface of abstract class DcmCodec and the class DcmCodecStruct
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/09 14:48:14 $
00026  *  Source File:      $Source: /share/dicom/cvs-depot/dcmtk/dcmdata/include/dcmtk/dcmdata/dccodec.h,v $
00027  *  CVS/RCS Revision: $Revision: 1.18 $
00028  *  Status:           $State: Exp $
00029  *
00030  *  CVS/RCS Log at end of file
00031  *
00032  */
00033 
00034 #ifndef DCCODEC_H
00035 #define DCCODEC_H
00036 
00037 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00038 #include "dcmtk/dcmdata/dctypes.h"
00039 #include "dcmtk/dcmdata/dcerror.h"
00040 #include "dcmtk/dcmdata/dcxfer.h"
00041 #include "dcmtk/ofstd/oflist.h"
00042 
00043 class DcmStack;
00044 class DcmRepresentationParameter;
00045 class DcmPixelSequence;
00046 class DcmPolymorphOBOW;
00047 class DcmItem;
00048 class DcmTagKey;
00049 
00054 class DcmCodecParameter
00055 {
00056 public:
00058     DcmCodecParameter() {}
00059 
00061     DcmCodecParameter(const DcmCodecParameter&) {}
00062 
00064     virtual ~DcmCodecParameter() {}
00065     
00070     virtual DcmCodecParameter *clone() const = 0;
00071 
00075     virtual const char *className() const = 0;
00076 
00077 };                    
00078 
00079 
00090 class DcmCodec
00091 {
00092 public:
00094   DcmCodec() {}
00095 
00097   virtual ~DcmCodec() {}
00098 
00109   virtual OFCondition decode(
00110       const DcmRepresentationParameter * fromRepParam,
00111       DcmPixelSequence * pixSeq,
00112       DcmPolymorphOBOW& uncompressedPixelData,
00113       const DcmCodecParameter * cp,
00114       const DcmStack& objStack) const = 0;
00115 
00130   virtual OFCondition encode(
00131       const Uint16 * pixelData,
00132       const Uint32 length,
00133       const DcmRepresentationParameter * toRepParam,
00134       DcmPixelSequence * & pixSeq,
00135       const DcmCodecParameter *cp,
00136       DcmStack & objStack) const = 0;
00137 
00152   virtual OFCondition encode(
00153       const E_TransferSyntax fromRepType,
00154       const DcmRepresentationParameter * fromRepParam,
00155       DcmPixelSequence * fromPixSeq,
00156       const DcmRepresentationParameter * toRepParam,
00157       DcmPixelSequence * & toPixSeq,
00158       const DcmCodecParameter * cp,
00159       DcmStack & objStack) const = 0;
00160 
00168   virtual OFBool canChangeCoding(
00169       const E_TransferSyntax oldRepType,
00170       const E_TransferSyntax newRepType) const = 0;
00171 
00172 
00173   // static helper methods that have proven useful in codec classes derived from DcmCodec 
00174 
00182   static OFCondition insertStringIfMissing(DcmItem *dataset, const DcmTagKey& tag, const char *val);
00183 
00192   static OFCondition convertToSecondaryCapture(DcmItem *dataset);
00193 
00202   static OFCondition newInstance(
00203     DcmItem *dataset, 
00204     const char *purposeOfReferenceCodingScheme = NULL,
00205     const char *purposeOfReferenceCodeValue = NULL,
00206     const char *purposeOfReferenceCodeMeaning = NULL);
00207 
00212   static OFCondition updateImageType(DcmItem *dataset);
00213 
00222   static OFCondition insertCodeSequence(
00223     DcmItem *dataset,
00224     const DcmTagKey &tagKey,
00225     const char *codingSchemeDesignator,
00226     const char *codeValue,
00227     const char *codeMeaning);
00228 
00229 };
00230 
00231 
00236 class DcmCodecList
00237 {
00238 
00239 public:
00240 
00242   virtual ~DcmCodecList();
00243 
00258   static OFCondition registerCodec(
00259     const DcmCodec *aCodec,  
00260     const DcmRepresentationParameter *aDefaultRepParam,
00261     const DcmCodecParameter *aCodecParameter);
00262 
00268   static OFCondition deregisterCodec(const DcmCodec *aCodec);
00269     
00278   static OFCondition updateCodecParameter(
00279     const DcmCodec *aCodec,
00280     const DcmCodecParameter *aCodecParameter);
00281 
00294   static OFCondition decode(
00295     const DcmXfer & fromType,
00296     const DcmRepresentationParameter * fromParam,
00297     DcmPixelSequence * fromPixSeq,
00298     DcmPolymorphOBOW& uncompressedPixelData,
00299     DcmStack & pixelStack);
00300 
00317   static OFCondition encode(
00318     const E_TransferSyntax fromRepType,
00319     const Uint16 * pixelData,
00320     const Uint32 length,
00321     const E_TransferSyntax toRepType,
00322     const DcmRepresentationParameter * toRepParam,
00323     DcmPixelSequence * & pixSeq,
00324     DcmStack & pixelStack);
00325 
00343   static OFCondition encode(
00344     const E_TransferSyntax fromRepType,
00345     const DcmRepresentationParameter * fromParam, 
00346     DcmPixelSequence * fromPixSeq, 
00347     const E_TransferSyntax toRepType,
00348     const DcmRepresentationParameter * toRepParam,
00349     DcmPixelSequence * & toPixSeq,
00350     DcmStack & pixelStack);
00351 
00352 
00361   static OFBool canChangeCoding(
00362     const E_TransferSyntax fromRepType,
00363     const E_TransferSyntax toRepType);
00364 
00365 private:
00366 
00372   DcmCodecList(
00373     const DcmCodec *aCodec,  
00374     const DcmRepresentationParameter *aDefaultRepParam,
00375     const DcmCodecParameter *aCodecParameter);
00376 
00378   DcmCodecList(const DcmCodecList &);
00379 
00381   DcmCodecList &operator=(const DcmCodecList &);
00382 
00384   const DcmCodec * codec;
00385   
00387   const DcmRepresentationParameter * defaultRepParam;
00388   
00390   const DcmCodecParameter * codecParameter;
00391 
00393   static OFList<DcmCodecList *> registeredCodecs;
00394   
00395 #ifdef _REENTRANT
00396 
00397   static OFReadWriteLock codecLock;
00398 #endif
00399 
00400   // dummy friend declaration to prevent gcc from complaining
00401   // that this class only defines private constructors and has no friends.
00402   friend class DcmCodecListDummyFriend;
00403 };
00404  
00405 
00406 #endif
00407 
00408 /*
00409 ** CVS/RCS Log:
00410 ** $Log: dccodec.h,v $
00411 ** Revision 1.18  2005/12/09 14:48:14  meichel
00412 ** Added missing virtual destructors
00413 **
00414 ** Revision 1.17  2005/12/08 16:28:01  meichel
00415 ** Changed include path schema for all DCMTK header files
00416 **
00417 ** Revision 1.16  2004/08/24 14:54:18  meichel
00418 **  Updated compression helper methods. Image type is not set to SECONDARY
00419 **   any more, support for the purpose of reference code sequence added.
00420 **
00421 ** Revision 1.15  2003/06/12 13:35:23  joergr
00422 ** Fixed inconsistent API documentation reported by Doxygen.
00423 **
00424 ** Revision 1.14  2002/05/24 14:51:41  meichel
00425 ** Moved helper methods that are useful for different compression techniques
00426 **   from module dcmjpeg to module dcmdata
00427 **
00428 ** Revision 1.13  2002/02/27 14:21:20  meichel
00429 ** Declare dcmdata read/write locks only when compiled in multi-thread mode
00430 **
00431 ** Revision 1.12  2001/11/12 16:29:51  meichel
00432 ** Added dummy friend class declaration to singleton class DcmCodecList
00433 **   to keep gcc from squawking.
00434 **
00435 ** Revision 1.11  2001/11/08 16:19:39  meichel
00436 ** Changed interface for codec registration. Now everything is thread-safe
00437 **   and multiple codecs can be registered for a single transfer syntax (e.g.
00438 **   one encoder and one decoder).
00439 **
00440 ** Revision 1.10  2001/09/25 17:19:07  meichel
00441 ** Updated abstract class DcmCodecParameter for use with dcmjpeg.
00442 **   Added new function deregisterGlobalCodec().
00443 **
00444 ** Revision 1.9  2001/06/01 15:48:34  meichel
00445 ** Updated copyright header
00446 **
00447 ** Revision 1.8  2001/05/25 09:53:51  meichel
00448 ** Modified DcmCodec::decode() interface, required for future dcmjpeg module.
00449 **
00450 ** Revision 1.7  2000/09/27 08:19:54  meichel
00451 ** Minor changes in DcmCodec interface, required for future dcmjpeg module.
00452 **
00453 ** Revision 1.6  2000/04/14 16:09:12  meichel
00454 ** Made function DcmCodec and related functions thread safe.
00455 **   registerGlobalCodec() should not be called anymore from the constructor
00456 **   of global objects.
00457 **
00458 ** Revision 1.5  2000/03/08 16:26:11  meichel
00459 ** Updated copyright header.
00460 **
00461 ** Revision 1.4  1999/03/31 09:24:31  meichel
00462 ** Updated copyright header in module dcmdata
00463 **
00464 ** Revision 1.3  1998/07/15 15:48:43  joergr
00465 ** Removed several compiler warnings reported by gcc 2.8.1 with
00466 ** additional options, e.g. missing copy constructors and assignment
00467 ** operators, initialization of member variables in the body of a
00468 ** constructor instead of the member initialization list, hiding of
00469 ** methods by use of identical names, uninitialized member variables,
00470 ** missing const declaration of char pointers. Replaced tabs by spaces.
00471 **
00472 ** Revision 1.2  1997/07/24 13:07:45  andreas
00473 ** - Make DcmCodec:canChangeCoding abstract
00474 **
00475 ** Revision 1.1  1997/07/21 07:54:57  andreas
00476 ** - New environment for encapsulated pixel representations. DcmPixelData
00477 **   can contain different representations and uses codecs to convert
00478 **   between them. Codecs are derived from the DcmCodec class. New error
00479 **   codes are introduced for handling of representations. New internal
00480 **   value representation (only for ident()) for PixelData
00481 ** 
00482 */


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