Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
berryAsyncRunnable.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #ifndef BERRYASYNCRUNNABLE_H_
15 #define BERRYASYNCRUNNABLE_H_
16 
17 #include <Poco/ActiveRunnable.h>
18 
19 namespace berry {
20 
26 template <class ArgType, class OwnerType>
27 class AsyncRunnable : public Poco::ActiveRunnableBase
28 {
29 public:
30  typedef void (OwnerType::*Callback)(const ArgType&);
31 
32  AsyncRunnable(OwnerType* pOwner, Callback method, const ArgType& arg):
33  _pOwner(pOwner),
34  _method(method),
35  _arg(arg)
36  {
37  poco_check_ptr (pOwner);
38  }
39 
40  void run() override
41  {
42  ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
43  (_pOwner->*_method)(_arg);
44  }
45 
46 private:
47  OwnerType* _pOwner;
48  Callback _method;
49  ArgType _arg;
50 };
51 
52 }
53 
54 #endif /* BERRYASYNCRUNNABLE_H_ */
berry::AsyncRunnable::AsyncRunnable
AsyncRunnable(OwnerType *pOwner, Callback method, const ArgType &arg)
Definition: berryAsyncRunnable.h:32
berry::AsyncRunnable::Callback
void(OwnerType::* Callback)(const ArgType &)
Definition: berryAsyncRunnable.h:30
berry::AsyncRunnable::run
void run() override
Definition: berryAsyncRunnable.h:40
berry::AsyncRunnable
Definition: berryAsyncRunnable.h:27
berry
Definition: QmitkPropertyItemModel.h:24