1#ifndef RTCTK_COMPONENTFRAMEWORK_INTROSPECTIONIMPL_HPP
2#define RTCTK_COMPONENTFRAMEWORK_INTROSPECTIONIMPL_HPP
14#include <Introspectionif.hpp>
17#include <rtctk/componentFramework/events.rad.hpp>
26#include <nlohmann/json.hpp>
39 std::shared_ptr<elt::mal::rr::RrEntity> rr_service =
40 std::make_shared<IntrospectionImpl>(engine, replier);
41 replier.
RegisterService<introspectionif::AsyncIntrospection>(
"Introspection", rr_service);
45 : m_engine(engine), m_replier(replier) {
48 ::elt::mal::future<std::string>
GetInterfaces(
const std::string& service)
override {
49 LOG4CPLUS_TRACE(
GetLogger(),
"Received command 'GetInterfaces'");
50 boost::promise<std::string> promise;
53 auto xmls_vector = this->m_replier.GetServiceDescriptions(service);
55 ::nlohmann::json ret_json = ::nlohmann::json::object({});
56 for (
const auto& xml : xmls_vector) {
57 ret_json += ::nlohmann::json::object_t::value_type(xml.first, xml.second);
59 promise.set_value(ret_json.dump());
60 }
catch (::nlohmann::json::type_error& ex) {
62 fmt::format(
"Error while creating JSON reply: \nmessage: {}\nexception id: {}",
67 stdif::ExceptionErr(msg, 3002);
68 promise.set_exception(new_exception);
71 return promise.get_future();
74 ::elt::mal::future<std::string>
GetTopics(
const std::string& topic)
override {
75 LOG4CPLUS_TRACE(
GetLogger(),
"Received command 'GetTopics'");
76 boost::promise<std::string> promise;
77 LOG4CPLUS_INFO(
GetLogger(),
"NOT IMPLEMENTED");
79 stdif::ExceptionErr(
"NOT IMPLEMENTED", 3001);
80 promise.set_exception(new_exception);
81 return promise.get_future();
85 LOG4CPLUS_TRACE(
GetLogger(),
"Received command 'GetOldbPrefix'");
86 boost::promise<std::string> promise;
87 LOG4CPLUS_INFO(
GetLogger(),
"NOT IMPLEMENTED");
88 auto new_exception = stdif::ExceptionErr(
"NOT IMPLEMENTED", 3001);
89 promise.set_exception(new_exception);
90 return promise.get_future();
Class that handles reception of commands using MAL.
Definition commandReplier.hpp:29
void RegisterService(const std::string &name, std::shared_ptr< elt::mal::rr::RrEntity > &service)
Definition commandReplier.hpp:36
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition introspectionImpl.hpp:38
::elt::mal::future< std::string > GetInterfaces(const std::string &service) override
Definition introspectionImpl.hpp:48
IntrospectionImpl(StateMachineEngine &engine, CommandReplier &replier)
Definition introspectionImpl.hpp:44
::elt::mal::future< std::string > GetOldbPrefix() override
Definition introspectionImpl.hpp:84
::elt::mal::future< std::string > GetTopics(const std::string &topic) override
Definition introspectionImpl.hpp:74
Definition stateMachineEngine.hpp:34
Receive commands via MAL.
log4cplus::Logger & GetLogger(const std::string &name="app")
Get handle to a specific logger.
Definition logger.cpp:191
Logging Support Library based on log4cplus.
Provides core functionality of an RTC Component.
Definition commandReplier.cpp:21
Wrapper around the SCXML State Machine Engine.