Ask Your Question

Revision history [back]

To give a quick answer (even if I agree with the comments given):

explicit constructor is called (why not implicitly ?)

I would suggest you to read about this keyword:

Here why an "auto" specifier is used ?

Auto is used to avoid specifying the type of _handle_add_two_ints_ as it can be found at compile time. If you wish, you can find the type and replace auto.

What does this exactly means?

It will call the function _rcutils_cli_option_exist_ and look if the user specified the option '-h' when calling the binary. If yes, print how to use the binary. Check

auto service_name = std::string("add_two_ints"); //naming the service ?

Is declaring a string which will be used to name the service

if (rcutils_cli_option_exist(argv, argv + argc, "-s")) {

If the '-s' option has been specified, then the user gave a service name, so _rcutils_cli_get_option_ will return the argument specified after '-s'

auto node = std::make_shared<servernode>(service_name); //passing the service name to the node ?

This create an instance of the class ServerNode with the service_name as argument.


Process any event from the node ( if a request to the service occures as example)