DGtal 1.4.0
Loading...
Searching...
No Matches
ImageCachePolicies.h
1
17#pragma once
18
31#if defined(ImageCachePolicies_RECURSES)
32#error Recursive header files inclusion detected in ImageCachePolicies.h
33#else // defined(ImageCachePolicies_RECURSES)
35#define ImageCachePolicies_RECURSES
36
37#if !defined ImageCachePolicies_h
39#define ImageCachePolicies_h
40
42// Inclusions
43#include <iostream>
44#include "DGtal/base/Common.h"
45#include "DGtal/base/ConceptUtils.h"
46#include "DGtal/images/CImage.h"
47#include "DGtal/images/CImageFactory.h"
48#include "DGtal/base/Alias.h"
49
50#include "DGtal/images/ImageCache.h"
52
53namespace DGtal
54{
55
57// Template class ImageCacheReadPolicyLAST
76template <typename TImageContainer, typename TImageFactory>
78{
79public:
80
84
85 typedef TImageFactory ImageFactory;
86
89 typedef typename TImageContainer::Point Point;
90 typedef typename TImageContainer::Value Value;
91
93 myCacheImagesPtr(NULL), myImageFactory(&anImageFactory)
94 {
95 }
96
102
103private:
104
106
108
109public:
110
120
129 ImageContainer * getPage(const Domain & aDomain);
130
138
144 void updateCache(const Domain &aDomain);
145
150
151protected:
152
155
158
159}; // end of class ImageCacheReadPolicyLAST
160
162// Template class ImageCacheReadPolicyFIFO
181template <typename TImageContainer, typename TImageFactory>
183{
184public:
185
189
190 typedef TImageFactory ImageFactory;
191
196
197 ImageCacheReadPolicyFIFO(Alias<ImageFactory> anImageFactory, int aFIFOSizeMax=10):
198 myFIFOSizeMax(aFIFOSizeMax), myImageFactory(&anImageFactory)
199 {
200 }
201
207
208private:
209
211
213
214public:
215
225
234 ImageContainer * getPage(const Domain & aDomain);
235
243
249 void updateCache(const Domain &aDomain);
250
255
256protected:
257
259 std::deque <ImageContainer *> myFIFOCacheImages;
260
262 unsigned int myFIFOSizeMax;
263
266
267}; // end of class ImageCacheReadPolicyFIFO
268
270// Template class ImageCacheWritePolicyWT
285template <typename TImageContainer, typename TImageFactory>
287{
288public:
289
293
294 typedef TImageFactory ImageFactory;
295
300
302 myImageFactory(&anImageFactory)
303 {
304 }
305
311
312private:
313
315
317
318public:
319
328 void writeInPage(ImageContainer * anImageContainer, const Point & aPoint, const Value &aValue);
329
335 void flushPage(ImageContainer * anImageContainer);
336
337protected:
338
341
342}; // end of class ImageCacheWritePolicyWT
343
345// Template class ImageCacheWritePolicyWB
361template <typename TImageContainer, typename TImageFactory>
363{
364public:
365
369
370 typedef TImageFactory ImageFactory;
371
376
378 myImageFactory(&anImageFactory)
379 {
380 }
381
387
388private:
389
391
393
394public:
395
404 void writeInPage(ImageContainer * anImageContainer, const Point & aPoint, const Value &aValue);
405
411 void flushPage(ImageContainer * anImageContainer);
412
413protected:
414
417
418}; // end of class ImageCacheWritePolicyWB
419
420} // namespace DGtal
421
422
424// Includes inline functions.
425#include "DGtal/images/ImageCachePolicies.ih"
426
427// //
429
430#endif // !defined ImageCachePolicies_h
431
432#undef ImageCachePolicies_RECURSES
433#endif // else defined(ImageCachePolicies_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition Alias.h:183
Aim: implements a 'FIFO' read policy cache.
ImageFactory * myImageFactory
Alias on the image factory.
ImageContainer * getPageToDetach()
unsigned int myFIFOSizeMax
Size max of the FIFO.
void updateCache(const Domain &aDomain)
std::deque< ImageContainer * > myFIFOCacheImages
Alias on the images cache.
ImageCacheReadPolicyFIFO(const ImageCacheReadPolicyFIFO &other)
ImageCacheReadPolicyFIFO & operator=(const ImageCacheReadPolicyFIFO &other)
ImageCacheReadPolicyFIFO(Alias< ImageFactory > anImageFactory, int aFIFOSizeMax=10)
ImageContainer * getPage(const Domain &aDomain)
BOOST_CONCEPT_ASSERT((concepts::CImageFactory< TImageFactory >))
ImageContainer * getPage(const Point &aPoint)
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
Aim: implements a 'LAST' read policy cache.
ImageCacheReadPolicyLAST & operator=(const ImageCacheReadPolicyLAST &other)
ImageContainer * getPage(const Domain &aDomain)
ImageCacheReadPolicyLAST(const ImageCacheReadPolicyLAST &other)
ImageContainer * myCacheImagesPtr
Alias on the images cache.
ImageFactory * myImageFactory
Alias on the image factory.
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
BOOST_CONCEPT_ASSERT((concepts::CImageFactory< TImageFactory >))
void updateCache(const Domain &aDomain)
ImageContainer * getPage(const Point &aPoint)
ImageContainer * getPageToDetach()
ImageCacheReadPolicyLAST(Alias< ImageFactory > anImageFactory)
Aim: implements a 'WB (Write-back or Write-behind)' write policy cache.
ImageCacheWritePolicyWB & operator=(const ImageCacheWritePolicyWB &other)
void flushPage(ImageContainer *anImageContainer)
ImageCacheWritePolicyWB(const ImageCacheWritePolicyWB &other)
BOOST_CONCEPT_ASSERT((concepts::CImageFactory< TImageFactory >))
ImageCacheWritePolicyWB(Alias< ImageFactory > anImageFactory)
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
ImageFactory * myImageFactory
Alias on the image factory.
void writeInPage(ImageContainer *anImageContainer, const Point &aPoint, const Value &aValue)
Aim: implements a 'WT (Write-through)' write policy cache.
ImageCacheWritePolicyWT(Alias< ImageFactory > anImageFactory)
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
void flushPage(ImageContainer *anImageContainer)
void writeInPage(ImageContainer *anImageContainer, const Point &aPoint, const Value &aValue)
ImageCacheWritePolicyWT(const ImageCacheWritePolicyWT &other)
ImageCacheWritePolicyWT & operator=(const ImageCacheWritePolicyWT &other)
ImageFactory * myImageFactory
Alias on the image factory.
BOOST_CONCEPT_ASSERT((concepts::CImageFactory< TImageFactory >))
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines the concept describing an image factory.
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition CImage.h:103
const Point aPoint(3, 4)
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer