-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Description
NOTE. This issue is just a reminder that SObjectizer needs a solution for use-cases like described in #24
I don't know how and when this will be implemented (and can it be implemented at all), but the reminder will help to form scope for a new SObjectizer's release when appropriate resources will be available.
The task is to allow writing something like that:
class image_base : public so_5::message_t {...};
class image_vendor_A : public image_base {...};
class image_vendor_B : public image_base {...};
class image_vendor_C : public image_base {...};
// The first handler.
void first_handler::so_define_agent() {
so_subscribe_self()
// Handles only one type of images.
.event([this](mhood_t<image_vendor_A> cmd) {...})
// All other messages are just logged.
.event([this](mhood_t<image_base> cmd) { log_image(*cmd); });
}
...
// Another handler.
void second_handler::so_define_agent() {
so_subscribe_self()
// Handles two types.
.event([this](mhood_t<image_vendor_B> cmd) {...})
.event([this](mhood_t<image_vendor_C> cmd) {...})
// All other messages are just redirected as is.
.event([this](mhood_t<image_base> cmd) {
so_5::send(new_dest, cmd);
});
}
// Yet another handler.
void third_handler::so_define_agent() {
// Redirects all messages to another destination.
so_subscribe_self().event([this](mhood_t<image_base> cmd) {
so_5::send(new_dest, cmd);
}
}Additional requirement. It'll be great to have that functionality for handling messages from mchains too:
so_5::receive(from(mchain).handle_all(),
[](so_5::mhood_t<image_vendor_A> cmd) {...},
[](so_5::mhood_t<image_vendor_C> cmd) {...},
[new_dest](so_5::mhood_t<image_base> cmd) { so_5::send(new_dest, cmd); });Metadata
Metadata
Assignees
Labels
No labels