#pragma once #include "cmix.pb.h" #include #include #include #include #include #include #include /*! * \file */ /*! * \brief The CMixProtoFunctor struct Is a functor that enables the ProtobufClient to serialize * all the types you specify below. */ struct CMixProtoFunctor { /*! * \brief proto_type Typedef that exposes the cmix proto container message. */ typedef cmix_proto::CMixMessage proto_type; /*! * \def MESSAGE_SETTER_DEF(TYPE, NAME) * Generates a message setter definition for the Protobuf type in TYPE with member name NAME. */ #define MESSAGE_SETTER_DEF(TYPE, NAME) \ proto_type operator()(cmix_proto::TYPE const& v) { \ proto_type m; \ BOOST_PP_CAT(*m.mutable_, NAME)() = v; \ return m; \ } \ /*! * \def MESSAGE_SETTER_DEF_ITERATION(Z, N, DATA) * Defines one iteration of the Repeat below, * \param Z level over repeat we are using it should be 1. * \param N current iteration * \param DATA The sequence consisiting of "pairs" of TYPE, NAME */ #define MESSAGE_SETTER_DEF_ITERATION(Z, N, DATA) \ MESSAGE_SETTER_DEF(BOOST_PP_SEQ_ELEM(BOOST_PP_MUL(N, 2), DATA), BOOST_PP_SEQ_ELEM(BOOST_PP_ADD(BOOST_PP_MUL(N, 2), 1), DATA)) /*! * \def MESSAGE_SETTER_DEFS(...) * Loops over the length of the variadic macro parameter / 2 */ #define MESSAGE_SETTER_DEFS(...) \ BOOST_PP_REPEAT(BOOST_PP_DIV(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), 2), MESSAGE_SETTER_DEF_ITERATION, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) MESSAGE_SETTER_DEFS( Initialization, initialization, ImANode, imanode, ImAClient, imaclient, Bye, bye, KeyExchange, keyexchange, SecretKey, secretkey, NodeReady, nodeready, UserMessage, usermessage, PrePre, prepre, PreMix, premix, PrePost, prepost, RealPre, realpre, RealMix, realmix, Payload, payload, Performance, performance ) #undef MESSAGE_SETTER_DEFS #undef MESSAGE_SETTER_DEF_ITERATION #undef MESSAGE_SETTER_DEF };