DGtal  1.5.beta
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 
53 namespace DGtal
54 {
55 
57 // Template class ImageCacheReadPolicyLAST
76 template <typename TImageContainer, typename TImageFactory>
78 {
79 public:
80 
84 
85  typedef TImageFactory ImageFactory;
86 
88  typedef typename TImageContainer::Domain Domain;
89  typedef typename TImageContainer::Point Point;
90  typedef typename TImageContainer::Value Value;
91 
93  myCacheImagesPtr(NULL), myImageFactory(&anImageFactory)
94  {
95  }
96 
102 
103 private:
104 
106 
108 
109 public:
110 
120 
129  ImageContainer * getPage(const Domain & aDomain);
130 
138 
144  void updateCache(const Domain &aDomain);
145 
149  void clearCache();
150 
151 protected:
152 
155 
158 
159 }; // end of class ImageCacheReadPolicyLAST
160 
162 // Template class ImageCacheReadPolicyFIFO
181 template <typename TImageContainer, typename TImageFactory>
183 {
184 public:
185 
189 
190  typedef TImageFactory ImageFactory;
191 
193  typedef typename TImageContainer::Domain Domain;
194  typedef typename TImageContainer::Point Point;
195  typedef typename TImageContainer::Value Value;
196 
197  ImageCacheReadPolicyFIFO(Alias<ImageFactory> anImageFactory, int aFIFOSizeMax=10):
198  myFIFOSizeMax(aFIFOSizeMax), myImageFactory(&anImageFactory)
199  {
200  }
201 
207 
208 private:
209 
211 
213 
214 public:
215 
225 
234  ImageContainer * getPage(const Domain & aDomain);
235 
243 
249  void updateCache(const Domain &aDomain);
250 
254  void clearCache();
255 
256 protected:
257 
259  std::deque <ImageContainer *> myFIFOCacheImages;
260 
262  unsigned int myFIFOSizeMax;
263 
266 
267 }; // end of class ImageCacheReadPolicyFIFO
268 
270 // Template class ImageCacheWritePolicyWT
285 template <typename TImageContainer, typename TImageFactory>
287 {
288 public:
289 
293 
294  typedef TImageFactory ImageFactory;
295 
297  typedef typename TImageContainer::Domain Domain;
298  typedef typename TImageContainer::Point Point;
299  typedef typename TImageContainer::Value Value;
300 
302  myImageFactory(&anImageFactory)
303  {
304  }
305 
311 
312 private:
313 
315 
317 
318 public:
319 
328  void writeInPage(ImageContainer * anImageContainer, const Point & aPoint, const Value &aValue);
329 
335  void flushPage(ImageContainer * anImageContainer);
336 
337 protected:
338 
341 
342 }; // end of class ImageCacheWritePolicyWT
343 
345 // Template class ImageCacheWritePolicyWB
361 template <typename TImageContainer, typename TImageFactory>
363 {
364 public:
365 
369 
370  typedef TImageFactory ImageFactory;
371 
373  typedef typename TImageContainer::Domain Domain;
374  typedef typename TImageContainer::Point Point;
375  typedef typename TImageContainer::Value Value;
376 
378  myImageFactory(&anImageFactory)
379  {
380  }
381 
387 
388 private:
389 
391 
393 
394 public:
395 
404  void writeInPage(ImageContainer * anImageContainer, const Point & aPoint, const Value &aValue);
405 
411  void flushPage(ImageContainer * anImageContainer);
412 
413 protected:
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.
unsigned int myFIFOSizeMax
Size max of the FIFO.
ImageContainer * getPage(const Point &aPoint)
void updateCache(const Domain &aDomain)
std::deque< ImageContainer * > myFIFOCacheImages
Alias on the images cache.
ImageCacheReadPolicyFIFO(const ImageCacheReadPolicyFIFO &other)
ImageContainer * getPage(const Domain &aDomain)
ImageCacheReadPolicyFIFO(Alias< ImageFactory > anImageFactory, int aFIFOSizeMax=10)
ImageContainer * getPageToDetach()
BOOST_CONCEPT_ASSERT((concepts::CImageFactory< TImageFactory >))
TImageContainer::Domain Domain
ImageCacheReadPolicyFIFO & operator=(const ImageCacheReadPolicyFIFO &other)
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
Aim: implements a 'LAST' read policy cache.
ImageContainer * getPage(const Domain &aDomain)
ImageContainer * getPage(const Point &aPoint)
ImageCacheReadPolicyLAST(const ImageCacheReadPolicyLAST &other)
ImageCacheReadPolicyLAST & operator=(const ImageCacheReadPolicyLAST &other)
ImageContainer * getPageToDetach()
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)
ImageCacheReadPolicyLAST(Alias< ImageFactory > anImageFactory)
TImageContainer::Domain Domain
Aim: implements a 'WB (Write-back or Write-behind)' write policy cache.
void flushPage(ImageContainer *anImageContainer)
ImageCacheWritePolicyWB & operator=(const ImageCacheWritePolicyWB &other)
ImageCacheWritePolicyWB(const ImageCacheWritePolicyWB &other)
BOOST_CONCEPT_ASSERT((concepts::CImageFactory< TImageFactory >))
TImageContainer::Domain Domain
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)
ImageFactory * myImageFactory
Alias on the image factory.
ImageCacheWritePolicyWT & operator=(const ImageCacheWritePolicyWT &other)
BOOST_CONCEPT_ASSERT((concepts::CImageFactory< TImageFactory >))
TImageContainer::Domain Domain
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines the concept describing an image factory.
Definition: CImageFactory.h:91
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