-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.h
More file actions
35 lines (32 loc) · 792 Bytes
/
controller.h
File metadata and controls
35 lines (32 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <memory>
#include <functional>
#include <type_traits>
class CDatabase;
class CController
{
public:
CController();
virtual ~CController();
protected:
std::unique_ptr<CDatabase> m_db;
public:
void Enter();
void Exit(bool commit = true);
int test(int t);
};
//template<typename T, typename U, typename...Args> struct RunOperation;
template<typename T, typename U, typename...Args>
typename std::result_of<U(T, Args...)>::type RunOperation(T&& controller, U&& function, Args...args)
{
try {
controller.Enter();
auto res = std::bind(function, &controller, args...)();
controller.Exit();
return res;
} catch (...) {
controller.Exit(false);
}
}
#endif // CONTROLLER_H