diff --git a/src/libcalamares/modulesystem/Descriptor.h b/src/libcalamares/modulesystem/Descriptor.h new file mode 100644 index 000000000..77d69caf3 --- /dev/null +++ b/src/libcalamares/modulesystem/Descriptor.h @@ -0,0 +1,36 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef MODULESYSTEM_DESCRIPTOR_H +#define MODULESYSTEM_DESCRIPTOR_H + +#include + +namespace Calamares +{ +namespace ModuleSystem +{ +/* While this isn't a useful *using* right now, the intention is + * to create a more strongly-typed Module Descriptor that carries + * only the necessary information and no variants. + */ +using Descriptor = QVariantMap; +} // namespace ModuleSystem +} // namespace Calamares + +#endif diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index e4101b767..d6e6407d1 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -24,6 +24,8 @@ #include "Requirement.h" #include "UiDllMacro.h" +#include "modulesystem/Descriptor.h" + #include #include @@ -73,7 +75,7 @@ public: * @param moduleDirectory the path to the directory with this module's files. * @return a pointer to an object of a subtype of Module. */ - static Module* fromDescriptor( const QVariantMap& moduleDescriptor, + static Module* fromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, const QString& instanceId, const QString& configFileName, const QString& moduleDirectory ); diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index 028e80168..7e3b45c7f 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -183,7 +183,7 @@ findCustomInstance( const Settings::InstanceDescriptionList& customInstances, co static QString getConfigFileName( const Settings::InstanceDescriptionList& customInstances, const ModuleSystem::InstanceKey& instanceKey, - const ModuleManager::ModuleDescriptor& descriptor ) + const ModuleSystem::Descriptor& descriptor ) { if ( instanceKey.isCustom() ) { @@ -246,8 +246,8 @@ ModuleManager::loadModules() } } - ModuleDescriptor descriptor - = m_availableDescriptorsByModuleName.value( instanceKey.module(), ModuleDescriptor() ); + ModuleSystem::Descriptor descriptor + = m_availableDescriptorsByModuleName.value( instanceKey.module(), ModuleSystem::Descriptor() ); if ( descriptor.isEmpty() ) { cError() << "Module" << instanceKey.toString() << "not found in module search paths." @@ -285,7 +285,7 @@ ModuleManager::loadModules() } else { - thisModule = Module::fromDescriptor( m_availableDescriptorsByModuleName.value( instanceKey.module() ), + thisModule = Module::fromDescriptor( descriptor, instanceKey.id(), configFileName, m_moduleDirectoriesByModuleName.value( instanceKey.module() ) ); diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index 37fa6b60c..be485c01d 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -20,6 +20,7 @@ #ifndef MODULELOADER_H #define MODULELOADER_H +#include "modulesystem/Descriptor.h" #include "modulesystem/InstanceKey.h" #include "Requirement.h" @@ -45,8 +46,6 @@ class ModuleManager : public QObject { Q_OBJECT public: - using ModuleDescriptor = QVariantMap; /// TODO: Should be strongly-typed instead - explicit ModuleManager( const QStringList& paths, QObject* parent = nullptr ); virtual ~ModuleManager() override; @@ -71,7 +70,7 @@ public: * @param name the name of the module for which to return the module descriptor. * @return the module descriptor, as a variant map already parsed from YAML. */ - ModuleDescriptor moduleDescriptor( const QString& name ); + ModuleSystem::Descriptor moduleDescriptor( const QString& name ); /** * @brief moduleInstance returns a Module object for a given instance key. @@ -128,7 +127,7 @@ private: */ bool checkModuleDependencies( const Module& ); - QMap< QString, ModuleDescriptor > m_availableDescriptorsByModuleName; + QMap< QString, ModuleSystem::Descriptor > m_availableDescriptorsByModuleName; QMap< QString, QString > m_moduleDirectoriesByModuleName; QMap< ModuleSystem::InstanceKey, Module* > m_loadedModulesByInstanceKey; const QStringList m_paths;