-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComposition.h
104 lines (85 loc) · 2.08 KB
/
Composition.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
#ifndef BaseLib_Policy_Composition_h_IsIncluded
#define BaseLib_Policy_Composition_h_IsIncluded
#include"BaseLib/Templates/BaseTypes.h"
#include"BaseLib/Export.h"
namespace BaseLib { namespace Policy
{
/**
* Use to combine the results of commands (aggregate, etc). Aka. function composition.
*/
namespace CompositionKind
{
enum Type
{
NO,
AGGREGATE,
INDIVIDUAL,
MINIMUM,
MAXIMUM
};
}
/**
* @brief The Composition class
*/
class DLL_STATE Composition : public Templates::ComparableImmutableType<CompositionKind::Type>
{
public:
Composition(CompositionKind::Type kind = CompositionKind::INDIVIDUAL)
: Templates::ComparableImmutableType<CompositionKind::Type>(kind)
{}
virtual ~Composition()
{}
// -----------------------------------------
// Getters
// -----------------------------------------
CompositionKind::Type Kind() const
{
return this->Clone();
}
bool IsNo() const
{
return this->delegate() == CompositionKind::NO;
}
bool IsAggregate() const
{
return this->delegate() == CompositionKind::AGGREGATE;
}
bool IsIndividual() const
{
return this->delegate() == CompositionKind::INDIVIDUAL;
}
bool IsMinimum() const
{
return this->delegate() == CompositionKind::MINIMUM;
}
bool IsMaximum() const
{
return this->delegate() == CompositionKind::MAXIMUM;
}
public:
// --------------------------------------------
// Static constructors
// --------------------------------------------
static Composition No()
{
return Composition(CompositionKind::NO);
}
static Composition Aggregate()
{
return Composition(CompositionKind::AGGREGATE);
}
static Composition Individual()
{
return Composition(CompositionKind::INDIVIDUAL);
}
static Composition Minimum()
{
return Composition(CompositionKind::MINIMUM);
}
static Composition Maximum()
{
return Composition(CompositionKind::MAXIMUM);
}
};
}}
#endif