so-5-5 icon indicating copy to clipboard operation
so-5-5 copied to clipboard

multiparameter messages

Open kotbegemot opened this issue 6 years ago • 14 comments

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);

kotbegemot avatar Oct 05 '18 10:10 kotbegemot

Which type of msg should be in that case?

eao197 avatar Oct 05 '18 10:10 eao197

It is assumed run-time tuple. the run-time tuple in the first approximation may be from a

std::vector < boost::any >

. @eao197

kotbegemot avatar Oct 05 '18 10:10 kotbegemot

Have you seen that: https://sourceforge.net/p/sobjectizer/wiki/so-5.5.5%20tuple_as_message/ ?

eao197 avatar Oct 05 '18 10:10 eao197

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

kotbegemot avatar Oct 05 '18 10:10 kotbegemot

Ok. I understood.

Have you tried just send vector<any> as a message?

eao197 avatar Oct 05 '18 10:10 eao197

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.

kotbegemot avatar Oct 05 '18 11:10 kotbegemot

convenient partial loss of types and restoration

I have no idea how it can look at API level :(

eao197 avatar Oct 05 '18 11:10 eao197

Is there a problem at the API level? Is this the only problem?

kotbegemot avatar Oct 05 '18 11:10 kotbegemot

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.

eao197 avatar Oct 05 '18 11:10 eao197

Maybe something can help?

kotbegemot avatar Oct 05 '18 11:10 kotbegemot

As an option:

void some_agent::on_some_message(mhood_t< dynamic_msg > cmd) {

}

kotbegemot avatar Oct 05 '18 11:10 kotbegemot

But what will be inside dynamic_msg? How do you plan to extract some data from an instance of dynamic_msg?

eao197 avatar Oct 05 '18 11:10 eao197

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.

kotbegemot avatar Oct 05 '18 11:10 kotbegemot

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?

eao197 avatar Oct 05 '18 11:10 eao197