From eac422f85368521b1a78b020dac5a359a430389a Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 13 Jan 2018 00:35:27 +0100 Subject: [PATCH] Ref T199, bootstrap (aka setup) cache explicitly initialized * initMultiSimulatorCache * initCaches detecting bootstrap and init via high level functions --- .../components/copyconfigurationcomponent.cpp | 42 +++++++++++-------- .../components/copyconfigurationcomponent.h | 17 +++++--- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/blackgui/components/copyconfigurationcomponent.cpp b/src/blackgui/components/copyconfigurationcomponent.cpp index 8b7b45c20..47eeec9aa 100644 --- a/src/blackgui/components/copyconfigurationcomponent.cpp +++ b/src/blackgui/components/copyconfigurationcomponent.cpp @@ -10,6 +10,7 @@ #include "ui_copyconfigurationcomponent.h" #include "copyconfigurationcomponent.h" #include "configurationwizard.h" +#include "blackcore/data/globalsetup.h" #include "blackgui/guiapplication.h" #include "blackconfig/buildconfig.h" #include "blackmisc/directoryutils.h" @@ -27,6 +28,8 @@ using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation::Data; using namespace BlackConfig; using namespace BlackGui; +using namespace BlackCore; +using namespace BlackCore::Data; namespace BlackGui { @@ -91,7 +94,7 @@ namespace BlackGui if (!destination.exists()) { return 0; } // init model caches if applicable (.rev file entries) - this->initModelCaches(files); + this->initCaches(files); int c = 0; QStringList copied; @@ -341,35 +344,25 @@ namespace BlackGui return files; } - void CCopyConfigurationComponent::initModelCaches(const QStringList &files) + void CCopyConfigurationComponent::initCaches(const QStringList &files) { if (files.isEmpty()) { return; } if (!ui->rb_Cache->isChecked()) { return; } for (const QString &file : files) { - CStatusMessage msg; - IMultiSimulatorModelCaches *cache = nullptr; if (file.contains("modelset", Qt::CaseInsensitive)) { - cache = &m_modelSetCaches; + this->initMultiSimulatorCache(&m_modelSetCaches, file); } else if (file.contains("modelcache", Qt::CaseInsensitive)) { - cache = &m_modelCaches; + this->initMultiSimulatorCache(&m_modelCaches, file); } - else + else if (file.contains(CDirectoryUtils::bootstrapFileName())) { - continue; - } - - const CSimulatorInfo info = cache->getSimulatorForFilename(file); - if (info.isNoSimulator()) continue; - if (cache->isSaved(info)) continue; // already a file and hence in .rev - const QFileInfo fi(file); - msg = cache->setCacheTimestamp(fi.lastModified(), info); // create cache file and timestamp in .rev - if (msg.isFailure()) - { - CLogMessage(this).preformatted(msg); + CData setup { this }; //!< data cache setup + const CGlobalSetup s = CGlobalSetup::fromJsonFile(file, true); + setup.set(s); } } @@ -377,6 +370,19 @@ namespace BlackGui CGuiApplication::processEventsFor(2500); } + void CCopyConfigurationComponent::initMultiSimulatorCache(IMultiSimulatorModelCaches *cache, const QString &fileName) + { + const CSimulatorInfo info = cache->getSimulatorForFilename(fileName); + if (info.isNoSimulator()) return; + if (cache->isSaved(info)) return; // already a file and hence in .rev + const QFileInfo fi(fileName); + const CStatusMessage msg = cache->setCacheTimestamp(fi.lastModified(), info); // create cache file and timestamp in .rev + if (msg.isFailure()) + { + CLogMessage(this).preformatted(msg); + } + } + void CCopyConfigurationComponent::initOtherSwiftVersions() { ui->cb_OtherVersions->clear(); diff --git a/src/blackgui/components/copyconfigurationcomponent.h b/src/blackgui/components/copyconfigurationcomponent.h index 670714a51..f8910c4d0 100644 --- a/src/blackgui/components/copyconfigurationcomponent.h +++ b/src/blackgui/components/copyconfigurationcomponent.h @@ -99,8 +99,11 @@ namespace BlackGui //! Get the selected files QStringList getSelectedFiles() const; - //! Init model caches if required (create .rev entries with high level functions) - void initModelCaches(const QStringList &files); + //! Init caches if required (create .rev entries with high level functions) + void initCaches(const QStringList &files); + + //! Init a multi simulator cache (modelset/models) + void initMultiSimulatorCache(BlackMisc::Simulation::Data::IMultiSimulatorModelCaches *cache, const QString &fileName); //! Init the other swift versions void initOtherSwiftVersions(); @@ -116,9 +119,13 @@ namespace BlackGui bool m_nameFilterDisables = false; //!< name filter disables or hides bool m_withBootstrapFile = false; - // caches will be initialized (default files on disk) - BlackMisc::Simulation::Data::CModelCaches m_modelCaches{false, this}; - BlackMisc::Simulation::Data::CModelSetCaches m_modelSetCaches{false, this}; + // caches will be explicitly initialized in initCaches + BlackMisc::Simulation::Data::CModelCaches m_modelCaches{ false, this }; + BlackMisc::Simulation::Data::CModelSetCaches m_modelSetCaches{ false, this }; + + // caches will be initialized so they can be overriden + // those caches do not harm if they exists default initialized + //! \fixme this is a workaround, as it creates files on disk even if those are not copied. It was much nicer if the cache would init themself if the file appears BlackMisc::CData m_modelSetCurrentSimulator { this }; BlackMisc::CData m_modelsCurrentSimulator { this }; BlackMisc::CData m_launcherSetup { this };