16#ifndef IOX_TOOLS_ICEORYX_INTROSPECTION_INTROSPECTION_APP_HPP
17#define IOX_TOOLS_ICEORYX_INTROSPECTION_INTROSPECTION_APP_HPP
19#include "iceoryx_hoofs/platform/getopt.hpp"
20#include "iceoryx_introspection/introspection_types.hpp"
21#include "iceoryx_posh/popo/subscriber.hpp"
31namespace introspection
33static constexpr option longOptions[] = {{
"help", no_argument,
nullptr,
'h'},
34 {
"version", no_argument,
nullptr,
'v'},
35 {
"time", required_argument,
nullptr,
't'},
36 {
"mempool", no_argument,
nullptr, 0},
37 {
"port", no_argument,
nullptr, 0},
38 {
"process", no_argument,
nullptr, 0},
39 {
"all", no_argument,
nullptr, 0},
40 {
nullptr, 0,
nullptr, 0}};
42static constexpr const char* shortOptions =
"hvt:";
44static constexpr iox::units::Duration MIN_UPDATE_PERIOD = 500_ms;
45static constexpr iox::units::Duration DEFAULT_UPDATE_PERIOD = 1000_ms;
46static constexpr iox::units::Duration MAX_UPDATE_PERIOD = 10000_ms;
49enum class ColorPairs : uint8_t
56static const std::map<PrettyOptions, uint32_t> prettyMap = {
57 {PrettyOptions::title, A_BOLD | COLOR_PAIR(
static_cast<uint8_t
>(ColorPairs::redOnBlack))},
58 {PrettyOptions::highlight, A_BOLD | A_UNDERLINE},
59 {PrettyOptions::error, A_BOLD | COLOR_PAIR(
static_cast<uint8_t
>(ColorPairs::whiteOnRed))},
60 {PrettyOptions::bold, A_BOLD},
61 {PrettyOptions::normal, A_NORMAL}};
77 virtual void run() noexcept = 0;
80 enum class CmdLineArgumentParsingMode
88 bool doIntrospection =
false;
94 parseCmdLineArguments(
int argc,
96 CmdLineArgumentParsingMode cmdLineParsingMode = CmdLineArgumentParsingMode::ALL) noexcept;
98 void runIntrospection(const iox::units::Duration updatePeriodMs,
106 void clearToBottom();
109 void closeTerminal();
112 void refreshTerminal();
115 void updateDisplayYX();
119 void waitForUserInput(int32_t timeoutMs);
122 void printShortInfo(const std::
string& binaryName) noexcept;
127 void prettyPrint(const std::
string& str, const PrettyOptions pr = PrettyOptions::normal);
130 void printProcessIntrospectionData(const ProcessIntrospectionFieldTopic* processIntrospectionField);
133 void printMemPoolInfo(const MemPoolIntrospectionInfo& introspectionInfo);
136 template <typename Subscriber>
137 bool waitForSubscription(Subscriber& port);
141 composePublisherPortData(const PortIntrospectionFieldTopic* portData,
142 const PortThroughputIntrospectionFieldTopic* throughputData);
146 composeSubscriberPortData(const PortIntrospectionFieldTopic* portData,
147 const SubscriberPortChangingIntrospectionFieldTopic* subscriberPortChangingData);
154 void printHelp() noexcept;
156 template <typename T>
157 T bounded(T input, T min, T max) noexcept
159 return ((input >= min) ? ((input <= max) ? input : max) : min);
163 iox::units::Duration updatePeriodMs = DEFAULT_UPDATE_PERIOD;
base class for introspection
Definition: introspection_app.hpp:67
virtual void run() noexcept=0
interface to start the execution of the introspection
IntrospectionApp() noexcept
this is needed for the child classes to extend the parseCmdLineArguments function
IntrospectionApp(int argc, char *argv[]) noexcept
constructor to create a introspection
Definition: introspection_types.hpp:50
Definition: introspection_types.hpp:61
Definition: introspection_types.hpp:42