dcmdata/include/dcmtk/dcmdata/dcistrmf.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:  Marco Eichelberg
00017  *
00018  *  Purpose: DcmInputFileStream and related classes,
00019  *    implements streamed input from files.
00020  *
00021  *  Last Update:      $Author: joergr $
00022  *  Update Date:      $Date: 2010-10-14 13:15:41 $
00023  *  CVS/RCS Revision: $Revision: 1.9 $
00024  *  Status:           $State: Exp $
00025  *
00026  *  CVS/RCS Log at end of file
00027  *
00028  */
00029 
00030 #ifndef DCISTRMF_H
00031 #define DCISTRMF_H
00032 
00033 #include "dcmtk/config/osconfig.h"
00034 #include "dcmtk/dcmdata/dcistrma.h"
00035 
00036 
00039 class DcmFileProducer: public DcmProducer
00040 {
00041 public:
00046   DcmFileProducer(const char *filename, offile_off_t offset = 0);
00047 
00049   virtual ~DcmFileProducer();
00050 
00055   virtual OFBool good() const;
00056 
00061   virtual OFCondition status() const;
00062 
00066   virtual OFBool eos();
00067 
00075   virtual offile_off_t avail();
00076 
00082   virtual offile_off_t read(void *buf, offile_off_t buflen);
00083 
00088   virtual offile_off_t skip(offile_off_t skiplen);
00089 
00094   virtual void putback(offile_off_t num);
00095 
00096 private:
00097 
00099   DcmFileProducer(const DcmFileProducer&);
00100 
00102   DcmFileProducer& operator=(const DcmFileProducer&);
00103 
00105   OFFile file_;
00106 
00108   OFCondition status_;
00109 
00111   offile_off_t size_;
00112 };
00113 
00114 
00117 class DcmInputFileStreamFactory: public DcmInputStreamFactory
00118 {
00119 public:
00120 
00125   DcmInputFileStreamFactory(const char *filename, offile_off_t offset);
00126 
00128   DcmInputFileStreamFactory(const DcmInputFileStreamFactory &arg);
00129 
00131   virtual ~DcmInputFileStreamFactory();
00132 
00136   virtual DcmInputStream *create() const;
00137 
00140   virtual DcmInputStreamFactory *clone() const
00141   {
00142     return new DcmInputFileStreamFactory(*this);
00143   }
00144 
00145 private:
00146 
00147 
00149   DcmInputFileStreamFactory& operator=(const DcmInputFileStreamFactory&);
00150 
00152   OFString filename_;
00153 
00155   offile_off_t offset_;
00156 
00157 };
00158 
00159 
00162 class DcmInputFileStream: public DcmInputStream
00163 {
00164 public:
00169   DcmInputFileStream(const char *filename, offile_off_t offset = 0);
00170 
00172   virtual ~DcmInputFileStream();
00173 
00183   virtual DcmInputStreamFactory *newFactory() const;
00184 
00185 private:
00186 
00188   DcmInputFileStream(const DcmInputFileStream&);
00189 
00191   DcmInputFileStream& operator=(const DcmInputFileStream&);
00192 
00194   DcmFileProducer producer_;
00195 
00197   OFString filename_;
00198 };
00199 
00205 class DcmTempFileHandler
00206 {
00207 public:
00208 
00215   static DcmTempFileHandler *newInstance(const char *fname);
00216 
00222   DcmInputStream *create() const;
00223 
00225   void increaseRefCount();
00226 
00230   void decreaseRefCount();
00231 
00232 private:
00233 
00238   DcmTempFileHandler(const char *fname);
00239 
00243   virtual ~DcmTempFileHandler();
00244 
00246   DcmTempFileHandler(const DcmTempFileHandler& arg);
00247 
00249   DcmTempFileHandler& operator=(const DcmTempFileHandler& arg);
00250 
00254   size_t refCount_;
00255 
00256 #ifdef WITH_THREADS
00258   OFMutex mutex_;
00259 #endif
00260 
00262   OFString filename_;
00263 
00264 };
00265 
00268 class DcmInputTempFileStreamFactory: public DcmInputStreamFactory
00269 {
00270 public:
00271 
00276   DcmInputTempFileStreamFactory(DcmTempFileHandler *handler);
00277 
00279   DcmInputTempFileStreamFactory(const DcmInputTempFileStreamFactory &arg);
00280 
00282   virtual ~DcmInputTempFileStreamFactory();
00283 
00287   virtual DcmInputStream *create() const;
00288 
00291   virtual DcmInputStreamFactory *clone() const;
00292 
00293 private:
00294 
00296   DcmInputTempFileStreamFactory& operator=(const DcmInputTempFileStreamFactory&);
00297 
00299   DcmTempFileHandler *fileHandler_;
00300 
00301 };
00302 
00303 
00304 #endif
00305 
00306 /*
00307  * CVS/RCS Log:
00308  * $Log: dcistrmf.h,v $
00309  * Revision 1.9  2010-10-14 13:15:41  joergr
00310  * Updated copyright header. Added reference to COPYRIGHT file.
00311  *
00312  * Revision 1.8  2010-10-04 14:44:39  joergr
00313  * Replaced "#ifdef _REENTRANT" by "#ifdef WITH_THREADS" where appropriate (i.e.
00314  * in all cases where OFMutex, OFReadWriteLock, etc. are used).
00315  *
00316  * Revision 1.7  2010-03-01 09:08:44  uli
00317  * Removed some unnecessary include directives in the headers.
00318  *
00319  * Revision 1.6  2009-11-04 09:58:07  uli
00320  * Switched to logging mechanism provided by the "new" oflog module
00321  *
00322  * Revision 1.5  2008-05-29 10:39:43  meichel
00323  * Implemented new classes DcmTempFileHandler and DcmInputTempFileStreamFactory
00324  *   that perform thread-safe reference counted life cycle management of a
00325  *   temporary file and are needed for DcmElement temporary file extensions to come.
00326  *
00327  * Revision 1.4  2007/02/19 15:45:41  meichel
00328  * Class DcmInputStream and related classes are now safe for use with
00329  *   large files (2 GBytes or more) if supported by compiler and operating system.
00330  *
00331  * Revision 1.3  2005/12/08 16:28:17  meichel
00332  * Changed include path schema for all DCMTK header files
00333  *
00334  * Revision 1.2  2002/11/27 12:07:21  meichel
00335  * Adapted module dcmdata to use of new header file ofstdinc.h
00336  *
00337  * Revision 1.1  2002/08/27 16:55:33  meichel
00338  * Initial release of new DICOM I/O stream classes that add support for stream
00339  *   compression (deflated little endian explicit VR transfer syntax)
00340  *
00341  *
00342  */


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