OFFIS DCMTK  Version 3.6.0
dcfcache.h
1 /*
2  *
3  * Copyright (C) 1994-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmdata
15  *
16  * Author: Marco Eichelberg
17  *
18  * Purpose: file cache facility for DcmElement::getPartialValue
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:15:41 $
22  * CVS/RCS Revision: $Revision: 1.3 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 #ifndef DCFCACHE_H
30 #define DCFCACHE_H
31 
32 #include "dcmtk/config/osconfig.h"
33 #include "dcmtk/ofstd/offile.h" /* for offile_off_t */
34 #include "dcmtk/dcmdata/dcistrma.h" /* for class DcmInputStream */
35 
43 {
44 public:
45 
48  : stream_(NULL)
49  , offset_(0)
50  , user_(NULL)
51  {
52  }
53 
56  {
57  delete stream_;
58  }
59 
64  OFBool isUser(void *object) const
65  {
66  return object == user_;
67  }
68 
70  void clear()
71  {
72  delete stream_;
73  stream_ = NULL;
74  offset_ = 0;
75  user_ = NULL;
76  }
77 
83  void init(DcmInputStream *stream, void *user)
84  {
85  clear();
86  stream_ = stream;
87  user_ = user;
88  if (stream_) offset_ = stream_->tell();
89  }
90 
93  {
94  return stream_;
95  }
96 
98  offile_off_t getOffset() const { return offset_; }
99 
100 private:
101 
103  DcmFileCache(const DcmFileCache& arg);
104 
106  DcmFileCache& operator=(const DcmFileCache& arg);
107 
110 
112  offile_off_t offset_;
113 
115  const void *user_;
116 };
117 
118 #endif
119 
120 /*
121  * CVS/RCS Log:
122  * $Log: dcfcache.h,v $
123  * Revision 1.3 2010-10-14 13:15:41 joergr
124  * Updated copyright header. Added reference to COPYRIGHT file.
125  *
126  * Revision 1.2 2009-11-04 09:58:07 uli
127  * Switched to logging mechanism provided by the "new" oflog module
128  *
129  * Revision 1.1 2007-07-11 08:50:23 meichel
130  * Initial release of new method DcmElement::getPartialValue which gives access
131  * to partial attribute values without loading the complete attribute value
132  * into memory, if kept in file.
133  *
134  *
135  */
offile_off_t getOffset() const
return initial stream offset
Definition: dcfcache.h:98
void init(DcmInputStream *stream, void *user)
initializes the file cache with the given stream object and user.
Definition: dcfcache.h:83
DcmInputStream * getStream()
return input stream
Definition: dcfcache.h:92
DcmFileCache & operator=(const DcmFileCache &arg)
private undefined copy assignment operator
This class implements a simple container that stores an input stream, the position of that input stre...
Definition: dcfcache.h:42
offile_off_t offset_
offset within stream for initial position
Definition: dcfcache.h:112
OFBool isUser(void *object) const
checks if the given object is the current user of this cache returns true if so, false otherwise ...
Definition: dcfcache.h:64
virtual offile_off_t tell() const
returns the total number of bytes read from the stream so far
DcmInputStream * stream_
input stream, may be NULL
Definition: dcfcache.h:109
DcmFileCache()
default constructor
Definition: dcfcache.h:47
~DcmFileCache()
destructor
Definition: dcfcache.h:55
void clear()
returns object to default constructed state
Definition: dcfcache.h:70
abstract base class for input streams.
Definition: dcistrma.h:147
const void * user_
object that currently uses the file cache, i.e. has created the stream
Definition: dcfcache.h:115


Generated on Wed Dec 14 2016 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.11