Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #111][COMPONENTS] Introduce components architecture in the project #143

Merged
merged 1 commit into from
Dec 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 46 additions & 41 deletions dltmessageanalyzerplugin/src/CDLTMessageAnalyzer.cpp

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dltmessageanalyzerplugin/src/CDLTMessageAnalyzer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* @brief Definition of the CDLTMessageAnalyzer class
*/

#ifndef CDLTMESSAGEANALYZER_HPP
#define CDLTMESSAGEANALYZER_HPP
#pragma once

#include "memory"

Expand All @@ -24,6 +23,7 @@

#include "common/Definitions.hpp"
#include "components/analyzer/api/IDLTMessageAnalyzerControllerConsumer.hpp"
#include "components/settings/api/CSettingsManagerClient.hpp"

#include "QElapsedTimer"

Expand All @@ -48,7 +48,8 @@ class CTableMemoryJumper;
* @brief The CDLTMessageAnalyzer class - used as a main controller of the plugin.
* Entry point to majority of plugin's business-logic.
*/
class CDLTMessageAnalyzer : public IDLTMessageAnalyzerControllerConsumer
class CDLTMessageAnalyzer : public IDLTMessageAnalyzerControllerConsumer,
public CSettingsManagerClient
{
Q_OBJECT

Expand All @@ -68,7 +69,8 @@ class CDLTMessageAnalyzer : public IDLTMessageAnalyzerControllerConsumer
CUMLView* pUMLView, const std::shared_ptr<CTableMemoryJumper>& pSearchViewTableJumper,
CSearchResultView* pSearchResultView,
const std::shared_ptr<ISearchResultModel>& pSearchResultModel,
const std::weak_ptr<IDLTLogsWrapperCreator>& pDLTLogsWrapperCreator);
const std::weak_ptr<IDLTLogsWrapperCreator>& pDLTLogsWrapperCreator,
const tSettingsManagerPtr& pSettingsManagerPtr);

/**
* @brief setFile - set's the file to be used for analysis
Expand Down Expand Up @@ -307,5 +309,3 @@ class CDLTMessageAnalyzer : public IDLTMessageAnalyzerControllerConsumer
std::shared_ptr<CTableMemoryJumper> mpSearchViewTableJumper;
std::weak_ptr<IDLTLogsWrapperCreator> mpDLTLogsWrapperCreator;
};

#endif // CDLTMESSAGEANALYZER_HPP
1 change: 0 additions & 1 deletion dltmessageanalyzerplugin/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ include_directories(../../thirdparty/DMA_Plantuml/src)

DMA_add_subdirectory_with_clang_tidy(common)
DMA_add_subdirectory_with_clang_tidy(components)
DMA_add_subdirectory_with_clang_tidy(settings)

add_library(DLT-Message-Analyzer MODULE
dltmessageanalyzerplugin.cpp
Expand Down
3 changes: 2 additions & 1 deletion dltmessageanalyzerplugin/src/components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ DMA_add_subdirectory_with_clang_tidy(logo)
DMA_add_subdirectory_with_clang_tidy(logsWrapper)
DMA_add_subdirectory_with_clang_tidy(patternsView)
DMA_add_subdirectory_with_clang_tidy(plant_uml)
DMA_add_subdirectory_with_clang_tidy(searchView)
DMA_add_subdirectory_with_clang_tidy(searchView)
DMA_add_subdirectory_with_clang_tidy(settings)
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

#include "components/analyzer/api/IDLTMessageAnalyzerController.hpp"

class CAnalyzerComponent : public DMA::IComponent
#include "components/settings/api/CSettingsManagerClient.hpp"

class CAnalyzerComponent : public DMA::IComponent,
public CSettingsManagerClient
{
public:

CAnalyzerComponent();
CAnalyzerComponent(const tSettingsManagerPtr& pSettingsManagerPtr);
std::shared_ptr<IDLTMessageAnalyzerController> getAnalyzerController() const;

virtual const char* getName() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public slots:
const int& numberOfMessages,
const QRegularExpression& regex,
const int& numberOfThreads,
bool isContinuous );
bool isContinuous,
bool bUMLFeatureActive );
void cancelRequest( const tRequestId& requestId );

protected: // fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

#include "dma/base/ForceLink.hpp"

CAnalyzerComponent::CAnalyzerComponent():
CAnalyzerComponent::CAnalyzerComponent(const tSettingsManagerPtr& pSettingsManagerPtr):
CSettingsManagerClient(pSettingsManagerPtr),
mpMessageAnalyzerController(nullptr)
{
// force linkage references in order to have consistent diagrams
Expand All @@ -25,7 +26,7 @@ DMA::tSyncInitOperationResult CAnalyzerComponent::init()

try
{
auto pMTController = IDLTMessageAnalyzerController::createInstance<CMTAnalyzer>();
auto pMTController = IDLTMessageAnalyzerController::createInstance<CMTAnalyzer>(getSettingsManager());
mpMessageAnalyzerController = IDLTMessageAnalyzerController::createInstance<CContinuousAnalyzer>(pMTController);

result.bIsOperationSuccessful = true;
Expand Down Expand Up @@ -72,6 +73,7 @@ CAnalyzerComponent::getAnalyzerController() const
PUML_PACKAGE_BEGIN(DMA_Analyzer_API)
PUML_CLASS_BEGIN(CAnalyzerComponent)
PUML_INHERITANCE_CHECKED(DMA::IComponent, implements)
PUML_INHERITANCE_CHECKED(CSettingsManagerClient, extends)
PUML_COMPOSITION_DEPENDENCY_CHECKED(CContinuousAnalyzer, 1, 1, contains)
PUML_USE_DEPENDENCY_CHECKED(CMTAnalyzer, 1, 1, creates and feeds into CContinuousAnalyzer)
PUML_CLASS_END()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "QElapsedTimer"
#endif

#include "settings/CSettingsManager.hpp"
#include "components/settings/api/ISettingsManager.hpp"
#include "components/log/api/CLog.hpp"
#include "CDLTRegexAnalyzerWorker.hpp"

Expand All @@ -25,9 +25,10 @@ Q_DECLARE_METATYPE(CDLTRegexAnalyzerWorker::ePortionAnalysisState)
static std::atomic<tWorkerId> sWorkerIdCounter(0);

//CDLTRegexAnalyzerWorker
CDLTRegexAnalyzerWorker::CDLTRegexAnalyzerWorker():
mWorkerId(++sWorkerIdCounter),
mColors()
CDLTRegexAnalyzerWorker::CDLTRegexAnalyzerWorker(const tSettingsManagerPtr& pSettingsManagerPtr):
CSettingsManagerClient(pSettingsManagerPtr),
mWorkerId(++sWorkerIdCounter),
mColors()
{
qRegisterMetaType<tFoundMatchesPack>("tFoundMatchesPack");
qRegisterMetaType<ePortionAnalysisState>("ePortionAnalysisState");
Expand All @@ -36,13 +37,13 @@ CDLTRegexAnalyzerWorker::CDLTRegexAnalyzerWorker():
qRegisterMetaType<tWorkerThreadCookie>("tWorkerThreadCookie");
qRegisterMetaType<tRegexScriptingMetadata>("tRegexScriptingMetadata");

connect( CSettingsManager::getInstance().get(), &CSettingsManager::searchResultHighlightingGradientChanged,
connect( getSettingsManager().get(), &ISettingsManager::searchResultHighlightingGradientChanged,
[this]( const tHighlightingGradient& gradient )
{
mColors = generateColors(gradient);
});

mColors = generateColors(CSettingsManager::getInstance()->getSearchResultHighlightingGradient());
mColors = generateColors(getSettingsManager()->getSearchResultHighlightingGradient());
}

tWorkerId CDLTRegexAnalyzerWorker::getWorkerId() const
Expand All @@ -67,7 +68,7 @@ void CDLTRegexAnalyzerWorker::analyzePortion( const tRequestId& requestId,

bool bAnalyzeUML = false;

if(true == CSettingsManager::getInstance()->getUML_FeatureActive() &&
if(true == getSettingsManager()->getUML_FeatureActive() &&
true == regexMetadata.doesContainAnyUMLGroup() &&
true == regexMetadata.doesContainConsistentUMLData(false).first)
{
Expand Down Expand Up @@ -141,5 +142,6 @@ void CDLTRegexAnalyzerWorker::analyzePortion( const tRequestId& requestId,
PUML_PACKAGE_BEGIN(DMA_Analyzer)
PUML_CLASS_BEGIN_CHECKED(CDLTRegexAnalyzerWorker)
PUML_INHERITANCE_CHECKED(QObject, extends)
PUML_INHERITANCE_CHECKED(CSettingsManagerClient, extends)
PUML_CLASS_END()
PUML_PACKAGE_END()
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
#include "common/Definitions.hpp"
#include "../api/IDLTMessageAnalyzerController.hpp"

#include "components/settings/api/CSettingsManagerClient.hpp"

typedef int tWorkerThreadCookie;

/**
* @brief The CDLTRegexAnalyzerWorker class - an object, which is actually performs a regex analysis.
* Intention is to use one or more of these instances in context of worker-thread(s).
*/
class CDLTRegexAnalyzerWorker : public QObject
class CDLTRegexAnalyzerWorker : public QObject,
public CSettingsManagerClient
{
Q_OBJECT
public:
Expand All @@ -31,7 +34,7 @@ class CDLTRegexAnalyzerWorker : public QObject
ePortionAnalysisState_ERROR
};

CDLTRegexAnalyzerWorker();
CDLTRegexAnalyzerWorker(const tSettingsManagerPtr& pSettingsManagerPtr);
tWorkerId getWorkerId() const;

public slots:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Q_DECLARE_METATYPE(tWorkerId)
static const int CHUNK_SIZE = 4000;

//CMTAnalyzer
CMTAnalyzer::CMTAnalyzer():
CMTAnalyzer::CMTAnalyzer(const tSettingsManagerPtr& pSettingsManagerPtr):
CSettingsManagerClient(pSettingsManagerPtr),
mWorkerItemMap(),
mRequestIdCounter( static_cast<uint64_t>(-1) )
{
Expand All @@ -40,7 +41,7 @@ mRequestIdCounter( static_cast<uint64_t>(-1) )

for(int i = 0; i < threadsNumber; ++i )
{
CDLTRegexAnalyzerWorker* pWorker = new CDLTRegexAnalyzerWorker();
CDLTRegexAnalyzerWorker* pWorker = new CDLTRegexAnalyzerWorker(getSettingsManager());

// instance of CDLTRegexAnalyzerWorker, located in QThread will send updates to CMTAnalyzer
connect(pWorker, &CDLTRegexAnalyzerWorker::portionAnalysisFinished, this, &CMTAnalyzer::portionRegexAnalysisFinished, Qt::QueuedConnection);
Expand Down Expand Up @@ -467,6 +468,7 @@ CMTAnalyzer::tRequestData::tRequestData( const std::weak_ptr<IDLTMessageAnalyzer
PUML_PACKAGE_BEGIN(DMA_Analyzer)
PUML_CLASS_BEGIN_CHECKED(CMTAnalyzer)
PUML_INHERITANCE_CHECKED(IDLTMessageAnalyzerController, implements)
PUML_INHERITANCE_CHECKED(CSettingsManagerClient, extends)
PUML_COMPOSITION_DEPENDENCY_CHECKED(QThread, 1, *, contains)
PUML_COMPOSITION_DEPENDENCY_CHECKED(CDLTRegexAnalyzerWorker, 1, *, contains)
PUML_CLASS_END()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
#include "../api/IDLTMessageAnalyzerController.hpp"
#include "CDLTRegexAnalyzerWorker.hpp"

#include "components/settings/api/CSettingsManagerClient.hpp"

//Forward declarations
class QThread;
class IDLTMessageAnalyzerControllerConsumer;
class CDLTRegexAnalyzerWorker;
typedef int tWorkerId;

// CMTAnalyzer
class CMTAnalyzer: public IDLTMessageAnalyzerController
class CMTAnalyzer: public IDLTMessageAnalyzerController,
public CSettingsManagerClient
{
Q_OBJECT
public:
CMTAnalyzer();
CMTAnalyzer(const tSettingsManagerPtr& pSettingsManagerPtr);
~CMTAnalyzer() override;

//IDLTMessageAnalyzerController implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "../api/IDLTMessageAnalyzerController.hpp"
#include "qdlt.h"

#include "settings/CSettingsManager.hpp"
#include "components/settings/api/ISettingsManager.hpp"
#include "components/log/api/CLog.hpp"

#include "DMA_Plantuml.hpp"
Expand All @@ -30,16 +30,15 @@ tRequestId IDLTMessageAnalyzerControllerConsumer::requestAnalyze( const tFileWra
const int& numberOfMessages,
const QRegularExpression& regex,
const int& numberOfThreads,
bool isContinuous)
bool isContinuous,
bool bUMLFeatureActive )
{
tRequestId requestId = INVALID_REQUEST_ID;

if(false == mpController.expired())
{
tRegexScriptingMetadata regexMetadata;

bool bUMLFeatureActive = CSettingsManager::getInstance()->getUML_FeatureActive();

bool bParseResult = regexMetadata.parse(regex, bUMLFeatureActive);

if(false == bParseResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

#include "common/Definitions.hpp"

#include "components/settings/api/CSettingsManagerClient.hpp"

class CFiltersModel;
class CFilterItemDelegate;

class CFiltersView : public QTreeView
class CFiltersView : public QTreeView,
public CSettingsManagerClient
{
Q_OBJECT

Expand All @@ -25,6 +28,8 @@ class CFiltersView : public QTreeView
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
void keyPressEvent ( QKeyEvent * event ) override;

void handleSettingsManagerChange() override;

private:
void setModel(QAbstractItemModel *model) override;
void updateColumnsVisibility();
Expand All @@ -47,5 +52,5 @@ class CFiltersView : public QTreeView
bool mbResizeOnExpandCollapse;
bool mbSkipFirstUpdateWidth;
QLineEdit* mpRegexInputField;
CFilterItemDelegate* mpFilerItemDelegate;
CFilterItemDelegate* mpFilterItemDelegate;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
#include "common/Definitions.hpp"
#include "dma/component/IComponent.hpp"

#include "components/settings/api/CSettingsManagerClient.hpp"

class CFiltersView;
class IFiltersModel;

class CFiltersViewComponent : public DMA::IComponent
class CFiltersViewComponent : public DMA::IComponent, CSettingsManagerClient
{
public:

CFiltersViewComponent( CFiltersView* pFiltersView );
CFiltersViewComponent( CFiltersView* pFiltersView,
const tSettingsManagerPtr& pSettingsManagerPtr );

CFiltersView* getFiltersView() const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QStringListModel>

#include "components/log/api/CLog.hpp"
#include "settings/CSettingsManager.hpp"
#include "components/settings/api/ISettingsManager.hpp"
#include "common/Definitions.hpp"
#include "CFiltersModel.hpp"
#include "CFilterItemDelegate.hpp"
Expand Down Expand Up @@ -145,7 +145,7 @@ void CFilterItemDelegate::delayedComplete()

if(nullptr != mCompletionData.pPopUp)
{
mCompletionData.pPopUp->resize(CSettingsManager::getInstance()->getFiltersCompletion_CompletionPopUpWidth(),
mCompletionData.pPopUp->resize(getSettingsManager()->getFiltersCompletion_CompletionPopUpWidth(),
mCompletionData.pPopUp->height());
}
});
Expand Down Expand Up @@ -207,8 +207,8 @@ void CFilterItemDelegate::updateSuggestions(const QString& input)

pModel->setStringList(mpModel->getCompletionData(groupIndex,
normalizedInput,
CSettingsManager::getInstance()->getFiltersCompletion_MaxNumberOfSuggestions(),
CSettingsManager::getInstance()->getFiltersCompletion_MaxCharactersInSuggestion()));
getSettingsManager()->getFiltersCompletion_MaxNumberOfSuggestions(),
getSettingsManager()->getFiltersCompletion_MaxCharactersInSuggestion()));
}
else
{
Expand Down Expand Up @@ -524,6 +524,7 @@ void CFilterItemDelegate::setSpecificModel( CFiltersModel* pModel )
PUML_PACKAGE_BEGIN(DMA_FiltersView)
PUML_CLASS_BEGIN_CHECKED(CFilterItemDelegate)
PUML_INHERITANCE_CHECKED(QStyledItemDelegate, extends)
PUML_INHERITANCE_CHECKED(CSettingsManagerClient, extends)
PUML_AGGREGATION_DEPENDENCY_CHECKED(CFiltersModel, 1, 1, uses)
PUML_AGGREGATION_DEPENDENCY_CHECKED(QTreeView, 1, 1, parent view)
PUML_AGGREGATION_DEPENDENCY_CHECKED(QCompleter, 1, 1, uses)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@

#include <QStyledItemDelegate>

#include "components/settings/api/CSettingsManagerClient.hpp"

class QCompleter;
class CFiltersModel;
class CRegexLineEdit;

class CFilterItemDelegate : public QStyledItemDelegate
class CFilterItemDelegate : public QStyledItemDelegate,
public CSettingsManagerClient
{
public:
typedef QStyledItemDelegate tParent;
Expand Down
Loading