ParaView
vtkCacheSizeKeeper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkCacheSizeKeeper.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
24 #ifndef vtkCacheSizeKeeper_h
25 #define vtkCacheSizeKeeper_h
26 
27 #include "vtkObject.h"
28 #include "vtkPVClientServerCoreRenderingModule.h" //needed for exports
29 
30 class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkCacheSizeKeeper : public vtkObject
31 {
32 public:
33  vtkTypeMacro(vtkCacheSizeKeeper, vtkObject);
34  void PrintSelf(ostream& os, vtkIndent indent);
35 
39  static vtkCacheSizeKeeper* GetInstance();
40 
42 
45  void AddCacheSize(unsigned long kbytes)
46  {
47  if (this->CacheFull)
48  {
49  vtkErrorMacro("Cache is full. Cannot add more cached data.");
50  }
51  else
52  {
53  this->CacheSize += kbytes;
54  }
55  }
57 
61  void FreeCacheSize(unsigned long kbytes)
62  {
63  this->CacheSize = (this->CacheSize > kbytes) ? (this->CacheSize - kbytes) : 0;
64  }
65 
67 
70  vtkGetMacro(CacheSize, unsigned long);
72 
74 
79  vtkGetMacro(CacheLimit, unsigned long);
80  vtkSetMacro(CacheLimit, unsigned long);
82 
84 
87  vtkGetMacro(CacheFull, int);
88  vtkSetMacro(CacheFull, int);
90 
91 protected:
92  static vtkCacheSizeKeeper* New();
95 
96  unsigned long CacheSize;
97  unsigned long CacheLimit;
98  int CacheFull;
99 
100 private:
101  vtkCacheSizeKeeper(const vtkCacheSizeKeeper&) VTK_DELETE_FUNCTION;
102  void operator=(const vtkCacheSizeKeeper&) VTK_DELETE_FUNCTION;
103 };
104 
105 #endif
keeps track of amount of memory consumed by caches in vtkPVUpateSupressor objects.
void FreeCacheSize(unsigned long kbytes)
Report decrease in cache size (in bytes).
void AddCacheSize(unsigned long kbytes)
Report increase in cache size (in kbytes).
unsigned long CacheLimit
unsigned long CacheSize