dcmdata/include/dcmtk/dcmdata/dcfcache.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: file cache facility for DcmElement::getPartialValue
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-14 13:15:41 $
00022  *  CVS/RCS Revision: $Revision: 1.3 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 #ifndef DCFCACHE_H
00030 #define DCFCACHE_H
00031 
00032 #include "dcmtk/config/osconfig.h"
00033 #include "dcmtk/ofstd/offile.h"     /* for offile_off_t */
00034 #include "dcmtk/dcmdata/dcistrma.h" /* for class DcmInputStream */
00035 
00042 class DcmFileCache
00043 {
00044 public:
00045     
00047   DcmFileCache()
00048   : stream_(NULL)
00049   , offset_(0)
00050   , user_(NULL)
00051   {
00052   }
00053 
00055   ~DcmFileCache()
00056   {
00057     delete stream_;
00058   }
00059 
00064   OFBool isUser(void *object) const
00065   {
00066     return object == user_;
00067   }
00068 
00070   void clear()
00071   {
00072     delete stream_;
00073     stream_ = NULL;
00074     offset_ = 0;
00075     user_ = NULL;
00076   }
00077   
00083   void init(DcmInputStream *stream, void *user)
00084   {
00085     clear();
00086     stream_ = stream;
00087     user_ = user;
00088     if (stream_) offset_ = stream_->tell();
00089   }
00090   
00092   DcmInputStream *getStream()
00093   {
00094     return stream_;
00095   }
00096 
00098   offile_off_t getOffset() const { return offset_; }
00099   
00100 private:
00101 
00103   DcmFileCache(const DcmFileCache& arg);
00104 
00106   DcmFileCache& operator=(const DcmFileCache& arg);
00107 
00109   DcmInputStream *stream_;
00110   
00112   offile_off_t offset_;
00113 
00115   const void *user_;  
00116 };
00117 
00118 #endif
00119 
00120 /*
00121  * CVS/RCS Log:
00122  * $Log: dcfcache.h,v $
00123  * Revision 1.3  2010-10-14 13:15:41  joergr
00124  * Updated copyright header. Added reference to COPYRIGHT file.
00125  *
00126  * Revision 1.2  2009-11-04 09:58:07  uli
00127  * Switched to logging mechanism provided by the "new" oflog module
00128  *
00129  * Revision 1.1  2007-07-11 08:50:23  meichel
00130  * Initial release of new method DcmElement::getPartialValue which gives access
00131  *   to partial attribute values without loading the complete attribute value
00132  *   into memory, if kept in file.
00133  *
00134  *
00135  */


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