DGtal  0.9.2
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)
34 
35 #define ImageCachePolicies_RECURSES
36 
37 #if !defined ImageCachePolicies_h
38 
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 
87  typedef TImageContainer ImageContainer;
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 
119  ImageContainer * getPage(const Point & aPoint);
120 
129  ImageContainer * getPage(const Domain & aDomain);
130 
137  ImageContainer * getPageToDetach();
138 
144  void updateCache(const Domain &aDomain);
145 
149  void clearCache();
150 
151 protected:
152 
154  ImageContainer * myCacheImagesPtr;
155 
157  ImageFactory * myImageFactory;
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 
192  typedef TImageContainer ImageContainer;
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 
224  ImageContainer * getPage(const Point & aPoint);
225 
234  ImageContainer * getPage(const Domain & aDomain);
235 
242  ImageContainer * getPageToDetach();
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 
265  ImageFactory * myImageFactory;
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 
296  typedef TImageContainer ImageContainer;
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 
340  ImageFactory * myImageFactory;
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 
372  typedef TImageContainer ImageContainer;
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 
416  ImageFactory * myImageFactory;
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)
ImageFactory * myImageFactory
Alias on the image factory.
Aim: implements a 'WB (Write-back or Write-behind)' write policy cache.
void updateCache(const Domain &aDomain)
ImageFactory * myImageFactory
Alias on the image factory.
Aim: implements a 'LAST' read policy cache.
TImageContainer::Domain Domain
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: Alias.h:182
ImageCacheWritePolicyWB & operator=(const ImageCacheWritePolicyWB &other)
void updateCache(const Domain &aDomain)
ImageCacheReadPolicyFIFO(Alias< ImageFactory > anImageFactory, int aFIFOSizeMax=10)
TImageContainer::Domain Domain
void writeInPage(ImageContainer *anImageContainer, const Point &aPoint, const Value &aValue)
ImageFactory * myImageFactory
Alias on the image factory.
ImageCacheWritePolicyWT(Alias< ImageFactory > anImageFactory)
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
ImageContainer * getPageToDetach()
ImageContainer * getPage(const Point &aPoint)
void flushPage(ImageContainer *anImageContainer)
ImageCacheWritePolicyWT & operator=(const ImageCacheWritePolicyWT &other)
ImageContainer * myCacheImagesPtr
Alias on the images cache.
TImageContainer::Domain Domain
ImageCacheReadPolicyLAST(Alias< ImageFactory > anImageFactory)
Aim: Defines the concept describing an image factory.
Definition: CImageFactory.h:90
Aim: implements a 'WT (Write-through)' write policy cache.
ImageCacheReadPolicyLAST & operator=(const ImageCacheReadPolicyLAST &other)
DGtal is the top-level namespace which contains all DGtal functions and types.
ImageCacheReadPolicyFIFO & operator=(const ImageCacheReadPolicyFIFO &other)
void writeInPage(ImageContainer *anImageContainer, const Point &aPoint, const Value &aValue)
ImageFactory * myImageFactory
Alias on the image factory.
unsigned int myFIFOSizeMax
Size max of the FIFO.
ImageContainer * getPage(const Point &aPoint)
TImageContainer::Domain Domain
Aim: implements a 'FIFO' read policy cache.
ImageCacheWritePolicyWB(Alias< ImageFactory > anImageFactory)
void flushPage(ImageContainer *anImageContainer)
ImageContainer * getPageToDetach()
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
std::deque< ImageContainer * > myFIFOCacheImages
Alias on the images cache.
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:102
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.