BOOST_MIXIN_MESSAGE_N
// In header: <boost/mixin/message_macros.hpp>
BOOST_MIXIN_MESSAGE_N(return_type, message, args)
Macro that declares a message
This generates the stand-alone function which is users should use to call messages.
The calls will throw the exception bad_message_call
if none of the mixins from which the object is composed handles this message. To prevent the message calls from Throwing exceptions you can define BOOST_MIXIN_NO_MSG_THROW
before including the library's headers.
Variants:
BOOST_MIXIN_MESSAGE_N(return_type, message, args) BOOST_MIXIN_CONST_MESSAGE_N(return_type, message, args) BOOST_MIXIN_MULTICAST_MESSAGE_N(return_type, message, args) BOOST_MIXIN_CONST_MULTICAST_MESSAGE_N(return_type, message, args) BOOST_MIXIN_EXPORTED_MESSAGE_N(export, return_type, message, args) BOOST_MIXIN_EXPORTED_CONST_MESSAGE_N(export, return_type, message, args) BOOST_MIXIN_EXPORTED_MULTICAST_MESSAGE_N(export, return_type, message, args) BOOST_MIXIN_EXPORTED_CONST_MULTICAST_MESSAGE_N(export, return_type, message, args) BOOST_MIXIN_MESSAGE_N_OVERLOAD(message_name, return_type, method_name, args) BOOST_MIXIN_CONST_MESSAGE_N_OVERLOAD(message_name, return_type, method_name, args) BOOST_MIXIN_MULTICAST_MESSAGE_N_OVERLOAD(message_name, return_type, method_name, args) BOOST_MIXIN_CONST_MULTICAST_MESSAGE_N_OVERLOAD(message_name, return_type, method_name, args) BOOST_MIXIN_EXPORTED_MESSAGE_N_OVERLOAD(export, message_name, return_type, method_name, args) BOOST_MIXIN_EXPORTED_CONST_MESSAGE_N_OVERLOAD(export, message_name, return_type, method_name, args) BOOST_MIXIN_EXPORTED_MULTICAST_MESSAGE_N_OVERLOAD(export, message_name, return_type, method_name, args) BOOST_MIXIN_EXPORTED_CONST_MULTICAST_MESSAGE_N_OVERLOAD(export, message_name, return_type, method_name, args)
Legend:
N
in those variant names is a number that indicates how many parameters the message takes. If N
is 0, then args
is omitted.
args
is a coma-separated list of the argument types and argument names of the message's arguments
If MULTICAST
is a part of a macro, it declares a multicast message. Otherwise it declares a unicast message.
If CONST
is part of a macro, then the message works with const object&
and should be bound to const methods of a mixin class. Otherwise it works with simply object&
and should be bound no non-const methods of the mixin class.
If EXPORTED
is part of a macro, then it's used to declare a message that is exported from a dynamic library. The export
parameter should be the appropriate export/import symbols for the particular compiler (i.e. __declspec(dllexport)
)
If OVERLOAD
is part of a macro, it defines a message overload. It splits the ways of referring to the message in two. The first - message_name
- should be used when referring to the message - in mixin feature lists, in object::implements
, and in BOOST_MIXIN_DEFINE_MESSAGE
. The second - method_name
- is the name of the method in the mixin class, and will be the name of the message function generated by the macro.
Examples:
// A basic non-const unicast message with no arguments. // Should be bound to: void mixin_class::foo() BOOST_MIXIN_MESSAGE_0(void, foo); // A const multicast message with two arguments // Should be bound to: void mixin_class::serialize(archive& ar, int flags) const BOOST_MIXIN_CONST_MULTICAST_MESSAGE_2(void, serialize, archive&, ar, int, flags); // Assuming MY_LIB_API is a macro that expands accordingly to the // export/import symbols for the compiler you're using, this is // a const unicast message with one argument exported from a dynamic library // Should be bound to: float mixin_class::size(int dimension) const BOOST_MIXIN_EXPORTED_CONST_MESSAGE_1(MY_LIB_API, int, size, int, dimension); // Two message overloads, that should be bound to: // void mixin_class::scale(float uniform); // void mixin_class::scale(const vector3& vec); // respectively. // The macros will generate two functions named scale with the // appropriate arguments. In order to bind them to a mixin, // you should use scale_uniform_msg and scale_vector_msg // in the mixin feature list. BOOST_MIXIN_MESSAGE_1_OVERLOAD(scale_uniform, void, scale, float, uniform); BOOST_MIXIN_MESSAGE_1_OVERLOAD(scale_vector, void, scale, const vector3&, vec);