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
|
/*
# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# --------------------------------------------------------------------------
# detail/systemTraits.h:
# - Define system traits and provide a way to match against them
# --------------------------------------------------------------------------
*/
#ifndef SYSTEMTRAITS_H_
#define SYSTEMTRAITS_H_
#include "typeList.h"
#define DEFINE_SYSTEM_TRAIT(name) struct name;
#define BEGIN_SYSTEM_TRAITS typedef TypeList<
#define END_SYSTEM_TRAITS > SystemTraits;
namespace input_policy
{
// Trait names are externally visible.
DEFINE_SYSTEM_TRAIT(UnixLike)
DEFINE_SYSTEM_TRAIT(LinuxSystem)
DEFINE_SYSTEM_TRAIT(X11GUI)
DEFINE_SYSTEM_TRAIT(ConsoleKitSupported)
namespace detail
{
BEGIN_SYSTEM_TRAITS
#ifdef __linux
UnixLike,
LinuxSystem,
X11GUI,
ConsoleKitSupported
#endif
END_SYSTEM_TRAITS
}
/////////////////////////////////////////////////////////////////////////
// Boolean logic as applied to system traits
/////////////////////////////////////////////////////////////////////////
template<IMPLICIT_TYPE_LIST_PARAMS(T)>
struct AllOf;
template<IMPLICIT_TYPE_LIST_PARAMS(T)>
struct AnyOf;
namespace detail
{
/////////////////////////////////////////////////////////////////////////
// Does the list of system traits match what we have given?
/////////////////////////////////////////////////////////////////////////
template<typename Needles, typename Haystack>
struct Matches
{
// if Needles is neither AnyOf<...> nor AllOf<...>
// then we need to know if the Haystack contains it:
static const bool value = Contains<Needles, Haystack>::value;
};
template<typename Haystack>
struct MatchesPredicate
{
template<typename Needle>
struct apply
{
static const bool value = Matches<Needle, Haystack>::value;
};
};
template<IMPLICIT_TYPE_LIST_PARAMS_NODEFAULT(T), typename Haystack>
struct Matches<AnyOf<IMPLICIT_TYPE_LIST_ARGS(T)>, Haystack>
{
static const bool value = ForAnyInTypeList<MatchesPredicate<Haystack>, IMPLICIT_TYPE_LIST(T)>::value;
};
template<IMPLICIT_TYPE_LIST_PARAMS_NODEFAULT(T), typename Haystack>
struct Matches<AllOf<IMPLICIT_TYPE_LIST_ARGS(T)>, Haystack>
{
static const bool value = ForAllInTypeList<MatchesPredicate<Haystack>, IMPLICIT_TYPE_LIST(T)>::value;
};
}
}
#endif /* SYSTEMTRAITS_H_ */
|