ModuleDeleter.hpp
1 #ifndef OPALS_MODULE_DELETER_HPP_INCLUDED
2 #define OPALS_MODULE_DELETER_HPP_INCLUDED
3 
4 #include "opals/IModuleBase.hpp"
5 
6 namespace opals
7 {
8  /**
9  \struct ModuleDeleter
10  \brief A functor that may be used for memory management of modules allocated on the heap
11  usage: e.g. std::shared_ptr<IGrid> grid( opals::IGrid::New(), opals::ModuleDeleter() );
12 
13  \author wk
14  \date 20.12.2011
15  */
17  {
18  void operator()(opals::IModuleBase *ptr) const
19  {
20  if(ptr)
21  ptr->Delete();
22  ptr = 0;
23  }
24  };
25 }
26 
27 #endif // OPALS_MODULE_DELETER_HPP_INCLUDED