]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/msm/include/boost/msm/back/args.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / msm / include / boost / msm / back / args.hpp
CommitLineData
7c673cae
FG
1// Copyright 2008 Christophe Henry
2// henry UNDERSCORE christophe AT hotmail DOT com
3// This is an extended version of the state machine available in the boost::mpl library
4// Distributed under the same license as the original.
5// Copyright for the original version:
6// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
7// under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10
11#ifndef BOOST_MSM_BACK_ARGS_H
12#define BOOST_MSM_BACK_ARGS_H
13
14#include <boost/preprocessor/repetition/enum_params.hpp>
15#include <boost/preprocessor/arithmetic/sub.hpp>
16#include <boost/preprocessor/punctuation/comma_if.hpp>
17#include <boost/preprocessor/control/expr_if.hpp>
18#include <boost/preprocessor/punctuation/comma.hpp>
19#include <boost/preprocessor/arithmetic/add.hpp>
20#include <boost/preprocessor/cat.hpp>
21#include <boost/preprocessor/comparison/less.hpp>
22#include <boost/preprocessor/arithmetic/dec.hpp>
23#include <boost/function.hpp>
24
25#ifndef BOOST_MSM_VISITOR_ARG_SIZE
26#define BOOST_MSM_VISITOR_ARG_SIZE 2 // default max number of arguments
27#endif
28
29namespace boost { namespace msm { namespace back
30{
31struct no_args {};
32#define MSM_ARGS_TYPEDEF_SUB(z, n, unused) typedef ARG ## n argument ## n ;
33#define MSM_ARGS_PRINT(z, n, data) data
34#define MSM_ARGS_NONE_PRINT(z, n, data) class data ## n = no_args \
35 BOOST_PP_COMMA_IF( BOOST_PP_LESS(n, BOOST_PP_DEC(BOOST_MSM_VISITOR_ARG_SIZE) ) )
36
37#define MSM_VISITOR_MAIN_ARGS(n) \
38 template <class RES, \
39 BOOST_PP_REPEAT(BOOST_MSM_VISITOR_ARG_SIZE, MSM_ARGS_NONE_PRINT, ARG)> \
40 struct args \
41 { \
42 typedef ::boost::function<RES(BOOST_PP_ENUM_PARAMS(n, ARG))> type; \
43 enum {args_number=n}; \
44 BOOST_PP_REPEAT(n, MSM_ARGS_TYPEDEF_SUB, ~ ) \
45 };
46
47#define MSM_VISITOR_ARGS(z, n, unused) \
48 template <class RES BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class ARG)> \
49 struct args<RES, \
50 BOOST_PP_ENUM_PARAMS(n,ARG) \
51 BOOST_PP_COMMA_IF(n) \
52 BOOST_PP_ENUM(BOOST_PP_SUB(BOOST_MSM_VISITOR_ARG_SIZE,n), MSM_ARGS_PRINT, no_args) \
53 > \
54 { \
55 typedef ::boost::function<RES(BOOST_PP_ENUM_PARAMS(n, ARG))> type; \
56 enum {args_number=n}; \
57 BOOST_PP_REPEAT(n, MSM_ARGS_TYPEDEF_SUB, ~ ) \
58 };
59MSM_VISITOR_MAIN_ARGS(BOOST_MSM_VISITOR_ARG_SIZE)
60BOOST_PP_REPEAT(BOOST_MSM_VISITOR_ARG_SIZE, MSM_VISITOR_ARGS, ~)
61
62#undef MSM_VISITOR_ARGS
63#undef MSM_ARGS_PRINT
64
65}}}
66
67#endif //BOOST_MSM_BACK_ARGS_H
68