##// END OF EJS Templates
Merge pull request 148 from SCIQLOP-Initialisation develop...
Merge pull request 148 from SCIQLOP-Initialisation develop Develop

File last commit:

r92:afb77b3143a6
r121:c6da4aa56140 merge
Show More
DataSourceController.cpp
78 lines | 2.6 KiB | text/x-c | CppLexer
/ core / src / DataSource / DataSourceController.cpp
Alexandre Leroux
Minor fixes...
r32 #include <DataSource/DataSourceController.h>
Alexandre Leroux
Implements the method for setting data source structure
r37 #include <DataSource/DataSourceItem.h>
Initialisation de l'application multithread avec le spimpl....
r21
#include <QMutex>
#include <QThread>
Ajout du logger compatible Linux à la compilation.
r25 #include <QDir>
#include <QStandardPaths>
Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController")
Initialisation de l'application multithread avec le spimpl....
r21
class DataSourceController::DataSourceControllerPrivate {
public:
QMutex m_WorkingMutex;
Alexandre Leroux
Implements the method for setting data source structure
r37 /// Data sources registered
Alexandre Leroux
Enables the registration of a data source in the controller
r36 QHash<QUuid, QString> m_DataSources;
Alexandre Leroux
Implements the method for setting data source structure
r37 /// Data sources structures
std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems;
Initialisation de l'application multithread avec le spimpl....
r21 };
DataSourceController::DataSourceController(QObject *parent)
: impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
{
Remove coverage from windows build...
r76 qCDebug(LOG_DataSourceController()) << tr("DataSourceController construction")
<< QThread::currentThread();
Initialisation de l'application multithread avec le spimpl....
r21 }
DataSourceController::~DataSourceController()
{
Remove coverage from windows build...
r76 qCDebug(LOG_DataSourceController()) << tr("DataSourceController destruction")
<< QThread::currentThread();
Initialisation de l'application multithread avec le spimpl....
r21 this->waitForFinish();
}
Alexandre Leroux
Enables the registration of a data source in the controller
r36 QUuid DataSourceController::registerDataSource(const QString &dataSourceName) noexcept
{
auto dataSourceUid = QUuid::createUuid();
impl->m_DataSources.insert(dataSourceUid, dataSourceName);
return dataSourceUid;
}
Alexandre Leroux
Implements the method for setting data source structure
r37 void DataSourceController::setDataSourceItem(
const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept
{
if (impl->m_DataSources.contains(dataSourceUid)) {
impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem)));
// Retrieves the data source item to emit the signal with it
auto it = impl->m_DataSourceItems.find(dataSourceUid);
if (it != impl->m_DataSourceItems.end()) {
Alexandre Leroux
Change signal/slot signature for data source
r92 emit dataSourceItemSet(it->second.get());
Alexandre Leroux
Implements the method for setting data source structure
r37 }
}
else {
qCWarning(LOG_DataSourceController()) << tr("Can't set data source item for uid %1 : no "
"data source has been registered with the uid")
.arg(dataSourceUid.toString());
}
}
Initialisation de l'application multithread avec le spimpl....
r21 void DataSourceController::initialize()
{
Remove coverage from windows build...
r76 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init")
<< QThread::currentThread();
Initialisation de l'application multithread avec le spimpl....
r21 impl->m_WorkingMutex.lock();
Alexandre Leroux
Minor fixes...
r32 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END");
Initialisation de l'application multithread avec le spimpl....
r21 }
void DataSourceController::finalize()
{
impl->m_WorkingMutex.unlock();
}
void DataSourceController::waitForFinish()
{
Alexandre Leroux
Minor fixes...
r32 QMutexLocker locker{&impl->m_WorkingMutex};
Initialisation de l'application multithread avec le spimpl....
r21 }