MeVisLab Toolbox Reference
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
29 class MLImageFormat;
30 class MLImageFormatCompressionParams;
31
32 //----------------------------------------------------------------------------------
36 //----------------------------------------------------------------------------------
38
39 public:
40
43 UPDATE_OFF = 0,
46 UPDATE_MODE_NUM
47 };
48
50 static const char* const UPDATE_MODE_NAMES[UPDATE_MODE_NUM];
51
54
57
60 BoolField &getValidFld () const { return *_validFld ; }
61 NotifyField &getLoadFld () const { return *_loadFld ; }
62 NotifyField &getUpdateRegionFld () const { return *_updateRegionFld ; }
63 NotifyField &getClearFld () const { return *_clearFld ; }
64 EnumField &getAutoLoadFld () const { return *_autoLoadFld ; }
65 StringField &getTmpFileNamePrefixFld() const { return *_tmpFileNamePrefixFld; }
67
68 protected:
69 // ----------------------------------------------------------
72 // ----------------------------------------------------------
74 void activateAttachments() override;
75
77 void handleNotification (Field *field) override;
79
80 // ----------------------------------------------------------
83 // ----------------------------------------------------------
86
88 Module::INPUT_HANDLE handleInput(int /*inIndex*/, Module::INPUT_STATE /*state*/) const override;
89
93 int /*outIndex*/) override;
94
101
103
104 private:
105
106 // ----------------------------------------------------------
109 // ----------------------------------------------------------
110
111 // Handle a special case where preserveCacheFile is being enabled while a temporary
112 // cache file exists. To avoid a file leak we need to remove the temporary cache
113 // file, but not the file given by the (prefix) path.
117 virtual bool _handlePreserveCacheFileFlagChange(Field* field);
118
122 void _shutDownFileIO(bool forceRemove=false);
123
128 void _clearOutput(bool forceRemove=false);
129
146 MLErrorCode _setUpOrOpenCacheFile(bool *cacheWasLoaded=nullptr);
147
155 MLErrorCode _overwriteWithInputInFile();
157
158
159 // ----------------------------------------------------------
162 // ----------------------------------------------------------
165 MLImageFormat *_fileManager;
166
168 PagedImage _inImgProps;
170
171
172 // ----------------------------------------------------------
175 // ----------------------------------------------------------
176
178 BoolField *_validFld;
179
181 BoolField *_preserveCacheFileFld;
182
183
185 NotifyField *_loadFld;
186
189 NotifyField *_updateRegionFld;
190
193 NotifyField *_clearFld;
194
195
198 EnumField *_autoLoadFld;
199
201 StringField *_tmpFileNamePrefixFld;
202
205 StringField *_outFullCacheFilePathFld;
207
208
211 };
212
214
215#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:58
Field to encapsulate an enumerated value.
Definition mlFields.h:195
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:323
INPUT_STATE
See documentation of handleInput.
Definition mlModule.h:315
Field without value for notifications.
Definition mlFields.h:659
Class which represents an image, which manages properties of an image and image data which is located...
Field to encapsulate a string value.
Definition mlFields.h:610
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
Definition mlSubImage.h:75
#define ML_MODULE_CLASS_HEADER(className)
Like ML_CLASS_HEADER for the usage of derived classes from Module.
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:716
Target mlrange_cast(Source arg)
Generic version of checked ML casts.