[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:
Adriaan de Groot 2020-08-11 22:08:34 +02:00
parent f0c4164515
commit ee834a7abb
3 changed files with 69 additions and 4 deletions

View File

@ -7,6 +7,8 @@
#include "Descriptor.h" #include "Descriptor.h"
#include "utils/Logger.h"
namespace Calamares namespace Calamares
{ {
namespace ModuleSystem namespace ModuleSystem
@ -44,5 +46,17 @@ interfaceNames()
return table; return table;
} }
Descriptor::Descriptor() {}
Descriptor
Descriptor::fromDescriptorData( const QVariantMap& moduleDesc )
{
Descriptor d;
cDebug() << moduleDesc;
return d;
}
} // namespace ModuleSystem } // namespace ModuleSystem
} // namespace Calamares } // namespace Calamares

View File

@ -61,17 +61,65 @@ const NamedEnumTable< Interface >& interfaceNames();
* to create a more strongly-typed Module Descriptor that carries * to create a more strongly-typed Module Descriptor that carries
* only the necessary information and no variants. * only the necessary information and no variants.
*/ */
// using Descriptor = QVariantMap;
class Descriptor class Descriptor
{ {
public: public:
///@brief an invalid, and empty, descriptor
Descriptor(); Descriptor();
/** @brief Fills a descriptor from the loaded (YAML) data.
*
*/
static Descriptor fromDescriptorData( const QVariantMap& moduleDesc );
bool isValid() const { return false; } bool isValid() const { return false; }
QString name() const { return QString(); } QString name() const { return QString(); }
Type type() const { return Type::Job; }
Interface interface() const { return Interface::QtPlugin; }
bool isEmergency() const { return false; } 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 } // namespace ModuleSystem

View File

@ -51,6 +51,9 @@ Module* moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor,
class DLLEXPORT Module class DLLEXPORT Module
{ {
public: public:
using Type = ModuleSystem::Type;
using Interface = ModuleSystem::Interface;
virtual ~Module(); virtual ~Module();
/** /**
@ -132,13 +135,13 @@ public:
* @brief type returns the Type of this module object. * @brief type returns the Type of this module object.
* @return the type enum value. * @return the type enum value.
*/ */
virtual ModuleSystem::Type type() const = 0; virtual Type type() const = 0;
/** /**
* @brief interface the Interface used by this module. * @brief interface the Interface used by this module.
* @return the interface enum value. * @return the interface enum value.
*/ */
virtual ModuleSystem::Interface interface() const = 0; virtual Interface interface() const = 0;
/** /**
* @brief Check the requirements of this module. * @brief Check the requirements of this module.