Skip to content

bind_and_transform #67

@ilpropheta

Description

@ilpropheta

Hi!
I am very happy with the new message sinks and binding features and I was wondering if it would be feasible to add a sort of bind_and_transform function that binds and also maps a message type into another through a lambda (or any function object).

Imagine a scenario where a message box hosts this message type:

struct Pair
{
	Message1 message1;
	Message2 message2;
};

Suppose a bunch of agents handle Message1 but they can't be modified (e.g. they are in charge of another team). Thus, they can't simply subscribe to Pair. Then, one simple solution consists in adding a "transformer" agent that does the mapping into another message box. However, it would be more convenient (and efficient?) to have this:

binding->bind_and_transform<Pair>(input, wrap_to_msink(some_other_mbox), [](const Pair& p) {
	return p.message1;
});

Can it make some sense? Or is there any way to make something like this already?

Thanks!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions