DGtal  1.3.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)
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 
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 
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 
224  ImageContainer * getPage(const Point & aPoint);
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)
DGtal::ImageCacheWritePolicyWT::myImageFactory
ImageFactory * myImageFactory
Alias on the image factory.
Definition: ImageCachePolicies.h:340
DGtal::ImageCacheWritePolicyWB::Value
TImageContainer::Value Value
Definition: ImageCachePolicies.h:375
DGtal::ImageCacheWritePolicyWT::Value
TImageContainer::Value Value
Definition: ImageCachePolicies.h:299
DGtal::ImageCacheReadPolicyFIFO::ImageFactory
TImageFactory ImageFactory
Definition: ImageCachePolicies.h:190
DGtal::ImageCacheWritePolicyWB::flushPage
void flushPage(ImageContainer *anImageContainer)
DGtal::ImageCacheReadPolicyFIFO::myFIFOCacheImages
std::deque< ImageContainer * > myFIFOCacheImages
Alias on the images cache.
Definition: ImageCachePolicies.h:259
DGtal::ImageCacheReadPolicyLAST::getPageToDetach
ImageContainer * getPageToDetach()
DGtal::ImageContainerBySTLVector::Domain
TDomain Domain
Definition: ImageContainerBySTLVector.h:137
DGtal::ImageContainerBySTLVector::Value
TValue Value
Definition: ImageContainerBySTLVector.h:153
DGtal::ImageCacheWritePolicyWT::~ImageCacheWritePolicyWT
~ImageCacheWritePolicyWT()
Definition: ImageCachePolicies.h:310
DGtal::ImageContainerBySTLVector
Definition: ImageContainerBySTLVector.h:126
DGtal::ImageCacheWritePolicyWT::operator=
ImageCacheWritePolicyWT & operator=(const ImageCacheWritePolicyWT &other)
DGtal::ImageCacheWritePolicyWT::ImageCacheWritePolicyWT
ImageCacheWritePolicyWT(Alias< ImageFactory > anImageFactory)
Definition: ImageCachePolicies.h:301
DGtal::ImageCacheReadPolicyFIFO::getPage
ImageContainer * getPage(const Point &aPoint)
DGtal::ImageCacheReadPolicyLAST::clearCache
void clearCache()
aPoint
const Point aPoint(3, 4)
DGtal::ImageCacheReadPolicyLAST::Value
TImageContainer::Value Value
Definition: ImageCachePolicies.h:90
DGtal::ImageCacheWritePolicyWT::flushPage
void flushPage(ImageContainer *anImageContainer)
DGtal::ImageCacheReadPolicyFIFO::updateCache
void updateCache(const Domain &aDomain)
DGtal::ImageCacheReadPolicyLAST
Aim: implements a 'LAST' read policy cache.
Definition: ImageCachePolicies.h:77
DGtal::ImageCacheWritePolicyWB::operator=
ImageCacheWritePolicyWB & operator=(const ImageCacheWritePolicyWB &other)
DGtal::ImageCacheReadPolicyLAST::getPage
ImageContainer * getPage(const Point &aPoint)
DGtal::ImageCacheWritePolicyWB::writeInPage
void writeInPage(ImageContainer *anImageContainer, const Point &aPoint, const Value &aValue)
DGtal::ImageCacheReadPolicyFIFO::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
DGtal::ImageCacheReadPolicyFIFO::myFIFOSizeMax
unsigned int myFIFOSizeMax
Size max of the FIFO.
Definition: ImageCachePolicies.h:262
DGtal::ImageCacheReadPolicyFIFO::clearCache
void clearCache()
DGtal::ImageCacheWritePolicyWB::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Domain
HyperRectDomain< Space > Domain
Definition: testSimpleRandomAccessRangeFromPoint.cpp:44
DGtal::ImageCacheReadPolicyFIFO::~ImageCacheReadPolicyFIFO
~ImageCacheReadPolicyFIFO()
Definition: ImageCachePolicies.h:206
DGtal::ImageCacheWritePolicyWT::Domain
TImageContainer::Domain Domain
Definition: ImageCachePolicies.h:297
DGtal::ImageCacheReadPolicyLAST::myImageFactory
ImageFactory * myImageFactory
Alias on the image factory.
Definition: ImageCachePolicies.h:157
DGtal::ImageCacheReadPolicyLAST::Point
TImageContainer::Point Point
Definition: ImageCachePolicies.h:89
DGtal::ImageCacheReadPolicyFIFO::getPageToDetach
ImageContainer * getPageToDetach()
DGtal::ImageCacheReadPolicyFIFO::Domain
TImageContainer::Domain Domain
Definition: ImageCachePolicies.h:193
DGtal::ImageCacheReadPolicyLAST::ImageContainer
TImageContainer ImageContainer
Definition: ImageCachePolicies.h:87
DGtal::ImageCacheReadPolicyLAST::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
DGtal::ImageCacheReadPolicyFIFO::Point
TImageContainer::Point Point
Definition: ImageCachePolicies.h:194
DGtal::ImageCacheWritePolicyWB::ImageCacheWritePolicyWB
ImageCacheWritePolicyWB(Alias< ImageFactory > anImageFactory)
Definition: ImageCachePolicies.h:377
DGtal::ImageCacheReadPolicyFIFO::operator=
ImageCacheReadPolicyFIFO & operator=(const ImageCacheReadPolicyFIFO &other)
DGtal::ImageCacheReadPolicyFIFO::Value
TImageContainer::Value Value
Definition: ImageCachePolicies.h:195
DGtal::ImageCacheReadPolicyFIFO::myImageFactory
ImageFactory * myImageFactory
Alias on the image factory.
Definition: ImageCachePolicies.h:265
DGtal::ImageCacheWritePolicyWB::Point
TImageContainer::Point Point
Definition: ImageCachePolicies.h:374
DGtal::ImageCacheWritePolicyWT::Point
TImageContainer::Point Point
Definition: ImageCachePolicies.h:298
DGtal::ImageCacheReadPolicyLAST::ImageCacheReadPolicyLAST
ImageCacheReadPolicyLAST(Alias< ImageFactory > anImageFactory)
Definition: ImageCachePolicies.h:92
DGtal::ImageCacheReadPolicyLAST::myCacheImagesPtr
ImageContainer * myCacheImagesPtr
Alias on the images cache.
Definition: ImageCachePolicies.h:154
DGtal::PointVector< dim, Integer >
DGtal::ImageCacheReadPolicyLAST::ImageFactory
TImageFactory ImageFactory
Definition: ImageCachePolicies.h:85
DGtal::ImageCacheWritePolicyWB::Domain
TImageContainer::Domain Domain
Definition: ImageCachePolicies.h:373
DGtal::ImageCacheWritePolicyWB::~ImageCacheWritePolicyWB
~ImageCacheWritePolicyWB()
Definition: ImageCachePolicies.h:386
DGtal::ImageCacheWritePolicyWT::ImageFactory
TImageFactory ImageFactory
Definition: ImageCachePolicies.h:294
DGtal::ImageCacheReadPolicyLAST::Domain
TImageContainer::Domain Domain
Definition: ImageCachePolicies.h:88
DGtal::ImageCacheWritePolicyWB::myImageFactory
ImageFactory * myImageFactory
Alias on the image factory.
Definition: ImageCachePolicies.h:416
DGtal::Alias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: Alias.h:182
DGtal::concepts::CImageFactory
Aim: Defines the concept describing an image factory.
Definition: CImageFactory.h:90
DGtal::ImageCacheReadPolicyFIFO::ImageCacheReadPolicyFIFO
ImageCacheReadPolicyFIFO(Alias< ImageFactory > anImageFactory, int aFIFOSizeMax=10)
Definition: ImageCachePolicies.h:197
DGtal::ImageCacheWritePolicyWB::ImageFactory
TImageFactory ImageFactory
Definition: ImageCachePolicies.h:370
DGtal::ImageCacheReadPolicyFIFO
Aim: implements a 'FIFO' read policy cache.
Definition: ImageCachePolicies.h:182
TImageContainer
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer
Definition: testVoronoiMapComplete.cpp:49
DGtal::ImageCacheWritePolicyWB
Aim: implements a 'WB (Write-back or Write-behind)' write policy cache.
Definition: ImageCachePolicies.h:362
DGtal::ImageCacheWritePolicyWT::writeInPage
void writeInPage(ImageContainer *anImageContainer, const Point &aPoint, const Value &aValue)
DGtal::ImageCacheWritePolicyWT
Aim: implements a 'WT (Write-through)' write policy cache.
Definition: ImageCachePolicies.h:286
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::ImageCacheWritePolicyWT::ImageContainer
TImageContainer ImageContainer
Definition: ImageCachePolicies.h:296
DGtal::ImageCacheWritePolicyWT::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::ImageCacheReadPolicyLAST::operator=
ImageCacheReadPolicyLAST & operator=(const ImageCacheReadPolicyLAST &other)
DGtal::ImageCacheReadPolicyLAST::~ImageCacheReadPolicyLAST
~ImageCacheReadPolicyLAST()
Definition: ImageCachePolicies.h:101
DGtal::ImageCacheReadPolicyFIFO::ImageContainer
TImageContainer ImageContainer
Definition: ImageCachePolicies.h:192
DGtal::ImageCacheReadPolicyLAST::updateCache
void updateCache(const Domain &aDomain)
DGtal::concepts::CImage
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:102
DGtal::ImageCacheWritePolicyWB::ImageContainer
TImageContainer ImageContainer
Definition: ImageCachePolicies.h:372