fw4spl
ValveDump.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWMEMORY_POLICY_VALVEDUMP_HPP__
8 #define __FWMEMORY_POLICY_VALVEDUMP_HPP__
9 
10 #include "fwMemory/BufferInfo.hpp"
11 #include "fwMemory/BufferManager.hpp"
12 #include "fwMemory/config.hpp"
13 #include "fwMemory/IPolicy.hpp"
14 #include "fwMemory/policy/factory/new.hpp"
15 
16 #include <fwCore/base.hpp>
17 
18 namespace fwMemory
19 {
20 
21 namespace policy
22 {
23 
35 class FWMEMORY_CLASS_API ValveDump : public fwMemory::IPolicy
36 {
37 public:
39  (()),
40  ::fwMemory::policy::factory::New< ValveDump >)
41 
42  FWMEMORY_API ValveDump();
43 
44  FWMEMORY_API virtual void allocationRequest( BufferInfo& info,
45  ::fwMemory::BufferManager::ConstBufferPtrType buffer,
46  BufferInfo::SizeType size ) override;
47  FWMEMORY_API virtual void setRequest( BufferInfo& info,
48  ::fwMemory::BufferManager::ConstBufferPtrType buffer,
49  BufferInfo::SizeType size ) override;
50  FWMEMORY_API virtual void reallocateRequest( BufferInfo& info,
51  ::fwMemory::BufferManager::ConstBufferPtrType buffer,
52  BufferInfo::SizeType newSize ) override;
53 
54  FWMEMORY_API virtual void destroyRequest( BufferInfo& info,
55  ::fwMemory::BufferManager::ConstBufferPtrType buffer ) override;
56 
57  FWMEMORY_API virtual void lockRequest( BufferInfo& info,
58  ::fwMemory::BufferManager::ConstBufferPtrType buffer ) override;
59  FWMEMORY_API virtual void unlockRequest( BufferInfo& info,
60  ::fwMemory::BufferManager::ConstBufferPtrType buffer ) override;
61 
62  FWMEMORY_API virtual void dumpSuccess( BufferInfo& info,
63  ::fwMemory::BufferManager::ConstBufferPtrType buffer ) override;
64  FWMEMORY_API virtual void restoreSuccess( BufferInfo& info,
65  ::fwMemory::BufferManager::ConstBufferPtrType buffer ) override;
66 
67  FWMEMORY_API virtual void refresh() override;
68 
69  FWMEMORY_API bool setParam(const std::string& name, const std::string& value) override;
70  FWMEMORY_API virtual std::string getParam(const std::string& name, bool* ok = NULL ) const override;
71  FWMEMORY_API const ::fwMemory::IPolicy::ParamNamesType& getParamNames() const override;
72 
73 protected:
74 
75  FWMEMORY_API bool needDump(size_t supplement) const;
76 
77  FWMEMORY_API size_t dump(size_t nbOfBytes);
78 
79  FWMEMORY_API void apply(size_t supplement = 0);
80 
81  size_t m_minFreeMem;
82  size_t m_hysteresisOffset;
83 };
84 
85 } // namespace policy
86 
87 } // namespace fwMemory
88 
89 #endif // __FWMEMORY_POLICY_VALVEDUMP_HPP__
90 
The namespace fwMemory contains tools to manage memory. Use for dump.
Definition: SReader.hpp:20
STL namespace.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
Valve dump policy.
Definition: ValveDump.hpp:35
BufferManager implementation.
Defines the memory dump policy interface.
Definition: IPolicy.hpp:23