fw4spl
IPolicy.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_IPOLICY_HPP__
8 #define __FWMEMORY_IPOLICY_HPP__
9 
10 #include "fwMemory/BufferInfo.hpp"
11 #include "fwMemory/BufferManager.hpp"
12 #include "fwMemory/config.hpp"
13 #include "fwMemory/policy/factory/new.hpp"
14 
15 #include <fwCore/base.hpp>
16 
17 namespace fwMemory
18 {
19 
23 class FWMEMORY_CLASS_API IPolicy : public fwCore::BaseObject
24 {
25 public:
26 
27  typedef SPTR (IPolicy) sptr;
28  typedef std::vector<std::string> ParamNamesType;
29 
30  virtual void allocationRequest(BufferInfo& info,
31  ::fwMemory::BufferManager::ConstBufferPtrType buffer,
32  BufferInfo::SizeType size ) = 0;
33 
34  virtual void setRequest(BufferInfo& info,
35  ::fwMemory::BufferManager::ConstBufferPtrType buffer, BufferInfo::SizeType size ) = 0;
36 
37  virtual void reallocateRequest(BufferInfo& info,
38  ::fwMemory::BufferManager::ConstBufferPtrType buffer,
39  BufferInfo::SizeType newSize ) = 0;
40 
41  virtual void destroyRequest(BufferInfo& info, ::fwMemory::BufferManager::ConstBufferPtrType buffer ) = 0;
42 
43  virtual void lockRequest(BufferInfo& info, ::fwMemory::BufferManager::ConstBufferPtrType buffer ) = 0;
44  virtual void unlockRequest(BufferInfo& info, ::fwMemory::BufferManager::ConstBufferPtrType buffer ) = 0;
45 
46  virtual void dumpSuccess( BufferInfo& info, ::fwMemory::BufferManager::ConstBufferPtrType buffer ) = 0;
47  virtual void restoreSuccess( BufferInfo& info, ::fwMemory::BufferManager::ConstBufferPtrType buffer ) = 0;
48 
49  virtual void refresh() = 0;
50 
51  virtual bool setParam(const std::string& name, const std::string& value) = 0;
52  virtual std::string getParam(const std::string& name, bool* ok = NULL ) const = 0;
53  virtual const ParamNamesType& getParamNames() const = 0;
54 
55  template <typename T>
56  class Registrar
57  {
58  public:
59  Registrar()
60  {
61  ::fwMemory::policy::registry::get()->addFactory(T::leafClassname(), &::fwMemory::policy::factory::New<T>);
62  }
63  };
64 
65 };
66 
67 } // namespace fwMemory
68 
69 #endif // __FWMEMORY_IPOLICY_HPP__
70 
#define SPTR(_cls_)
Base class for all FW4SPL&#39;s classes.
Definition: BaseObject.hpp:22
The namespace fwMemory contains tools to manage memory. Use for dump.
Definition: SReader.hpp:20
Defines the memory dump policy interface.
Definition: IPolicy.hpp:23