|
52 | 52 | #define _VALUE_TYPE_SCALAR 0 |
53 | 53 | #define _VALUE_TYPE_COLUMN 1 |
54 | 54 | #define _VALUE_TYPE_EIGEN_COLUMN 2 |
| 55 | +#define _VALUE_TYPE_METHOD 3 |
| 56 | +#define _VALUE_TYPE_CONST_METHOD 4 |
| 57 | + |
| 58 | +/* declare the value of last valid column */ |
| 59 | +#define _VALUE_LAST_COLUMN_TYPE _VALUE_TYPE_EIGEN_COLUMN |
| 60 | + |
| 61 | +/* declare a macro useful for passing a valid but not used value*/ |
| 62 | +#define _VALUE_TYPE_UNUSED BOOST_PP_LIMIT_MAG |
55 | 63 |
|
56 | 64 | /* The size type need to be "hardcoded" in the template parameters for classes serialized by ROOT */ |
57 | 65 | /* In practice, using a typedef as a template parameter to the Layout or its ViewTemplateFreeParams member |
@@ -571,9 +579,38 @@ namespace cms::soa { |
571 | 579 |
|
572 | 580 | } // namespace cms::soa |
573 | 581 |
|
574 | | -#define SOA_SCALAR(TYPE, NAME) (_VALUE_TYPE_SCALAR, TYPE, NAME) |
575 | | -#define SOA_COLUMN(TYPE, NAME) (_VALUE_TYPE_COLUMN, TYPE, NAME) |
576 | | -#define SOA_EIGEN_COLUMN(TYPE, NAME) (_VALUE_TYPE_EIGEN_COLUMN, TYPE, NAME) |
| 582 | +#define SOA_SCALAR(TYPE, NAME) (_VALUE_TYPE_SCALAR, TYPE, NAME, ~) |
| 583 | +#define SOA_COLUMN(TYPE, NAME) (_VALUE_TYPE_COLUMN, TYPE, NAME, ~) |
| 584 | +#define SOA_EIGEN_COLUMN(TYPE, NAME) (_VALUE_TYPE_EIGEN_COLUMN, TYPE, NAME, ~) |
| 585 | +#define SOA_ELEMENT_METHODS(...) (_VALUE_TYPE_METHOD, _, _, (__VA_ARGS__)) |
| 586 | +#define SOA_CONST_ELEMENT_METHODS(...) (_VALUE_TYPE_CONST_METHOD, _, _, (__VA_ARGS__)) |
| 587 | + |
| 588 | +/* Macro generating customized methods for the element */ |
| 589 | +#define GENERATE_METHODS(R, DATA, FIELD) \ |
| 590 | + BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(0, FIELD), _VALUE_TYPE_METHOD), \ |
| 591 | + BOOST_PP_TUPLE_ELEM(3, FIELD), \ |
| 592 | + BOOST_PP_EMPTY()) |
| 593 | + |
| 594 | +/* Macro generating customized methods for the const element*/ |
| 595 | +#define GENERATE_CONST_METHODS(R, DATA, FIELD) \ |
| 596 | + BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(0, FIELD), _VALUE_TYPE_CONST_METHOD), \ |
| 597 | + BOOST_PP_TUPLE_ELEM(3, FIELD), \ |
| 598 | + BOOST_PP_EMPTY()) |
| 599 | + |
| 600 | +/* Preprocessing loop for managing functions generation: only macros containing valid content are expanded */ |
| 601 | +#define ENUM_FOR_PRED(R, STATE) BOOST_PP_LESS(BOOST_PP_TUPLE_ELEM(0, STATE), BOOST_PP_TUPLE_ELEM(1, STATE)) |
| 602 | + |
| 603 | +#define ENUM_FOR_OP(R, STATE) \ |
| 604 | + (BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(0, STATE)), BOOST_PP_TUPLE_ELEM(1, STATE), BOOST_PP_TUPLE_ELEM(2, STATE)) |
| 605 | + |
| 606 | +#define ENUM_FOR_MACRO(R, STATE) \ |
| 607 | + BOOST_PP_TUPLE_ENUM(BOOST_PP_SEQ_ELEM(BOOST_PP_TUPLE_ELEM(0, STATE), BOOST_PP_TUPLE_ELEM(2, STATE))) |
| 608 | + |
| 609 | +#define ENUM_IF_VALID(...) \ |
| 610 | + BOOST_PP_FOR((0, BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)), \ |
| 611 | + ENUM_FOR_PRED, \ |
| 612 | + ENUM_FOR_OP, \ |
| 613 | + ENUM_FOR_MACRO) |
577 | 614 |
|
578 | 615 | /* Iterate on the macro MACRO and return the result as a comma separated list, converting |
579 | 616 | the boost sequence into tuples and then into list */ |
|
0 commit comments