/* # 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/policyChain.h: # - Tie together the different bits of policy information a handler may # give us # -------------------------------------------------------------------------- */ #ifndef POLICYCHAIN_H_ #define POLICYCHAIN_H_ #include "typeList.h" namespace input_policy { namespace detail { template struct PolicyChain : public PolicyList::head::template apply_ > { }; template struct PolicyChain : public BaseCase { }; } } ///////////////////////////////////////////////////////////////////////// // Macros that enable specification of policies: // A policy is declared like this: // template< PARAM1, PARAM2, ... > // BEGIN_POLICY_CLASS(MyPolicy) { // static const int field1 = 2; // ... // } END_POLICY_CLASS(MyPolicy); ///////////////////////////////////////////////////////////////////////// #define BEGIN_POLICY_CLASS(policyName) \ struct policyName { \ template \ struct apply_ : public NextPolicy #define END_POLICY_CLASS \ ; }; ///////////////////////////////////////////////////////////////////////// // A macro that enables us to use a template parameter list // in a class using a policy, like this: // // template // struct MyPolicyBasedClass // { // typedef USE_POLICY(baseCase) policy_type; // }; // // now, the following type is valid: // MyPolicyBasedClass ///////////////////////////////////////////////////////////////////////// #define POLICY_PARAMS IMPLICIT_TYPE_LIST_PARAMS(Policy) #define POLICY_PARAMS_LIST IMPLICIT_TYPE_LIST(Policy) #define USE_POLICY(baseCase) ::input_policy::detail::PolicyChain #endif /* POLICYCHAIN_H_ */