[libcalamares] Define interface for Module descriptor
- add fields -- all const, all bogus -- to the descriptor, introduce a stub method to load the descriptor from YAML data (e.g. read from module.desc) - lighten the type-naming in Module a little, with usings
This commit is contained in:
parent
f0c4164515
commit
ee834a7abb
@ -7,6 +7,8 @@
|
||||
|
||||
#include "Descriptor.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
namespace ModuleSystem
|
||||
@ -44,5 +46,17 @@ interfaceNames()
|
||||
return table;
|
||||
}
|
||||
|
||||
Descriptor::Descriptor() {}
|
||||
|
||||
Descriptor
|
||||
Descriptor::fromDescriptorData( const QVariantMap& moduleDesc )
|
||||
{
|
||||
Descriptor d;
|
||||
|
||||
cDebug() << moduleDesc;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
} // namespace ModuleSystem
|
||||
} // namespace Calamares
|
||||
|
@ -61,17 +61,65 @@ const NamedEnumTable< Interface >& interfaceNames();
|
||||
* to create a more strongly-typed Module Descriptor that carries
|
||||
* only the necessary information and no variants.
|
||||
*/
|
||||
// using Descriptor = QVariantMap;
|
||||
|
||||
class Descriptor
|
||||
{
|
||||
public:
|
||||
///@brief an invalid, and empty, descriptor
|
||||
Descriptor();
|
||||
|
||||
/** @brief Fills a descriptor from the loaded (YAML) data.
|
||||
*
|
||||
*/
|
||||
static Descriptor fromDescriptorData( const QVariantMap& moduleDesc );
|
||||
|
||||
bool isValid() const { return false; }
|
||||
|
||||
QString name() const { return QString(); }
|
||||
Type type() const { return Type::Job; }
|
||||
Interface interface() const { return Interface::QtPlugin; }
|
||||
|
||||
bool isEmergency() const { return false; }
|
||||
bool hasConfig() const { return true; }
|
||||
|
||||
/// @brief The directory where the module.desc lives
|
||||
QString directory() const { return m_directory; }
|
||||
void setDirectory( const QString& d ) { m_directory = d; }
|
||||
|
||||
QStringList requiredModules() const { return QStringList {}; }
|
||||
|
||||
/** @section C++ Modules
|
||||
*
|
||||
* The C++ modules are the most general, and are loaded as
|
||||
* a shared library after which a suitable factory creates
|
||||
* objects from them.
|
||||
*/
|
||||
|
||||
/// @brief Short path to the shared-library; no extension.
|
||||
QString load() const { return QString(); }
|
||||
|
||||
/** @section Process Job modules
|
||||
*
|
||||
* Process Jobs are somewhat deprecated in favor of shellprocess
|
||||
* and contextualprocess jobs, since those handle multiple configuration
|
||||
* much more gracefully.
|
||||
*
|
||||
* Process Jobs execute one command.
|
||||
*/
|
||||
/// @brief The command to execute; passed to the shell
|
||||
QString command() const { return QString(); }
|
||||
/// @brief Timeout in seconds
|
||||
int timeout() const { return 30; }
|
||||
/// @brief Run command in chroot?
|
||||
bool chroot() const { return false; }
|
||||
|
||||
/** @section Python Job modules
|
||||
*
|
||||
* Python job modules have one specific script to load and run.
|
||||
*/
|
||||
QString script() const { return QString(); }
|
||||
|
||||
private:
|
||||
QString m_directory;
|
||||
};
|
||||
|
||||
} // namespace ModuleSystem
|
||||
|
@ -51,6 +51,9 @@ Module* moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor,
|
||||
class DLLEXPORT Module
|
||||
{
|
||||
public:
|
||||
using Type = ModuleSystem::Type;
|
||||
using Interface = ModuleSystem::Interface;
|
||||
|
||||
virtual ~Module();
|
||||
|
||||
/**
|
||||
@ -132,13 +135,13 @@ public:
|
||||
* @brief type returns the Type of this module object.
|
||||
* @return the type enum value.
|
||||
*/
|
||||
virtual ModuleSystem::Type type() const = 0;
|
||||
virtual Type type() const = 0;
|
||||
|
||||
/**
|
||||
* @brief interface the Interface used by this module.
|
||||
* @return the interface enum value.
|
||||
*/
|
||||
virtual ModuleSystem::Interface interface() const = 0;
|
||||
virtual Interface interface() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Check the requirements of this module.
|
||||
|
Loading…
Reference in New Issue
Block a user