AusweisApp2
ScopeGuard.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
9 #include <functional>
10 #include <QtGlobal>
11 
12 class test_ScopeGuard;
13 
14 namespace governikus
15 {
16 
17 QT_WARNING_PUSH
18  QT_WARNING_DISABLE_DEPRECATED
19 
20 class [[deprecated ("Use qScopeGuard")]] ScopeGuard
21 {
22  private:
23  friend class ::test_ScopeGuard;
24  friend ScopeGuard qScopeGuard(const std::function<void()>& pFunc);
25 
26  const std::function<void()> mFunction;
27  bool mEnabled;
28 
29  ScopeGuard(const std::function<void()>& pFunc, bool pEnabled = true);
30 
31  bool isEnabled() const;
32  void setEnabled(bool pEnabled = true);
33 
34  public:
35  ScopeGuard(const ScopeGuard& pCopy) = delete;
36  ScopeGuard(const ScopeGuard&& pCopy) = delete;
37  ScopeGuard& operator=(const ScopeGuard& pCopy) = delete;
38  ScopeGuard& operator=(const ScopeGuard&& pCopy) = delete;
39 
40  ~ScopeGuard();
41 
42  void dismiss()
43  {
44  setEnabled(false);
45  }
46 
47 
48 };
49 
50 #if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
51 inline ScopeGuard qScopeGuard(const std::function<void()>& pFunc)
52 {
53  return ScopeGuard(pFunc);
54 }
55 
56 
57 #endif
58 
59 QT_WARNING_POP
60 
61 } // namespace governikus
governikus::ScopeGuard::qScopeGuard
friend ScopeGuard qScopeGuard(const std::function< void()> &pFunc)
governikus::ScopeGuard::operator=
ScopeGuard & operator=(const ScopeGuard &pCopy)=delete
governikus::ScopeGuard::operator=
ScopeGuard & operator=(const ScopeGuard &&pCopy)=delete
governikus::ScopeGuard::ScopeGuard
ScopeGuard(const ScopeGuard &&pCopy)=delete
governikus::ScopeGuard::ScopeGuard
ScopeGuard(const ScopeGuard &pCopy)=delete
governikus
Implementation of ActivationContext for Intent based activation on Android systems.
Definition: ActivationContext.h:15
governikus::ScopeGuard::dismiss
void dismiss()
Definition: ScopeGuard.h:42
test_ScopeGuard
Definition: test_ScopeGuard.cpp:19
governikus::ScopeGuard
Definition: ScopeGuard.h:21
governikus::ScopeGuard::~ScopeGuard
~ScopeGuard()
Definition: ScopeGuard.cpp:22
ScopeGuard.h