18 #ifndef GZ_TRANSPORT_REPHANDLER_HH_
19 #define GZ_TRANSPORT_REPHANDLER_HH_
23 #pragma warning(disable: 4251)
25 #include <google/protobuf/message.h>
26 #include <google/protobuf/stubs/common.h>
27 #if GOOGLE_PROTOBUF_VERSION > 2999999 && GOOGLE_PROTOBUF_VERSION < 4022000
28 #include <google/protobuf/stubs/casts.h>
39 #include "gz/transport/config.hh"
40 #include "gz/transport/Export.hh"
49 inline namespace GZ_TRANSPORT_VERSION_NAMESPACE {
57 : hUuid(
Uuid().ToString())
77 public:
virtual bool RunCallback(
const std::string &_req,
89 public:
virtual std::string ReqTypeName()
const = 0;
93 public:
virtual std::string RepTypeName()
const = 0;
99 #pragma warning(disable: 4251)
139 std::cerr <<
"RepHandler::RunLocalCallback() error: "
144 #if GOOGLE_PROTOBUF_VERSION >= 4022000
146 google::protobuf::internal::DownCast<const Req*>(&_msgReq);
147 auto msgRep = google::protobuf::internal::DownCast<Rep*>(&_msgRep);
148 #elif GOOGLE_PROTOBUF_VERSION > 2999999
149 auto msgReq = google::protobuf::down_cast<const Req*>(&_msgReq);
150 auto msgRep = google::protobuf::down_cast<Rep*>(&_msgRep);
153 google::protobuf::internal::down_cast<const Req*>(&_msgReq);
154 auto msgRep = google::protobuf::internal::down_cast<Rep*>(&_msgRep);
157 return this->cb(*msgReq, *msgRep);
167 std::cerr <<
"RepHandler::RunCallback() error: "
173 auto msgReq = this->CreateMsg(_req);
180 if (!this->cb(*msgReq, msgRep))
183 if (!msgRep.SerializeToString(&_rep))
185 std::cerr <<
"RepHandler::RunCallback(): Error serializing the "
196 return Req().GetTypeName();
202 return Rep().GetTypeName();
214 if (!msgPtr->ParseFromString(_data))
216 std::cerr <<
"RepHandler::CreateMsg() error: ParseFromString failed"