MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlImageFormatFileCache.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_IMAGE_FORMAT_FILE_CACHE_H
14#define ML_IMAGE_FORMAT_FILE_CACHE_H
15
16
20
21#include "MLImageFormatSystem.h"
22#include <mlModuleIncludes.h>
23#include <mlImageFormatTools.h>
24#include <mlImageFormatIOBase.h>
25
27
29class MLImageFormat;
30class MLImageFormatCompressionParams;
31
32//----------------------------------------------------------------------------------
36//----------------------------------------------------------------------------------
38{
39
40public:
43 UPDATE_OFF = 0,
46 UPDATE_MODE_NUM
47 };
48
50 static const char* const UPDATE_MODE_NAMES[UPDATE_MODE_NUM];
51
54
57
61 {
62 return *_validFld;
63 }
65 {
66 return *_loadFld;
67 }
69 {
70 return *_updateRegionFld;
71 }
73 {
74 return *_clearFld;
75 }
77 {
78 return *_autoLoadFld;
79 }
81 {
82 return *_tmpFileNamePrefixFld;
83 }
85
86protected:
87 // ----------------------------------------------------------
90 // ----------------------------------------------------------
92 void activateAttachments() override;
93
97
98 // ----------------------------------------------------------
101 // ----------------------------------------------------------
104
106 Module::INPUT_HANDLE handleInput(int /*inIndex*/, Module::INPUT_STATE /*state*/) const override;
107
109 SubImageBox calculateInputSubImageBox(int /*inIndex*/, const SubImageBox& outSubImgBox, int /*outIndex*/) override;
110
117
119
120private:
121 // ----------------------------------------------------------
124 // ----------------------------------------------------------
125
126 // Handle a special case where preserveCacheFile is being enabled while a temporary
127 // cache file exists. To avoid a file leak we need to remove the temporary cache
128 // file, but not the file given by the (prefix) path.
132 virtual bool _handlePreserveCacheFileFlagChange(Field* field);
133
137 void _shutDownFileIO(bool forceRemove = false);
138
143 void _clearOutput(bool forceRemove = false);
144
161 MLErrorCode _setUpOrOpenCacheFile(bool* cacheWasLoaded = nullptr);
162
170 MLErrorCode _overwriteWithInputInFile();
172
173
174 // ----------------------------------------------------------
177 // ----------------------------------------------------------
180 MLImageFormat* _fileManager;
181
183 PagedImage _inImgProps;
185
186
187 // ----------------------------------------------------------
190 // ----------------------------------------------------------
191
193 BoolField* _validFld;
194
196 BoolField* _preserveCacheFileFld;
197
198
200 NotifyField* _loadFld;
201
204 NotifyField* _updateRegionFld;
205
208 NotifyField* _clearFld;
209
210
213 EnumField* _autoLoadFld;
214
216 StringField* _tmpFileNamePrefixFld;
217
220 StringField* _outFullCacheFilePathFld;
222
223
226};
227
229
230#endif // of __mlImageFormatFileCache_H
#define MLIMAGEFORMAT_EXPORT
Global and OS specific declarations for the MLImageFormat project.
Field to encapsulate a boolean value.
Definition mlFields.h:56
Field to encapsulate an enumerated value.
Definition mlFields.h:185
Base class for all fields used in the ML.
Definition mlField.h:73
An ML module class for file caching and modification of a whole ML PagedImage volume as MLImageFormat...
NotifyField & getClearFld() const
void activateAttachments() override
Update internal module state after load or clone.
void calculateOutputImageProperties(int outputIndex, PagedImage *outputImage) override
Sets properties of the output image at output outIndex.
Module::INPUT_HANDLE handleInput(int, Module::INPUT_STATE) const override
Allow invalid input images.
void handleNotification(Field *field) override
Handle field changes of the field field.
SubImageBox calculateInputSubImageBox(int, const SubImageBox &outSubImgBox, int) override
Determines the data to be loaded from input image for page processing.
UPDATE_MODE
Enum to controls how input and parameter changes influence/update the result image.
@ UPDATE_AUTOCLEAR
Invalidate cached image if input changes.
@ UPDATE_AUTOUPDATE
Update cached image and output (if possible) if input changes.
~MLImageFormatFileCache() override
Destructor.
StringField & getTmpFileNamePrefixFld() const
void calculateOutputSubImage(SubImage *outSubImg, int outIndex, SubImage *inSubImgs) override
Calculates page outSubImg of output image with index outIndex by using inSubimgs.
NotifyField & getUpdateRegionFld() const
MLImageFormatFileCache()
Constructor.
IO base class to manage/save/load/modify .mlimage files and to derive specific save,...
File format class to store, load, and modify a PagedImage in a file.
INPUT_HANDLE
See documentation of handleInput.
Definition mlModule.h:342
INPUT_STATE
See documentation of handleInput.
Definition mlModule.h:330
Field without value for notifications.
Definition mlFields.h:687
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
Field to encapsulate a string value.
Definition mlFields.h:634
This class manages/represents a rectangular 6D image region that is organized linearly in memory.
Definition mlSubImage.h:75
#define ML_MODULE_CLASS_HEADER(className)
Similar to ML_CLASS_HEADER for the usage of derived classes from Module.
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:772
Target mlrange_cast(Source arg)
Generic version of checked ML casts.