/* # 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 struct AllOf; template struct AnyOf; namespace detail { ///////////////////////////////////////////////////////////////////////// // Does the list of system traits match what we have given? ///////////////////////////////////////////////////////////////////////// template struct Matches { // if Needles is neither AnyOf<...> nor AllOf<...> // then we need to know if the Haystack contains it: static const bool value = Contains::value; }; template struct MatchesPredicate { template struct apply { static const bool value = Matches::value; }; }; template struct Matches, Haystack> { static const bool value = ForAnyInTypeList, IMPLICIT_TYPE_LIST(T)>::value; }; template struct Matches, Haystack> { static const bool value = ForAllInTypeList, IMPLICIT_TYPE_LIST(T)>::value; }; } } #endif /* SYSTEMTRAITS_H_ */