MythTV  master
cleanup.h
Go to the documentation of this file.
1 #ifndef CLEANUP_H_
2 #define CLEANUP_H_
3 
4 #include "mythmetaexp.h"
5 
7 {
8  public:
9  virtual void doClean() = 0;
10  virtual ~CleanupProc() = default;
11 };
12 
14 {
15  public:
16  static CleanupHooks *getInstance();
17 
18  public:
19  void addHook(CleanupProc *clean_proc);
20  void removeHook(CleanupProc *clean_proc);
21  void cleanup();
22 
23  private:
24  CleanupHooks();
25  ~CleanupHooks();
26  class CleanupHooksImp *m_imp {nullptr};
27 };
28 
29 template <typename T>
31 {
32  public:
33  explicit SimpleCleanup(T *inst) : m_inst(inst)
34  {
36  }
37 
39  {
41  }
42 
43  void doClean() override // CleanupProc
44  {
45  m_inst->cleanup();
46  }
47 
48  private:
49  T *m_inst {nullptr};
50 };
51 
52 #endif // CLEANUP_H_
void removeHook(CleanupProc *clean_proc)
Definition: cleanup.cpp:58
void addHook(CleanupProc *clean_proc)
Definition: cleanup.cpp:53
void doClean() override
Definition: cleanup.h:43
#define META_PUBLIC
Definition: mythmetaexp.h:9
~SimpleCleanup()
Definition: cleanup.h:38
static QString cleanup(const QString &str)
static CleanupHooks * getInstance()
Definition: cleanup.cpp:44
SimpleCleanup(T *inst)
Definition: cleanup.h:33