[libcalamares] Add a ModuleSystem::Descriptor
- this is currently just an alias for QVariantMap, which is the type already in use. - future plan is to tighten this up and have an actual Descriptor class that carries only the information actually needed for the module descriptor.
This commit is contained in:
parent
974d795390
commit
155db29ccf
36
src/libcalamares/modulesystem/Descriptor.h
Normal file
36
src/libcalamares/modulesystem/Descriptor.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2020, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MODULESYSTEM_DESCRIPTOR_H
|
||||
#define MODULESYSTEM_DESCRIPTOR_H
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
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
|
@ -24,6 +24,8 @@
|
||||
#include "Requirement.h"
|
||||
#include "UiDllMacro.h"
|
||||
|
||||
#include "modulesystem/Descriptor.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QVariant>
|
||||
|
||||
@ -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 );
|
||||
|
@ -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() ) );
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user