Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed May 28, 2024
2 parents 194eadc + a497307 commit b1c67ca
Show file tree
Hide file tree
Showing 21 changed files with 459 additions and 50 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option (CC_TOOLS_QT_INSTALL_LIBRARY_HEADERS "Install tools library headers." ON)
option (CC_TOOLS_QT_BUILD_APPS "Build tool applications." ON)
option (CC_TOOLS_QT_BUILD_PLUGINS "Build plugins." ${CC_TOOLS_QT_BUILD_APPS})
option (CC_TOOLS_QT_WARN_AS_ERR "Treat warning as error" ON)
option (CC_TOOLS_QT_USE_CCACHE "Use ccache on UNIX systems if it's available" ON)
option (CC_TOOLS_QT_USE_CCACHE "Use ccache on UNIX systems if it's available" OFF)
option (CC_TOOLS_QT_STATIC_RUNTIME "Enable/Disable static runtime" OFF)

# More fine-grained options
Expand Down
19 changes: 13 additions & 6 deletions app/cc_view/src/GuiAppMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ QString GuiAppMgr::messageDesc(const Message& msg)
return QString("(%1) %2").arg(msg.idAsString()).arg(msg.name());
}

void GuiAppMgr::setDebugOutputLevel(unsigned level)
{
m_debugOutputLevel = level;
}

void GuiAppMgr::pluginsEditClicked()
{
emit sigPluginsEditDialog();
Expand Down Expand Up @@ -531,12 +536,12 @@ void GuiAppMgr::sendUpdateList(const MessagesList& msgs)
void GuiAppMgr::deleteMessages(MessagesList&& msgs)
{
auto& msgMgr = MsgMgrG::instanceRef();
for (auto& m : msgs) {
assert(m);
assert(m != m_clickedMsg);

msgMgr.deleteMsg(std::move(m));
if (msgMgr.getAllMsgs().size() == msgs.size()) {
msgMgr.deleteAllMsgs();
return;
}

msgMgr.deleteMsgs(msgs);
}

void GuiAppMgr::sendMessages(MessagesList&& msgs)
Expand Down Expand Up @@ -626,6 +631,8 @@ bool GuiAppMgr::applyNewPlugins(const ListOfPluginInfos& plugins)
continue;
}

plugin->setDebugOutputLevel(m_debugOutputLevel);

if (!applyInfo.m_socket) {
applyInfo.m_socket = plugin->createSocket();
}
Expand Down Expand Up @@ -753,7 +760,7 @@ void GuiAppMgr::msgAdded(MessagePtr msg)
prefix = SentPrefix;
}

std::cout << prefix << msg->name() << std::endl;
std::cout << '[' << property::message::Timestamp().getFrom(*msg) << "] " << prefix << msg->name() << std::endl;
#endif

if (!canAddToRecvList(*msg, type)) {
Expand Down
4 changes: 4 additions & 0 deletions app/cc_view/src/GuiAppMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class GuiAppMgr : public QObject

static QString messageDesc(const Message& msg);

void setDebugOutputLevel(unsigned level);

public slots:
void pluginsEditClicked();

Expand Down Expand Up @@ -260,6 +262,8 @@ private /*data*/:
MsgSendMgr m_sendMgr;

FilteredMessages m_filteredMessages;

unsigned m_debugOutputLevel = 0U;
};

} // namespace cc_tools_qt
Expand Down
10 changes: 10 additions & 0 deletions app/cc_view/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace
const QString CleanOptStr("clean");
const QString ConfigOptStr("config");
const QString PluginsOptStr("plugins");
const QString DebugOptStr("debug");

void metaTypesRegisterAll()
{
Expand Down Expand Up @@ -80,6 +81,14 @@ void prepareCommandLineOptions(QCommandLineParser& parser)
QCoreApplication::translate("main", "filename")
);
parser.addOption(pluginsOpt);

QCommandLineOption debugOpt(
QStringList() << "d" << DebugOptStr,
QCoreApplication::translate("main", "Debug output level. When 0 means no output"),
QCoreApplication::translate("main", "value") + " (=0)",
"0"
);
parser.addOption(debugOpt);
}

} // namespace
Expand Down Expand Up @@ -110,6 +119,7 @@ int main(int argc, char *argv[])
pluginMgr.setPluginsDir(pluginsDir);

auto& guiAppMgr = cc::GuiAppMgr::instanceRef();
guiAppMgr.setDebugOutputLevel(parser.value(DebugOptStr).toUInt());
do {
if (parser.isSet(CleanOptStr) && guiAppMgr.startClean()) {
break;
Expand Down
37 changes: 30 additions & 7 deletions app/cc_view/src/ui/MessagesFilterDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
<item>
<widget class="QLabel" name="m_searchLabel">
<property name="text">
<string>Search:</string>
<string>&amp;Search:</string>
</property>
<property name="buddy">
<cstring>m_searchLineEdit</cstring>
</property>
</widget>
</item>
Expand Down Expand Up @@ -79,7 +82,11 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="m_visibleListWidget"/>
<widget class="QListWidget" name="m_visibleListWidget">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
</layout>
</widget>
Expand All @@ -106,21 +113,27 @@
<item>
<widget class="QPushButton" name="m_hideAllPushButton">
<property name="toolTip">
<string>Hide All</string>
<string>Hide All [Ctrl+Shifth+Right]</string>
</property>
<property name="text">
<string>&gt;&gt;</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+Right</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_hideSelectedPushButton">
<property name="toolTip">
<string>Hide Selected</string>
<string>Hide Selected [Alt+Right]</string>
</property>
<property name="text">
<string>&gt;</string>
</property>
<property name="shortcut">
<string>Alt+Right</string>
</property>
</widget>
</item>
<item>
Expand All @@ -133,21 +146,27 @@
<item>
<widget class="QPushButton" name="m_showSelectedPushButton">
<property name="toolTip">
<string>Show Selected</string>
<string>Show Selected [Alt+Left]</string>
</property>
<property name="text">
<string>&lt;</string>
</property>
<property name="shortcut">
<string>Alt+Left</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_showAllPushButton">
<property name="toolTip">
<string>Show All</string>
<string>Show All [Ctrl+Shift+Left]</string>
</property>
<property name="text">
<string>&lt;&lt;</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+Left</string>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -187,7 +206,11 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QListWidget" name="m_hiddenListWidget"/>
<widget class="QListWidget" name="m_hiddenListWidget">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
</layout>
</widget>
Expand Down
14 changes: 14 additions & 0 deletions lib/include/cc_tools_qt/Filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ class CC_API Filter
m_interPluginConfigReportCallback = std::forward<TFunc>(func);
}

/// @brief Set debug output level
/// @param[in] level Debug level. If @b 0, debug output is disabled
void setDebugOutputLevel(unsigned level = 0U);

protected:
/// @brief Polymorphic start functionality implementation.
/// @details Invoked by start() and default implementation does nothing.
Expand Down Expand Up @@ -154,6 +158,9 @@ class CC_API Filter
/// @param[in] props Properties map.
virtual void applyInterPluginConfigImpl(const QVariantMap& props);

/// @brief Get plugin name for the debug output
virtual const char* debugNameImpl() const;

/// @brief Report new data to send generated by the filter itself.
/// @details This function needs to be invoked by the derived class when
/// when it has new data to be sent over I/O link. This function
Expand All @@ -176,10 +183,17 @@ class CC_API Filter
/// @param[in] props Reported properties.
void reportInterPluginConfig(const QVariantMap& props);

/// @brief Get current timestamp
static unsigned long long currTimestamp();

/// @brief Get current debug output level
unsigned getDebugOutputLevel() const;

private:
DataToSendCallback m_dataToSendCallback;
ErrorReportCallback m_errorReportCallback;
InterPluginConfigReportCallback m_interPluginConfigReportCallback;
unsigned m_debugLevel = 0U;
};

/// @brief Pointer to @ref Filter object.
Expand Down
4 changes: 3 additions & 1 deletion lib/include/cc_tools_qt/MsgMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include <memory>
#include <list>
#include <vector>

#include "Api.h"
Expand All @@ -35,7 +36,7 @@ class MsgMgrImpl;
class CC_API MsgMgr
{
public:
typedef std::vector<MessagePtr> AllMessages;
typedef std::list<MessagePtr> AllMessages;
typedef Protocol::MessagesList MessagesList;

typedef Message::Type MsgType;
Expand All @@ -52,6 +53,7 @@ class CC_API MsgMgr
void setRecvEnabled(bool enabled);

void deleteMsg(MessagePtr msg);
void deleteMsgs(const MessagesList& msgs);
void deleteAllMsgs();

void sendMsgs(MessagesList&& msgs);
Expand Down
5 changes: 5 additions & 0 deletions lib/include/cc_tools_qt/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ class CC_API Plugin : public QObject
/// @brief Set callback to report inter-plugin configuration.
void setInterPluginConfigReportCallback(InterPluginConfigReportCallback&& func);

/// @brief Set debug output level
/// @param[in] level Debug level. If @b 0, debug output is disabled
void setDebugOutputLevel(unsigned level = 0U);

protected:
/// @brief Polymorphic call to retrieve current configuration
/// @details Default implementation does nothing. The derived class
Expand Down Expand Up @@ -172,6 +176,7 @@ class CC_API Plugin : public QObject
private:
PluginProperties m_props;
InterPluginConfigReportCallback m_interPluginConfigReportCallback;
unsigned m_debugOutputLevel = 0U;
};

} // namespace cc_tools_qt
Expand Down
8 changes: 8 additions & 0 deletions lib/include/cc_tools_qt/Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ class CC_API Protocol
/// @param[in] props Properties map.
void applyInterPluginConfig(const QVariantMap& props);

/// @brief Set debug output level
/// @param[in] level Debug level. If @b 0, debug output is disabled
void setDebugOutputLevel(unsigned level = 0U);

/// @brief Type of callback to report errors
using ErrorReportCallback = std::function<void (const QString& msg)>;

Expand Down Expand Up @@ -244,6 +248,9 @@ class CC_API Protocol
/// @param[in] props Reported properties.
void reportInterPluginConfig(const QVariantMap& props);

/// @brief Get current debug output level
unsigned getDebugOutputLevel() const;

/// @brief Helper function to assign "tranport message" object as a property
/// of application message object.
static void setTransportToMessageProperties(MessagePtr transportMsg, Message& msg);
Expand Down Expand Up @@ -279,6 +286,7 @@ class CC_API Protocol
ErrorReportCallback m_errorReportCallback;
SendMessageRequestCallback m_sendMessageRequestCallback;
InterPluginConfigReportCallback m_interPluginConfigReportCallback;
unsigned m_debugLevel = 0U;
};

/// @brief Pointer to @ref Protocol object.
Expand Down
11 changes: 11 additions & 0 deletions lib/include/cc_tools_qt/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ class CC_API Socket
m_interPluginConfigReportCallback = std::forward<TFunc>(func);
}

/// @brief Set debug output level
/// @param[in] level Debug level. If @b 0, debug output is disabled
void setDebugOutputLevel(unsigned level = 0U);

protected:
/// @brief Polymorphic start functionality implementation.
/// @details Invoked by start() and default implementation does nothing.
Expand Down Expand Up @@ -221,12 +225,19 @@ class CC_API Socket
/// @param[in] props Reported properties.
void reportInterPluginConfig(const QVariantMap& props);

/// @brief Get current timestamp
static unsigned long long currTimestamp();

/// @brief Get current debug output level
unsigned getDebugOutputLevel() const;

private:
DataReceivedCallback m_dataReceivedCallback;
ErrorReportCallback m_errorReportCallback;
ConnectionStatusReportCallback m_connectionStatusReportCallback;
InterPluginConfigReportCallback m_interPluginConfigReportCallback;

unsigned m_debugLevel = 0U;
bool m_running = false;
bool m_connected = false;
};
Expand Down
Loading

0 comments on commit b1c67ca

Please sign in to comment.