##// END OF EJS Templates
Updates IDataProvider::requestDataLoading() method's signature...
Updates IDataProvider::requestDataLoading() method's signature The parameters needed for data retrieval are passed to a DataProviderParameters object. For now, it concerns only the list of datetimes to process, but the object will be completed with extra data which may be necessary for certain providers

File last commit:

r408:49f712bf7e59
r408:49f712bf7e59
Show More
VariableController.cpp
216 lines | 7.5 KiB | text/x-c | CppLexer
/ core / src / Variable / VariableController.cpp
The mock plugin can now create data with view operation
r235 #include <Variable/Variable.h>
Create a variable notify the variable cache parameter
r225 #include <Variable/VariableCacheController.h>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 #include <Variable/VariableController.h>
Alexandre Leroux
Adds Variable model in the Variable controller
r113 #include <Variable/VariableModel.h>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 #include <Data/DataProviderParameters.h>
#include <Data/IDataProvider.h>
#include <Data/IDataSeries.h>
Time widget is now used with the variable createion request
r193 #include <Time/TimeController.h>
Alexandre Leroux
Updates VariableController::createVariable() method...
r166
#include <QDateTime>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 #include <QMutex>
#include <QThread>
Alexandre Leroux
Transits tokens in provider requests
r376 #include <QUuid>
Temporal parameters of the selected variables can be updated using the...
r304 #include <QtCore/QItemSelectionModel>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111
Create a variable notify the variable cache parameter
r225 #include <unordered_map>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
struct VariableController::VariableControllerPrivate {
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r159 explicit VariableControllerPrivate(VariableController *parent)
Create a variable notify the variable cache parameter
r225 : m_WorkingMutex{},
m_VariableModel{new VariableModel{parent}},
Temporal parameters of the selected variables can be updated using the...
r304 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
Create a variable notify the variable cache parameter
r225 m_VariableCacheController{std::make_unique<VariableCacheController>()}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 {
}
QMutex m_WorkingMutex;
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r159 /// Variable model. The VariableController has the ownership
VariableModel *m_VariableModel;
Temporal parameters of the selected variables can be updated using the...
r304 QItemSelectionModel *m_VariableSelectionModel;
Time widget is now used with the variable createion request
r193
Create a variable notify the variable cache parameter
r225
Correction MR
r195 TimeController *m_TimeController{nullptr};
Create a variable notify the variable cache parameter
r225 std::unique_ptr<VariableCacheController> m_VariableCacheController;
The mock plugin can now create data with view operation
r235
std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> >
m_VariableToProviderMap;
Implement the network controller to permit the execution of a request...
r389 std::unordered_map<std::shared_ptr<Variable>, QUuid> m_VariableToIdentifier;
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 };
VariableController::VariableController(QObject *parent)
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r159 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 {
Correction clang format
r365 qCDebug(LOG_VariableController()) << tr("VariableController construction")
<< QThread::currentThread();
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 }
VariableController::~VariableController()
{
Correction clang format
r365 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
<< QThread::currentThread();
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 this->waitForFinish();
}
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 VariableModel *VariableController::variableModel() noexcept
Alexandre Leroux
Adds Variable model in the Variable controller
r113 {
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 return impl->m_VariableModel;
Alexandre Leroux
Adds Variable model in the Variable controller
r113 }
Temporal parameters of the selected variables can be updated using the...
r304 QItemSelectionModel *VariableController::variableSelectionModel() noexcept
{
return impl->m_VariableSelectionModel;
}
Time widget is now used with the variable createion request
r193 void VariableController::setTimeController(TimeController *timeController) noexcept
{
impl->m_TimeController = timeController;
}
Alexandre Leroux
Variable deletion (1)...
r329 void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noexcept
{
if (!variable) {
qCCritical(LOG_VariableController()) << "Can't delete variable: variable is null";
return;
}
Alexandre Leroux
Variable deletion (6)...
r335 // Spreads in SciQlop that the variable will be deleted, so that potential receivers can
// make some treatments before the deletion
emit variableAboutToBeDeleted(variable);
Alexandre Leroux
Variable deletion (2)...
r330
// Deletes provider
auto nbProvidersDeleted = impl->m_VariableToProviderMap.erase(variable);
qCDebug(LOG_VariableController())
<< tr("Number of providers deleted for variable %1: %2")
.arg(variable->name(), QString::number(nbProvidersDeleted));
Alexandre Leroux
Variable deletion (1)...
r329
Alexandre Leroux
Variable deletion (2)...
r331 // Clears cache
impl->m_VariableCacheController->clear(variable);
Alexandre Leroux
Variable deletion (3)...
r332 // Deletes from model
impl->m_VariableModel->deleteVariable(variable);
}
Alexandre Leroux
Variable deletion (1)...
r329
void VariableController::deleteVariables(
const QVector<std::shared_ptr<Variable> > &variables) noexcept
{
for (auto variable : qAsConst(variables)) {
deleteVariable(variable);
}
}
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 void VariableController::createVariable(const QString &name,
std::shared_ptr<IDataProvider> provider) noexcept
Alexandre Leroux
Affects model to the Variable Widget
r152 {
Time widget is now used with the variable createion request
r193
if (!impl->m_TimeController) {
qCCritical(LOG_VariableController())
<< tr("Impossible to create variable: The time controller is null");
return;
}
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 /// @todo : for the moment :
/// - the provider is only used to retrieve data from the variable for its initialization, but
/// it will be retained later
/// - default data are generated for the variable, without taking into account the timerange set
/// in sciqlop
Create a variable notify the variable cache parameter
r225 auto dateTime = impl->m_TimeController->dateTime();
It's now possible to create the variable and ask data to be retreived...
r319 if (auto newVariable = impl->m_VariableModel->createVariable(name, dateTime)) {
Implement the network controller to permit the execution of a request...
r389 auto identifier = QUuid::createUuid();
Create a variable notify the variable cache parameter
r225
The mock plugin can now create data with view operation
r235 // store the provider
impl->m_VariableToProviderMap[newVariable] = provider;
Implement the network controller to permit the execution of a request...
r389 impl->m_VariableToIdentifier[newVariable] = identifier;
The cache is now updated only if date requested has been successfully...
r318
Alexandre Leroux
Uses weak pointers in lambda functions to prevent a shared_ptr from ever being deleted (because a reference would always be kept in the lambda)
r361 auto addDateTimeAcquired = [ this, varW = std::weak_ptr<Variable>{newVariable} ](
Implement the network controller to permit the execution of a request...
r389 QUuid identifier, auto dataSeriesAcquired, auto dateTimeToPutInCache)
Alexandre Leroux
Uses weak pointers in lambda functions to prevent a shared_ptr from ever being deleted (because a reference would always be kept in the lambda)
r361 {
if (auto variable = varW.lock()) {
Implement the network controller to permit the execution of a request...
r389 auto varIdentifier = impl->m_VariableToIdentifier.at(variable);
if (varIdentifier == identifier) {
Alexandre Leroux
Transits tokens in provider requests
r376 impl->m_VariableCacheController->addDateTime(variable, dateTimeToPutInCache);
variable->setDataSeries(dataSeriesAcquired);
}
Alexandre Leroux
Uses weak pointers in lambda functions to prevent a shared_ptr from ever being deleted (because a reference would always be kept in the lambda)
r361 }
};
The cache is now updated only if date requested has been successfully...
r318
connect(provider.get(), &IDataProvider::dataProvided, addDateTimeAcquired);
It's now possible to create the variable and ask data to be retreived...
r319 this->onRequestDataLoading(newVariable, dateTime);
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 }
Alexandre Leroux
Affects model to the Variable Widget
r152 }
Temporal parameters of the selected variables can be updated using the...
r304 void VariableController::onDateTimeOnSelection(const SqpDateTime &dateTime)
{
Correction clang format
r365 qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection"
<< QThread::currentThread()->objectName();
Temporal parameters of the selected variables can be updated using the...
r304 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
for (const auto &selectedRow : qAsConst(selectedRows)) {
if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
selectedVariable->setDateTime(dateTime);
The data of the variable is now requested with the new provided...
r305 this->onRequestDataLoading(selectedVariable, dateTime);
Temporal parameters of the selected variables can be updated using the...
r304 }
}
}
Add implementation of progress bar on variable inspector connected to...
r401 void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, double progress)
{
auto findReply = [identifier](const auto &entry) { return identifier == entry.second; };
auto end = impl->m_VariableToIdentifier.cend();
auto it = std::find_if(impl->m_VariableToIdentifier.cbegin(), end, findReply);
if (it != end) {
impl->m_VariableModel->setDataProgress(it->first, progress);
}
}
The mock plugin can now create data with view operation
r235
Fix the cosinus bug....
r298 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
const SqpDateTime &dateTime)
The mock plugin can now create data with view operation
r235 {
Correction clang format
r365 qCDebug(LOG_VariableController()) << "VariableController::onRequestDataLoading"
<< QThread::currentThread()->objectName();
The mock plugin can now create data with view operation
r235 // we want to load data of the variable for the dateTime.
// First we check if the cache contains some of them.
// For the other, we ask the provider to give them.
if (variable) {
auto dateTimeListNotInCache
= impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime);
Fix the cosinus bug....
r298 if (!dateTimeListNotInCache.empty()) {
// Ask the provider for each data on the dateTimeListNotInCache
Implement the network controller to permit the execution of a request...
r389 auto identifier = impl->m_VariableToIdentifier.at(variable);
Fix the cosinus bug....
r298 impl->m_VariableToProviderMap.at(variable)->requestDataLoading(
Alexandre Leroux
Updates IDataProvider::requestDataLoading() method's signature...
r408 identifier, DataProviderParameters{std::move(dateTimeListNotInCache)});
Fix the cosinus bug....
r298 }
else {
emit variable->updated();
}
The mock plugin can now create data with view operation
r235 }
else {
qCCritical(LOG_VariableController()) << tr("Impossible to load data of a variable null");
}
}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 void VariableController::initialize()
{
qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
impl->m_WorkingMutex.lock();
qCDebug(LOG_VariableController()) << tr("VariableController init END");
}
void VariableController::finalize()
{
impl->m_WorkingMutex.unlock();
}
void VariableController::waitForFinish()
{
QMutexLocker locker{&impl->m_WorkingMutex};
}