14 #include <boost/functional/hash.hpp>
16 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
18 #include <mal/Mal.hpp>
19 #include <mal/utility/future.hpp>
20 #include <mal/rr/ClientAsync.hpp>
21 #include <mal/rr/AmiZpb.hpp>
22 #include <mal/ps/ZpbDataEntity.hpp>
23 #include <mal/utility/Uri.hpp>
24 #include <mal/util/ZpbList.hpp>
25 #include <mal/types/ZpbMalTypes.hpp>
26 #include <mal/rr/ServerContextZpb.hpp>
27 #include <mal/rr/ServerContextZpbAmi.hpp>
28 #include <mal/rr/ServerContextProvider.hpp>
45 m_zpbObj(inner, ::elt::mal::util::list::NoopDeleter<
ZpbType*>())
74 return m_zpbObj->desc();
78 setDesc(from.getDesc());
86 void setDesc(
const std::string&
desc) {
87 m_zpbObj->set_desc(desc);
90 std::shared_ptr<ZpbType> m_zpbObj;
109 public virtual ::elt::mal::ps::ZpbDataEntity<::hellomalif::LogInfo> {
117 m_zpbObj(inner, ::elt::mal::util::list::NoopDeleter<
ZpbType*>())
142 return m_zpbObj->level();
146 m_zpbObj->set_level(level);
149 return m_zpbObj->logger();
153 m_zpbObj->set_logger(logger);
156 std::unique_ptr<::hellomalif::LogInfo>
clone()
const override {
165 std::size_t seed = 0;
169 std::unique_ptr<::hellomalif::LogInfo>
cloneKey()
const override {
170 std::unique_ptr<::hellomalif::LogInfo> entity(
new LogInfoImpl());
179 msg.rebuild(m_zpbObj->ByteSizeLong());
180 return m_zpbObj->SerializeToArray(msg.data(), msg.size());
184 return m_zpbObj->SerializeToString(&output);
188 return m_zpbObj->ParseFromString(data);
192 google::protobuf::io::ArrayInputStream ais(data, size);
193 return m_zpbObj->ParseFromZeroCopyStream(&ais);
211 std::shared_ptr<ZpbType> m_zpbObj;
230 template<
typename Intf>
236 :
public virtual ::elt::mal::rr::ClientAsyncImpl<::hellomalif::StdCmdsAsync,
237 ::generated::zpb::hellomalif::StdCmds_Request,
238 ::generated::zpb::hellomalif::StdCmds_Reply>,
242 const ::elt::mal::Uri &uri,
243 const std::vector<std::shared_ptr<::elt::mal::rr::qos::QoS>> &standardQoS,
244 const ::elt::mal::Mal::Properties &malSpecificProperties,
245 const std::shared_ptr<::elt::mal::ZpbMal> &zpbMal):
248 uri, standardQoS, malSpecificProperties, zpbMal) {}
250 ::elt::mal::future<std::string>
Init()
override {
253 new ::generated::zpb::hellomalif::StdCmds_Init_In();
259 return sendRequest(request).then([](
260 ::elt::mal::future<::generated::zpb::hellomalif::StdCmds_Reply> replyFut) {
261 auto reply = replyFut.get();
262 auto code = reply.header().code();
264 if (
code != ::elt::mal::zpb::rr::CompletionCode::COMPLETED) {
265 std::ostringstream errMsg;
267 errMsg <<
"Code:" <<
code <<
" Message:";
268 reply.header().has_exceptionmessage() ?
269 errMsg << reply.header().exceptionmessage() : errMsg <<
"Unknown error message";
271 code == ::elt::mal::zpb::rr::CompletionCode::UNKNOWN_EXCEPTION ?
272 ::elt::mal::throw_exception(::elt::mal::UnhandledRemoteException(errMsg.str())) :
273 ::elt::mal::throw_exception(::elt::mal::MalException(errMsg.str()));
275 auto data = reply.data();
276 return (std::string)data.init().retval();
280 ::elt::mal::future<std::string>
Reset()
override {
283 new ::generated::zpb::hellomalif::StdCmds_Reset_In();
289 return sendRequest(request).then([](
290 ::elt::mal::future<::generated::zpb::hellomalif::StdCmds_Reply> replyFut) {
291 auto reply = replyFut.get();
292 auto code = reply.header().code();
294 if (
code != ::elt::mal::zpb::rr::CompletionCode::COMPLETED) {
295 std::ostringstream errMsg;
297 errMsg <<
"Code:" <<
code <<
" Message:";
298 reply.header().has_exceptionmessage() ?
299 errMsg << reply.header().exceptionmessage() : errMsg <<
"Unknown error message";
301 code == ::elt::mal::zpb::rr::CompletionCode::UNKNOWN_EXCEPTION ?
302 ::elt::mal::throw_exception(::elt::mal::UnhandledRemoteException(errMsg.str())) :
303 ::elt::mal::throw_exception(::elt::mal::MalException(errMsg.str()));
305 auto data = reply.data();
306 return (std::string)data.reset().retval();
310 ::elt::mal::future<std::string>
Enable()
override {
313 new ::generated::zpb::hellomalif::StdCmds_Enable_In();
319 return sendRequest(request).then([](
320 ::elt::mal::future<::generated::zpb::hellomalif::StdCmds_Reply> replyFut) {
321 auto reply = replyFut.get();
322 auto code = reply.header().code();
324 if (
code != ::elt::mal::zpb::rr::CompletionCode::COMPLETED) {
325 std::ostringstream errMsg;
327 errMsg <<
"Code:" <<
code <<
" Message:";
328 reply.header().has_exceptionmessage() ?
329 errMsg << reply.header().exceptionmessage() : errMsg <<
"Unknown error message";
331 code == ::elt::mal::zpb::rr::CompletionCode::UNKNOWN_EXCEPTION ?
332 ::elt::mal::throw_exception(::elt::mal::UnhandledRemoteException(errMsg.str())) :
333 ::elt::mal::throw_exception(::elt::mal::MalException(errMsg.str()));
335 auto data = reply.data();
336 return (std::string)data.enable().retval();
340 ::elt::mal::future<std::string>
Disable()
override {
343 new ::generated::zpb::hellomalif::StdCmds_Disable_In();
349 return sendRequest(request).then([](
350 ::elt::mal::future<::generated::zpb::hellomalif::StdCmds_Reply> replyFut) {
351 auto reply = replyFut.get();
352 auto code = reply.header().code();
354 if (
code != ::elt::mal::zpb::rr::CompletionCode::COMPLETED) {
355 std::ostringstream errMsg;
357 errMsg <<
"Code:" <<
code <<
" Message:";
358 reply.header().has_exceptionmessage() ?
359 errMsg << reply.header().exceptionmessage() : errMsg <<
"Unknown error message";
361 code == ::elt::mal::zpb::rr::CompletionCode::UNKNOWN_EXCEPTION ?
362 ::elt::mal::throw_exception(::elt::mal::UnhandledRemoteException(errMsg.str())) :
363 ::elt::mal::throw_exception(::elt::mal::MalException(errMsg.str()));
365 auto data = reply.data();
366 return (std::string)data.disable().retval();
370 ::elt::mal::future<std::string>
Status()
override {
373 new ::generated::zpb::hellomalif::StdCmds_Status_In();
379 return sendRequest(request).then([](
380 ::elt::mal::future<::generated::zpb::hellomalif::StdCmds_Reply> replyFut) {
381 auto reply = replyFut.get();
382 auto code = reply.header().code();
384 if (
code != ::elt::mal::zpb::rr::CompletionCode::COMPLETED) {
385 std::ostringstream errMsg;
387 errMsg <<
"Code:" <<
code <<
" Message:";
388 reply.header().has_exceptionmessage() ?
389 errMsg << reply.header().exceptionmessage() : errMsg <<
"Unknown error message";
391 code == ::elt::mal::zpb::rr::CompletionCode::UNKNOWN_EXCEPTION ?
392 ::elt::mal::throw_exception(::elt::mal::UnhandledRemoteException(errMsg.str())) :
393 ::elt::mal::throw_exception(::elt::mal::MalException(errMsg.str()));
395 auto data = reply.data();
396 return (std::string)data.status().retval();
400 ::elt::mal::future<std::string>
Config()
override {
403 new ::generated::zpb::hellomalif::StdCmds_Config_In();
409 return sendRequest(request).then([](
410 ::elt::mal::future<::generated::zpb::hellomalif::StdCmds_Reply> replyFut) {
411 auto reply = replyFut.get();
412 auto code = reply.header().code();
414 if (
code != ::elt::mal::zpb::rr::CompletionCode::COMPLETED) {
415 std::ostringstream errMsg;
417 errMsg <<
"Code:" <<
code <<
" Message:";
418 reply.header().has_exceptionmessage() ?
419 errMsg << reply.header().exceptionmessage() : errMsg <<
"Unknown error message";
421 code == ::elt::mal::zpb::rr::CompletionCode::UNKNOWN_EXCEPTION ?
422 ::elt::mal::throw_exception(::elt::mal::UnhandledRemoteException(errMsg.str())) :
423 ::elt::mal::throw_exception(::elt::mal::MalException(errMsg.str()));
425 auto data = reply.data();
426 return (std::string)data.config().retval();
430 ::elt::mal::future<std::string>
Stop()
override {
433 new ::generated::zpb::hellomalif::StdCmds_Stop_In();
439 return sendRequest(request).then([](
440 ::elt::mal::future<::generated::zpb::hellomalif::StdCmds_Reply> replyFut) {
441 auto reply = replyFut.get();
442 auto code = reply.header().code();
444 if (
code != ::elt::mal::zpb::rr::CompletionCode::COMPLETED) {
445 std::ostringstream errMsg;
447 errMsg <<
"Code:" <<
code <<
" Message:";
448 reply.header().has_exceptionmessage() ?
449 errMsg << reply.header().exceptionmessage() : errMsg <<
"Unknown error message";
451 code == ::elt::mal::zpb::rr::CompletionCode::UNKNOWN_EXCEPTION ?
452 ::elt::mal::throw_exception(::elt::mal::UnhandledRemoteException(errMsg.str())) :
453 ::elt::mal::throw_exception(::elt::mal::MalException(errMsg.str()));
455 auto data = reply.data();
456 return (std::string)data.stop().retval();
460 ::elt::mal::future<std::string>
Exit()
override {
463 new ::generated::zpb::hellomalif::StdCmds_Exit_In();
469 return sendRequest(request).then([](
470 ::elt::mal::future<::generated::zpb::hellomalif::StdCmds_Reply> replyFut) {
471 auto reply = replyFut.get();
472 auto code = reply.header().code();
474 if (
code != ::elt::mal::zpb::rr::CompletionCode::COMPLETED) {
475 std::ostringstream errMsg;
477 errMsg <<
"Code:" <<
code <<
" Message:";
478 reply.header().has_exceptionmessage() ?
479 errMsg << reply.header().exceptionmessage() : errMsg <<
"Unknown error message";
481 code == ::elt::mal::zpb::rr::CompletionCode::UNKNOWN_EXCEPTION ?
482 ::elt::mal::throw_exception(::elt::mal::UnhandledRemoteException(errMsg.str())) :
483 ::elt::mal::throw_exception(::elt::mal::MalException(errMsg.str()));
485 auto data = reply.data();
486 return (std::string)data.exit().retval();
490 ::elt::mal::future<std::string>
SetLogLevel(
const std::shared_ptr<::hellomalif::LogInfo>& info)
override {
493 new ::generated::zpb::hellomalif::StdCmds_SetLogLevel_In();
509 return sendRequest(request).then([](
510 ::elt::mal::future<::generated::zpb::hellomalif::StdCmds_Reply> replyFut) {
511 auto reply = replyFut.get();
512 auto code = reply.header().code();
514 if (
code != ::elt::mal::zpb::rr::CompletionCode::COMPLETED) {
515 std::ostringstream errMsg;
517 errMsg <<
"Code:" <<
code <<
" Message:";
518 reply.header().has_exceptionmessage() ?
519 errMsg << reply.header().exceptionmessage() : errMsg <<
"Unknown error message";
521 code == ::elt::mal::zpb::rr::CompletionCode::UNKNOWN_EXCEPTION ?
522 ::elt::mal::throw_exception(::elt::mal::UnhandledRemoteException(errMsg.str())) :
523 ::elt::mal::throw_exception(::elt::mal::MalException(errMsg.str()));
525 auto data = reply.data();
526 if (data.setloglevel().has_exexceptionerr()) {
529 return (std::string)data.setloglevel().retval();
539 const ::elt::mal::Uri &uri,
540 const std::vector<std::shared_ptr<::elt::mal::rr::qos::QoS>> &standardQoS,
541 const ::elt::mal::Mal::Properties &malSpecificProperties,
542 const std::shared_ptr<::elt::mal::ZpbMal> &zpbMal)
543 : m_delegate(uri, standardQoS, malSpecificProperties, zpbMal), m_timeoutMs{} {
544 m_timeoutMs = ::elt::mal::util::getReplyTimeQoS(standardQoS);
547 std::shared_ptr<::elt::mal::Mal>
getMal()
const override {
548 return m_delegate.getMal();
552 auto future = m_delegate.
Init();
553 if (::elt::mal::future_status::ready
554 == future.wait_for(boost::chrono::milliseconds(m_timeoutMs))) {
557 throw ::elt::mal::TimeoutException(
"timeout");
562 auto future = m_delegate.
Reset();
563 if (::elt::mal::future_status::ready
564 == future.wait_for(boost::chrono::milliseconds(m_timeoutMs))) {
567 throw ::elt::mal::TimeoutException(
"timeout");
572 auto future = m_delegate.
Enable();
573 if (::elt::mal::future_status::ready
574 == future.wait_for(boost::chrono::milliseconds(m_timeoutMs))) {
577 throw ::elt::mal::TimeoutException(
"timeout");
582 auto future = m_delegate.
Disable();
583 if (::elt::mal::future_status::ready
584 == future.wait_for(boost::chrono::milliseconds(m_timeoutMs))) {
587 throw ::elt::mal::TimeoutException(
"timeout");
592 auto future = m_delegate.
Status();
593 if (::elt::mal::future_status::ready
594 == future.wait_for(boost::chrono::milliseconds(m_timeoutMs))) {
597 throw ::elt::mal::TimeoutException(
"timeout");
602 auto future = m_delegate.
Config();
603 if (::elt::mal::future_status::ready
604 == future.wait_for(boost::chrono::milliseconds(m_timeoutMs))) {
607 throw ::elt::mal::TimeoutException(
"timeout");
612 auto future = m_delegate.
Stop();
613 if (::elt::mal::future_status::ready
614 == future.wait_for(boost::chrono::milliseconds(m_timeoutMs))) {
617 throw ::elt::mal::TimeoutException(
"timeout");
622 auto future = m_delegate.
Exit();
623 if (::elt::mal::future_status::ready
624 == future.wait_for(boost::chrono::milliseconds(m_timeoutMs))) {
627 throw ::elt::mal::TimeoutException(
"timeout");
631 std::string
SetLogLevel(
const std::shared_ptr<::hellomalif::LogInfo>& info)
override {
633 if (::elt::mal::future_status::ready
634 == future.wait_for(boost::chrono::milliseconds(m_timeoutMs))) {
637 throw ::elt::mal::TimeoutException(
"timeout");
648 return m_delegate.asyncConnect();
652 return m_delegate.registerConnectionListener(listener);
664 ::elt::mal::rr::ZpbServer &zpbServer,
665 const std::shared_ptr<::hellomalif::AsyncStdCmds> &entity,
666 const std::shared_ptr<::elt::mal::Mal> &mal)
667 : m_zpbServer(zpbServer), m_entity(entity), m_mal(mal) {}
671 const std::string &
id,
const std::string &topicIdFrame,
672 const std::string &headerFrame,
673 const ::elt::mal::zpb::rr::ZpbHeader &header) {
674 if (!::elt::mal::util::getSocketHasRcvMore(socket)) {
675 std::unique_ptr<::elt::mal::zpb::rr::ReplyHeader> unhandledExReplyHeader(
676 new ::elt::mal::zpb::rr::ReplyHeader());
678 unhandledExReplyHeader->set_code(::elt::mal::zpb::rr::CompletionCode::INVALID_ARGUMENT);
679 unhandledExReplyHeader->set_exceptionmessage(
"missing request frame");
681 sendReply(socket,
id, topicIdFrame, headerFrame, std::move(unhandledExReplyHeader),
682 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return>());
690 zmq::message_t msgFrame;
691 socket.recv(&msgFrame, 0);
693 if (!request.ParseFromArray(msgFrame.data(), msgFrame.size())) {
694 std::unique_ptr<::elt::mal::zpb::rr::ReplyHeader> unhandledExReplyHeader(
695 new ::elt::mal::zpb::rr::ReplyHeader());
697 unhandledExReplyHeader->set_code(::elt::mal::zpb::rr::CompletionCode::INVALID_ARGUMENT);
698 unhandledExReplyHeader->set_exceptionmessage(
"Invalid Request: Request parsing failed");
700 sendReply(socket,
id, topicIdFrame, headerFrame, std::move(unhandledExReplyHeader),
701 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return>());
708 if (call->has_init()) {
711 auto serverContext = std::unique_ptr<::elt::mal::rr::ServerContext<std::string>>(
712 new ::elt::mal::rr::ServerContextZpb<std::string>(m_mal));
714 ::elt::mal::rr::ServerContextProvider::setInstance<
715 ::elt::mal::rr::ServerContext<std::string>>(serverContext);
717 m_entity->Init().then(m_zpbServer.getExecutor(), [
this, &socket, id, topicIdFrame, headerFrame, params]
718 (::elt::mal::future<std::string> f) {
719 if (!f.has_exception()) {
720 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data(
721 new ::generated::zpb::hellomalif::StdCmds_Return());
723 auto out = new ::generated::zpb::hellomalif::StdCmds_Init_Out();
725 out->set_retval(f.get());
727 data->set_allocated_init(out);
735 }
else if (call->has_reset()) {
736 auto params = call->mutable_reset();
738 auto serverContext = std::unique_ptr<::elt::mal::rr::ServerContext<std::string>>(
739 new ::elt::mal::rr::ServerContextZpb<std::string>(m_mal));
741 ::elt::mal::rr::ServerContextProvider::setInstance<
742 ::elt::mal::rr::ServerContext<std::string>>(serverContext);
744 m_entity->Reset().then(m_zpbServer.getExecutor(), [
this, &socket, id, topicIdFrame, headerFrame, params]
745 (::elt::mal::future<std::string> f) {
746 if (!f.has_exception()) {
747 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data(
748 new ::generated::zpb::hellomalif::StdCmds_Return());
750 auto out = new ::generated::zpb::hellomalif::StdCmds_Reset_Out();
752 out->set_retval(f.get());
754 data->set_allocated_reset(out);
762 }
else if (call->has_enable()) {
763 auto params = call->mutable_enable();
765 auto serverContext = std::unique_ptr<::elt::mal::rr::ServerContext<std::string>>(
766 new ::elt::mal::rr::ServerContextZpb<std::string>(m_mal));
768 ::elt::mal::rr::ServerContextProvider::setInstance<
769 ::elt::mal::rr::ServerContext<std::string>>(serverContext);
771 m_entity->Enable().then(m_zpbServer.getExecutor(), [
this, &socket, id, topicIdFrame, headerFrame, params]
772 (::elt::mal::future<std::string> f) {
773 if (!f.has_exception()) {
774 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data(
775 new ::generated::zpb::hellomalif::StdCmds_Return());
777 auto out = new ::generated::zpb::hellomalif::StdCmds_Enable_Out();
779 out->set_retval(f.get());
781 data->set_allocated_enable(out);
789 }
else if (call->has_disable()) {
790 auto params = call->mutable_disable();
792 auto serverContext = std::unique_ptr<::elt::mal::rr::ServerContext<std::string>>(
793 new ::elt::mal::rr::ServerContextZpb<std::string>(m_mal));
795 ::elt::mal::rr::ServerContextProvider::setInstance<
796 ::elt::mal::rr::ServerContext<std::string>>(serverContext);
798 m_entity->Disable().then(m_zpbServer.getExecutor(), [
this, &socket, id, topicIdFrame, headerFrame, params]
799 (::elt::mal::future<std::string> f) {
800 if (!f.has_exception()) {
801 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data(
802 new ::generated::zpb::hellomalif::StdCmds_Return());
804 auto out = new ::generated::zpb::hellomalif::StdCmds_Disable_Out();
806 out->set_retval(f.get());
808 data->set_allocated_disable(out);
816 }
else if (call->has_status()) {
817 auto params = call->mutable_status();
819 auto serverContext = std::unique_ptr<::elt::mal::rr::ServerContext<std::string>>(
820 new ::elt::mal::rr::ServerContextZpb<std::string>(m_mal));
822 ::elt::mal::rr::ServerContextProvider::setInstance<
823 ::elt::mal::rr::ServerContext<std::string>>(serverContext);
825 m_entity->Status().then(m_zpbServer.getExecutor(), [
this, &socket, id, topicIdFrame, headerFrame, params]
826 (::elt::mal::future<std::string> f) {
827 if (!f.has_exception()) {
828 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data(
829 new ::generated::zpb::hellomalif::StdCmds_Return());
831 auto out = new ::generated::zpb::hellomalif::StdCmds_Status_Out();
833 out->set_retval(f.get());
835 data->set_allocated_status(out);
843 }
else if (call->has_config()) {
844 auto params = call->mutable_config();
846 auto serverContext = std::unique_ptr<::elt::mal::rr::ServerContext<std::string>>(
847 new ::elt::mal::rr::ServerContextZpb<std::string>(m_mal));
849 ::elt::mal::rr::ServerContextProvider::setInstance<
850 ::elt::mal::rr::ServerContext<std::string>>(serverContext);
852 m_entity->Config().then(m_zpbServer.getExecutor(), [
this, &socket, id, topicIdFrame, headerFrame, params]
853 (::elt::mal::future<std::string> f) {
854 if (!f.has_exception()) {
855 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data(
856 new ::generated::zpb::hellomalif::StdCmds_Return());
858 auto out = new ::generated::zpb::hellomalif::StdCmds_Config_Out();
860 out->set_retval(f.get());
862 data->set_allocated_config(out);
870 }
else if (call->has_stop()) {
871 auto params = call->mutable_stop();
873 auto serverContext = std::unique_ptr<::elt::mal::rr::ServerContext<std::string>>(
874 new ::elt::mal::rr::ServerContextZpb<std::string>(m_mal));
876 ::elt::mal::rr::ServerContextProvider::setInstance<
877 ::elt::mal::rr::ServerContext<std::string>>(serverContext);
879 m_entity->Stop().then(m_zpbServer.getExecutor(), [
this, &socket, id, topicIdFrame, headerFrame, params]
880 (::elt::mal::future<std::string> f) {
881 if (!f.has_exception()) {
882 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data(
883 new ::generated::zpb::hellomalif::StdCmds_Return());
885 auto out = new ::generated::zpb::hellomalif::StdCmds_Stop_Out();
887 out->set_retval(f.get());
889 data->set_allocated_stop(out);
897 }
else if (call->has_exit()) {
898 auto params = call->mutable_exit();
900 auto serverContext = std::unique_ptr<::elt::mal::rr::ServerContext<std::string>>(
901 new ::elt::mal::rr::ServerContextZpb<std::string>(m_mal));
903 ::elt::mal::rr::ServerContextProvider::setInstance<
904 ::elt::mal::rr::ServerContext<std::string>>(serverContext);
906 m_entity->Exit().then(m_zpbServer.getExecutor(), [
this, &socket, id, topicIdFrame, headerFrame, params]
907 (::elt::mal::future<std::string> f) {
908 if (!f.has_exception()) {
909 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data(
910 new ::generated::zpb::hellomalif::StdCmds_Return());
912 auto out = new ::generated::zpb::hellomalif::StdCmds_Exit_Out();
914 out->set_retval(f.get());
916 data->set_allocated_exit(out);
924 }
else if (call->has_setloglevel()) {
925 auto params = call->mutable_setloglevel();
927 auto serverContext = std::unique_ptr<::elt::mal::rr::ServerContext<std::string>>(
928 new ::elt::mal::rr::ServerContextZpb<std::string>(m_mal));
930 ::elt::mal::rr::ServerContextProvider::setInstance<
931 ::elt::mal::rr::ServerContext<std::string>>(serverContext);
933 m_entity->SetLogLevel(std::shared_ptr< ::hellomalif::LogInfo>(new ::hellomalif::zpb::LogInfoImpl(params->mutable_info()))).then(m_zpbServer.getExecutor(), [
this, &socket, id, topicIdFrame, headerFrame, params]
934 (::elt::mal::future<std::string> f) {
935 if (!f.has_exception()) {
936 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data(
937 new ::generated::zpb::hellomalif::StdCmds_Return());
939 auto out = new ::generated::zpb::hellomalif::StdCmds_SetLogLevel_Out();
941 out->set_retval(f.get());
943 data->set_allocated_setloglevel(out);
948 ::elt::mal::rethrow_exception(f.get_exception_ptr());
951 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data(new ::generated::zpb::hellomalif::StdCmds_Return());
955 auto out = new ::generated::zpb::hellomalif::StdCmds_SetLogLevel_Out();
957 *out->mutable_exexceptionerr() = **&_ex;
959 data->set_allocated_setloglevel(out);
965 headerFrame, f.get_exception_ptr());
970 std::unique_ptr<::elt::mal::zpb::rr::ReplyHeader> unhandledExReplyHeader(
971 new ::elt::mal::zpb::rr::ReplyHeader());
973 unhandledExReplyHeader->set_code(::elt::mal::zpb::rr::CompletionCode::UNKNOWN_OPERATION);
975 sendReply(socket,
id, topicIdFrame, headerFrame, std::move(unhandledExReplyHeader),
976 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return>());
981 zmq::socket_t &socket,
const std::string &
id,
const std::string &topicIdFrame,
982 const std::string &headerFrame,
983 std::unique_ptr<::elt::mal::zpb::rr::ReplyHeader> replyHeader,
984 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data) {
993 auto replyStr = reply.SerializeAsString();
995 m_zpbServer.sendReply(socket,
id, topicIdFrame, headerFrame, replyStr);
999 zmq::socket_t &socket,
const std::string &
id,
1000 const std::string &topicIdFrame,
const std::string &headerFrame,
1001 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return> data) {
1002 std::unique_ptr<::elt::mal::zpb::rr::ReplyHeader> completedReplyHeader(
1003 new ::elt::mal::zpb::rr::ReplyHeader());
1005 completedReplyHeader->set_code(::elt::mal::zpb::rr::CompletionCode::COMPLETED);
1007 sendReply(socket,
id, topicIdFrame, headerFrame,
1008 std::move(completedReplyHeader), std::move(data));
1012 zmq::socket_t &socket,
const std::string &
id,
const std::string &topicIdFrame,
1013 const std::string &headerFrame, ::elt::mal::exception_ptr exceptionPtr) {
1014 std::unique_ptr<::elt::mal::zpb::rr::ReplyHeader> unhandledExReplyHeader(
1015 new ::elt::mal::zpb::rr::ReplyHeader());
1017 unhandledExReplyHeader->set_code(::elt::mal::zpb::rr::CompletionCode::UNKNOWN_EXCEPTION);
1019 std::string exceptionMessage =
"Unknown";
1022 ::elt::mal::rethrow_exception(exceptionPtr);
1023 }
catch (std::exception &e) {
1024 exceptionMessage = e.what();
1027 unhandledExReplyHeader->set_exceptionmessage(exceptionMessage);
1029 sendReply(socket,
id, topicIdFrame, headerFrame, std::move(unhandledExReplyHeader),
1030 std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return>());
1034 ::elt::mal::rr::ZpbServer &m_zpbServer;
1035 std::shared_ptr<::hellomalif::AsyncStdCmds> m_entity;
1036 const std::shared_ptr<::elt::mal::Mal>& m_mal;
bool fromByteArray(const void *data, std::size_t size) override
Definition: ZpbHellomalifImpl.hpp:191
ExceptionErrImpl(const ::hellomalif::ExceptionErr &malVal)
Definition: ZpbHellomalifImpl.hpp:54
ExceptionErrImpl(const std::string &desc)
Definition: ZpbHellomalifImpl.hpp:59
ExceptionErrImpl(const ExceptionErrImpl &rhs)
Definition: ZpbHellomalifImpl.hpp:64
void sendReply(zmq::socket_t &socket, const std::string &id, const std::string &topicIdFrame, const std::string &headerFrame, std::unique_ptr<::elt::mal::zpb::rr::ReplyHeader > replyHeader, std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return > data)
Definition: ZpbHellomalifImpl.hpp:980
std::string Disable() override
Definition: ZpbHellomalifImpl.hpp:581
std::unique_ptr<::hellomalif::LogInfo > clone() const override
Definition: ZpbHellomalifImpl.hpp:156
required string logger
Definition: exmalif.proto:25
Definition: Hellomalif.hpp:115
::elt::mal::future< std::string > Stop() override
Definition: ZpbHellomalifImpl.hpp:430
void set_allocated_status(::generated::zpb::hellomalif::StdCmds_Status_In *status)
Definition: hellomalif.pb.h:3134
LogInfoImpl()
Definition: ZpbHellomalifImpl.hpp:113
Definition: Hellomalif.hpp:109
bool toByteArray(zmq::message_t &msg) const override
Definition: ZpbHellomalifImpl.hpp:178
void setLevel(const std::string &level) override
Definition: ZpbHellomalifImpl.hpp:145
Definition: ZpbHellomalifImpl.hpp:108
std::string desc
Definition: Hellomalif.hpp:45
std::string Init() override
Definition: ZpbHellomalifImpl.hpp:551
LogInfoImpl(const LogInfoImpl &rhs)
Definition: ZpbHellomalifImpl.hpp:132
std::string getLogger() const override
Definition: ZpbHellomalifImpl.hpp:148
void copy(const ::hellomalif::LogInfo &from) override
Definition: ZpbHellomalifImpl.hpp:196
std::unique_ptr<::hellomalif::LogInfo > cloneKey() const override
Definition: ZpbHellomalifImpl.hpp:169
ExceptionErrImpl(const ::generated::zpb::hellomalif::ExceptionErr &inner)
Definition: ZpbHellomalifImpl.hpp:49
Definition: ZpbHellomalifImpl.hpp:536
bool keyEquals(const ::hellomalif::LogInfo &other) const override
Definition: ZpbHellomalifImpl.hpp:160
required sfixed32 code
Definition: exmalif.proto:30
Definition: hellomalif.pb.h:1051
::generated::zpb::hellomalif::ExceptionErr ZpbType
Definition: ZpbHellomalifImpl.hpp:39
Definition: Hellomalif.hpp:27
std::string Stop() override
Definition: ZpbHellomalifImpl.hpp:611
::generated::zpb::hellomalif::LogInfo ZpbType
Definition: ZpbHellomalifImpl.hpp:111
std::string Status() override
Definition: ZpbHellomalifImpl.hpp:591
void set_allocated_init(::generated::zpb::hellomalif::StdCmds_Init_In *init)
::generated::zpb::hellomalif::StdCmds_Init_In * mutable_init()
Definition: hellomalif.pb.h:3610
::elt::mal::future< std::string > Exit() override
Definition: ZpbHellomalifImpl.hpp:460
std::size_t keyHash() const
Definition: ZpbHellomalifImpl.hpp:164
Definition: hellomalif.pb.h:1631
::elt::mal::future< void > asyncConnect() override
Definition: ZpbHellomalifImpl.hpp:647
void sendUnhandledExceptionReply(zmq::socket_t &socket, const std::string &id, const std::string &topicIdFrame, const std::string &headerFrame,::elt::mal::exception_ptr exceptionPtr)
Definition: ZpbHellomalifImpl.hpp:1011
void set_allocated_setloglevel(::generated::zpb::hellomalif::StdCmds_SetLogLevel_In *setloglevel)
StdCmdsAsyncImpl(const ::elt::mal::Uri &uri, const std::vector< std::shared_ptr<::elt::mal::rr::qos::QoS >> &standardQoS, const ::elt::mal::Mal::Properties &malSpecificProperties, const std::shared_ptr<::elt::mal::ZpbMal > &zpbMal)
Definition: ZpbHellomalifImpl.hpp:241
void set_allocated_exit(::generated::zpb::hellomalif::StdCmds_Exit_In *exit)
LogInfoImpl(::generated::zpb::hellomalif::LogInfo *inner)
Definition: ZpbHellomalifImpl.hpp:116
bool toByteArray(std::string &output) const override
Definition: ZpbHellomalifImpl.hpp:183
void processRequest(zmq::socket_t &socket, const std::string &id, const std::string &topicIdFrame, const std::string &headerFrame, const ::elt::mal::zpb::rr::ZpbHeader &header)
Definition: ZpbHellomalifImpl.hpp:670
void set_allocated_enable(::generated::zpb::hellomalif::StdCmds_Enable_In *enable)
void setLogger(const std::string &logger) override
Definition: ZpbHellomalifImpl.hpp:152
Definition: hellomalif.pb.h:162
std::string Enable() override
Definition: ZpbHellomalifImpl.hpp:571
void sendCompletedReply(zmq::socket_t &socket, const std::string &id, const std::string &topicIdFrame, const std::string &headerFrame, std::unique_ptr<::generated::zpb::hellomalif::StdCmds_Return > data)
Definition: ZpbHellomalifImpl.hpp:998
AsyncStdCmdsImpl(::elt::mal::rr::ZpbServer &zpbServer, const std::shared_ptr<::hellomalif::AsyncStdCmds > &entity, const std::shared_ptr<::elt::mal::Mal > &mal)
Definition: ZpbHellomalifImpl.hpp:663
package generated zpb hellomalif
Definition: hellomalif.proto:11
::elt::mal::future< std::string > Config() override
Definition: ZpbHellomalifImpl.hpp:400
std::string SetLogLevel(const std::shared_ptr<::hellomalif::LogInfo > &info) override
Definition: ZpbHellomalifImpl.hpp:631
Definition: hellomalif.pb.h:531
ExceptionErrImpl(ExceptionErrImpl &&rhs)
Definition: ZpbHellomalifImpl.hpp:66
Definition: hellomalif.pb.h:739
::generated::zpb::hellomalif::LogInfo * mutable_info()
Definition: hellomalif.pb.h:3545
Definition: ZpbHellomalifImpl.hpp:231
LogInfoImpl(const ::generated::zpb::hellomalif::LogInfo &inner)
Definition: ZpbHellomalifImpl.hpp:121
bool fromByteArray(const std::string &data) override
Definition: ZpbHellomalifImpl.hpp:187
Definition: ZpbHellomalifImpl.hpp:235
::generated::zpb::hellomalif::StdCmds_Call * mutable_data()
Definition: hellomalif.pb.h:4070
message LogInfo
Definition: exmalif.proto:23
LogInfoImpl(const std::string &level, const std::string &logger)
Definition: ZpbHellomalifImpl.hpp:126
std::string getLevel() const override
Definition: ZpbHellomalifImpl.hpp:141
void set_allocated_header(::elt::mal::zpb::rr::ReplyHeader *header)
Definition: hellomalif.pb.h:5234
std::string getDesc() const override
Definition: ZpbHellomalifImpl.hpp:73
ExceptionErrImpl & operator=(const ExceptionErrImpl &that)
Definition: ZpbHellomalifImpl.hpp:68
Definition: hellomalif.pb.h:284
void close() override
Definition: ZpbHellomalifImpl.hpp:643
void set_allocated_data(::generated::zpb::hellomalif::StdCmds_Return *data)
Definition: hellomalif.pb.h:5292
void set_allocated_reset(::generated::zpb::hellomalif::StdCmds_Reset_In *reset)
::elt::mal::future< std::string > SetLogLevel(const std::shared_ptr<::hellomalif::LogInfo > &info) override
Definition: ZpbHellomalifImpl.hpp:490
void copy(const ::hellomalif::ExceptionErr &from)
Definition: ZpbHellomalifImpl.hpp:77
void set_allocated_config(::generated::zpb::hellomalif::StdCmds_Config_In *config)
Definition: hellomalif.pb.h:1155
std::string Config() override
Definition: ZpbHellomalifImpl.hpp:601
Definition: hellomalif.pb.h:947
::elt::mal::rr::ListenerRegistration registerConnectionListener(ConnectionListener listener) override
Definition: ZpbHellomalifImpl.hpp:651
static int32_t typeHash()
Definition: ZpbHellomalifImpl.hpp:205
::elt::mal::future< std::string > Reset() override
Definition: ZpbHellomalifImpl.hpp:280
LogInfoImpl & operator=(const LogInfoImpl &that)
Definition: ZpbHellomalifImpl.hpp:136
std::string Reset() override
Definition: ZpbHellomalifImpl.hpp:561
ExceptionErrImpl(::generated::zpb::hellomalif::ExceptionErr *inner)
Definition: ZpbHellomalifImpl.hpp:44
std::string Exit() override
Definition: ZpbHellomalifImpl.hpp:621
Definition: ZpbHellomalifImpl.hpp:661
void set_allocated_stop(::generated::zpb::hellomalif::StdCmds_Stop_In *stop)
::elt::mal::future< std::string > Disable() override
Definition: ZpbHellomalifImpl.hpp:340
LogInfoImpl(LogInfoImpl &&rhs)
Definition: ZpbHellomalifImpl.hpp:134
StdCmdsSyncImpl(const ::elt::mal::Uri &uri, const std::vector< std::shared_ptr<::elt::mal::rr::qos::QoS >> &standardQoS, const ::elt::mal::Mal::Properties &malSpecificProperties, const std::shared_ptr<::elt::mal::ZpbMal > &zpbMal)
Definition: ZpbHellomalifImpl.hpp:538
Definition: hellomalif.pb.h:843
void set_allocated_disable(::generated::zpb::hellomalif::StdCmds_Disable_In *disable)
message ExceptionErr
Definition: exmalif.proto:28
Definition: hellomalif.pb.h:1259
::elt::mal::future< std::string > Init() override
Definition: ZpbHellomalifImpl.hpp:250
Definition: ZpbHellomalifImpl.hpp:37
::elt::mal::future< std::string > Status() override
Definition: ZpbHellomalifImpl.hpp:370
Definition: Hellomalif.hpp:50
std::shared_ptr<::elt::mal::Mal > getMal() const override
Definition: ZpbHellomalifImpl.hpp:547
Definition: hellomalif.pb.h:635
Definition: hellomalif.pb.h:427
::elt::mal::future< std::string > Enable() override
Definition: ZpbHellomalifImpl.hpp:310
ExceptionErrImpl()
Definition: ZpbHellomalifImpl.hpp:41
bool hasKey() const override
Definition: ZpbHellomalifImpl.hpp:174