so-5-5
so-5-5 copied to clipboard
multiparameter messages
It was not bad to have it possible not to write your structure but to transfer a set of parameters in rune-time.
auto args0 = 0;
auto args1 = 0.5;
std::string arg2 = "args2";
auto msg = make_message(arg0,arg1,arg2);
Which type of msg should be in that case?
It is assumed run-time tuple. the run-time tuple in the first approximation may be from a
std::vector < boost::any >
. @eao197
Have you seen that: https://sourceforge.net/p/sobjectizer/wiki/so-5.5.5%20tuple_as_message/ ?
Suppose there is a system. A partial system update is taking place. The message system can not be reduced at the time of a major update. New posts = old posts + new part to the end. After major update system. In a minor system update, you can remove the old one. @eao197
Ok. I understood.
Have you tried just send vector<any>
as a message?
Yes, I tried. It works, but it is inconvenient for end developers. It would be desirable: convenient partial loss of types and restoration as made in all the SObjectizer for communication.
convenient partial loss of types and restoration
I have no idea how it can look at API level :(
Is there a problem at the API level? Is this the only problem?
Is there a problem at the API level?
Now everything is really simple and clear:
struct my_msg {
int a_;
int b_;
...
};
...
void some_agent::on_my_msg(mhood_t<my_msg> cmd) {
std::cout << cmd->a_ << " " << cmd->b_ << std::endl;
}
But when we have something like black box with some data objects inside then how an user can work with it?
void some_agent::on_some_message(mhood_t<?> cmd) {
??? // How to access values in cmd?
}
Is this the only problem?
I don't know yet.
Maybe something can help?
As an option:
void some_agent::on_some_message(mhood_t< dynamic_msg > cmd) {
}
But what will be inside dynamic_msg
?
How do you plan to extract some data from an instance of dynamic_msg
?
But what will be inside dynamic_msg?
struct dynamic_msg : message_t {
std::vector<boost::any> storage;
}
one of the options.
How do you plan to extract some data from an instance of dynamic_msg?
types to save at the time of registration handler.
one of the options
It's the same thing as using plain vector<any>
. It can be done without support from SObjectizer.
types to save at the time of registration handler
I don't understand that. You already can define something like:
struct first_msg {
std::vector<boost::any> storage;
};
struct second_msg {
std::vector<boost::any> storage;
};
and then:
void some_agent::on_first_msg(mhood_t<first_msg> cmd) { /* Do what you want */ }
void some_agent::on_second_msg(mhood_t<second_msg> cmd) { /* Do what you want */ }
You can also provide as many builders for your first_msg
and second_msg
as you want.
Which support from SObjectizer is necessary here?