1#ifndef RTCTK_COMPONENTFRAMEWORK_INTROSPECTIONIMPL_HPP
2#define RTCTK_COMPONENTFRAMEWORK_INTROSPECTIONIMPL_HPP
15#include <Introspectionif.hpp>
18#include <rtctk/componentFramework/events.rad.hpp>
27#include <nlohmann/json.hpp>
40 std::shared_ptr<elt::mal::rr::RrEntity> rr_service =
41 std::make_shared<IntrospectionImpl>(engine, replier);
42 replier.
RegisterService<introspectionif::AsyncIntrospection>(
"Introspection", rr_service);
46 : m_engine(engine), m_replier(replier) {
49 ::elt::mal::future<std::string>
GetInterfaces(
const std::string& service) {
50 LOG4CPLUS_TRACE(
GetLogger(),
"Received command 'GetInterfaces'");
51 boost::promise<std::string> promise;
56 ::nlohmann::json ret_json = ::nlohmann::json::object({});
57 for (
const auto& xml : xmls_vector) {
58 ret_json += ::nlohmann::json::object_t::value_type(xml.first, xml.second);
60 promise.set_value(ret_json.dump());
61 }
catch (::nlohmann::json::type_error& ex) {
63 fmt::format(
"Error while creating JSON reply: \nmessage: {}\nexception id: {}",
68 stdif::ExceptionErr(msg, 3002);
69 promise.set_exception(new_exception);
72 return promise.get_future();
75 ::elt::mal::future<std::string>
GetTopics(
const std::string& topic) {
76 LOG4CPLUS_TRACE(
GetLogger(),
"Received command 'GetTopics'");
77 boost::promise<std::string> promise;
78 LOG4CPLUS_INFO(
GetLogger(),
"NOT IMPLEMENTED");
80 stdif::ExceptionErr(
"NOT IMPLEMENTED", 3001);
81 promise.set_exception(new_exception);
82 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
std::vector< std::pair< std::string, std::string > > GetServiceDescriptions(const std::string &service_name=std::string())
Definition: commandReplier.hpp:41
void RegisterService(std::string const &name, std::shared_ptr< elt::mal::rr::RrEntity > &service)
Definition: commandReplier.hpp:36
Class that handles reception of introspection commands.
Definition: introspectionImpl.hpp:37
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition: introspectionImpl.hpp:39
::elt::mal::future< std::string > GetOldbPrefix()
Definition: introspectionImpl.hpp:84
::elt::mal::future< std::string > GetTopics(const std::string &topic)
Definition: introspectionImpl.hpp:75
::elt::mal::future< std::string > GetInterfaces(const std::string &service)
Definition: introspectionImpl.hpp:49
IntrospectionImpl(StateMachineEngine &engine, CommandReplier &replier)
Definition: introspectionImpl.hpp:45
Definition: stateMachineEngine.hpp:35
Receive commands via MAL.
log4cplus::Logger & GetLogger(const std::string &name="app")
Get handle to a specific logger.
Definition: logger.cpp:180
Logging Support Library based on log4cplus.
Provides core functionality of an RTC Component.
Definition: commandReplier.cpp:22
Wrapper around the SCXML State Machine Engine.