-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReload.h
110 lines (91 loc) · 2.09 KB
/
Reload.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef BaseLib_Policy_Reload_h_IsIncluded
#define BaseLib_Policy_Reload_h_IsIncluded
#include"BaseLib/Templates/BaseTypes.h"
#include"BaseLib/Export.h"
namespace BaseLib { namespace Policy
{
namespace ReloadKind
{
enum Type
{
NO,
ON_CREATE,
ON_DELETE,
ON_MODIFY,
/**
* Enables refreshing the cache without cleanup or access to cache.
* Rather, it is based on timer
*/
ON_REFRESH
};
}
/**
* @brief The Reload class
*
* TODO: Rename to Load (Load on expiry)?
* TODO: store kind as a list internally to support multiple
*/
class DLL_STATE Reload
: public Templates::ComparableImmutableType<ReloadKind::Type>
{
public:
Reload(ReloadKind::Type kind)
: Templates::ComparableImmutableType<ReloadKind::Type>(kind)
{}
virtual ~Reload()
{}
ReloadKind::Type Kind() const
{
return this->Clone();
}
bool IsNo() const
{
return this->Clone() == ReloadKind::NO;
}
bool IsOnCreate() const
{
return this->Clone() == ReloadKind::ON_CREATE;
}
bool IsOnDelete() const
{
return this->Clone() == ReloadKind::ON_DELETE;
}
bool IsOnModify() const
{
return this->Clone() == ReloadKind::ON_MODIFY;
}
bool IsOnRefresh() const
{
return this->Clone() == ReloadKind::ON_REFRESH;
}
//---------------------------------------------------
// factory functions
//---------------------------------------------------
static Reload No()
{
static Reload reload(ReloadKind::NO);
return reload;
}
static Reload OnCreate()
{
static Reload reload(ReloadKind::ON_CREATE);
return reload;
}
static Reload OnDelete()
{
static Reload reload(ReloadKind::ON_DELETE);
return reload;
}
static Reload OnModify()
{
static Reload reload(ReloadKind::ON_MODIFY);
return reload;
}
static Reload OnRefresh()
{
static Reload reload(ReloadKind::ON_REFRESH);
return reload;
}
};
}}
#endif