12 #include <mrpt/system/COutputLogger.h>
13 #include <mrpt/system/CTimeLogger.h>
23 struct InfoPerService;
24 struct InfoPerSubscribedTopic;
48 class Client :
public mrpt::system::COutputLogger
52 Client(
const std::string& nodeName);
58 void setName(
const std::string& nodeName);
86 template <typename MSG_T>
88 const
std::
string& topicName, const
std::function<
void(const MSG_T&)>& callback);
90 template <typename INPUT_MSG_T, typename OUTPUT_MSG_T>
92 const
std::
string& serviceName,
93 const
std::function<OUTPUT_MSG_T(const INPUT_MSG_T&)>& callback);
95 template <typename INPUT_MSG_T, typename OUTPUT_MSG_T>
97 const
std::
string& serviceName, const INPUT_MSG_T& input, OUTPUT_MSG_T& output);
104 const
std::
string& topicName,
106 void(const
std::
string& , const
std::vector<uint8_t>& )>&
134 std::unique_ptr<ZMQImpl>
zmq_;
145 mrpt::system::CTimeLogger
profiler_{
false,
"mvsim::Client"};
155 const std::string& )>;
158 const std::string& topicName,
const google::protobuf::Descriptor* descriptor);
160 const std::string& serviceName,
const google::protobuf::Descriptor* descIn,
164 const std::string& topicName,
const google::protobuf::Descriptor* descriptor,
167 const std::string& serviceName,
const std::string& inputSerializedMsg,
168 mrpt::optional_ref<google::protobuf::Message> outputMsg,
169 mrpt::optional_ref<std::string> outputSerializedMsg = std::nullopt,
170 mrpt::optional_ref<std::string> outputMsgTypeName = std::nullopt);
176 template <
typename T>
182 template <
typename INPUT_MSG_T,
typename OUTPUT_MSG_T>
184 const std::string& serviceName,
const std::function<OUTPUT_MSG_T(
const INPUT_MSG_T&)>& callback)
187 serviceName, INPUT_MSG_T::descriptor(), OUTPUT_MSG_T::descriptor(),
189 [callback](
const std::string& inData)
192 in.ParseFromString(inData);
193 return std::make_shared<OUTPUT_MSG_T>(callback(in));
197 template <
typename MSG_T>
199 const std::string& topicName,
const std::function<
void(
const MSG_T&)>& callback)
202 topicName, MSG_T::descriptor(),
204 [callback](
const zmq::message_t& m)
207 mvsim::parseMessage(m, in);
212 template <
typename INPUT_MSG_T,
typename OUTPUT_MSG_T>
214 const std::string& serviceName,
const INPUT_MSG_T& input, OUTPUT_MSG_T& output)
216 doCallService(serviceName, input.SerializeAsString(), output);