KPackage 5.109.0
Public Member Functions | Static Public Member Functions | List of all members
KPackage::PackageLoader

This is an abstract base class which defines an interface to which the package loading logic can communicate with a parent application. More...

#include <KPackage/PackageLoader>

Public Member Functions

void addKnownPackageStructure (const QString &packageFormat, KPackage::PackageStructure *structure)
 Adds a new known package structure that can be used by the functions to load packages such as loadPackage, findPackages etc.
 
QList< KPluginMetaData > findPackages (const QString &packageFormat, const QString &packageRoot=QString(), std::function< bool(const KPluginMetaData &)> filter=std::function< bool(const KPluginMetaData &)>())
 List package of a certain type that match a certain filter function.
 
QList< KPluginMetaData > listPackages (const QString &packageFormat, const QString &packageRoot=QString())
 List all available packages of a certain type.
 
Package loadPackage (const QString &packageFormat, const QString &packagePath=QString())
 Load a Package plugin.
 
KPackage::PackageStructureloadPackageStructure (const QString &packageFormat)
 Loads a PackageStructure for a given format.
 

Static Public Member Functions

static PackageLoaderself ()
 Return the active plugin loader.
 

Detailed Description

This is an abstract base class which defines an interface to which the package loading logic can communicate with a parent application.

The plugin loader must be set before any plugins are loaded, otherwise (for safety reasons), the default PackageLoader implementation will be used. The reimplemented version should not do more than simply returning a loaded plugin. It should not init() it, and it should not hang on to it.

Author
Ryan Rix ry@n..nosp@m.rix..nosp@m.si

Member Function Documentation

◆ addKnownPackageStructure()

void KPackage::PackageLoader::addKnownPackageStructure ( const QString &  packageFormat,
KPackage::PackageStructure structure 
)

Adds a new known package structure that can be used by the functions to load packages such as loadPackage, findPackages etc.

Parameters
packageFormatthe package format, such as "KPackage/GenericQML"
structurethe package structure we want to be able to load packages from
Since
5.10

◆ findPackages()

QList< KPluginMetaData > KPackage::PackageLoader::findPackages ( const QString &  packageFormat,
const QString &  packageRoot = QString(),
std::function< bool(const KPluginMetaData &)>  filter = std::function< bool(const KPluginMetaData &)>() 
)

List package of a certain type that match a certain filter function.

Parameters
packageFormatthe format of the packages to list
packageRootthe root folder where the packages are installed. If not specified the default from the packageformat will be taken.
filtera filter function that will be called on each package: will return true for the matching ones
Returns
metadata for all the matching packages
Since
5.10

◆ listPackages()

QList< KPluginMetaData > KPackage::PackageLoader::listPackages ( const QString &  packageFormat,
const QString &  packageRoot = QString() 
)

List all available packages of a certain type.

Parameters
packageFormatthe format of the packages to list
packageRootthe root folder where the packages are installed. If not specified the default from the packageformat will be taken.
Returns
metadata for all the matching packages

◆ loadPackage()

Package KPackage::PackageLoader::loadPackage ( const QString &  packageFormat,
const QString &  packagePath = QString() 
)

Load a Package plugin.

Parameters
packageFormatthe format of the package to load
packagePaththe package name: the path of the package relative to the packageFormat root path. If not specified it will have to be set manually with Package::setPath() by the caller.
Returns
a Package object matching name, or an invalid package on failure

◆ loadPackageStructure()

KPackage::PackageStructure * KPackage::PackageLoader::loadPackageStructure ( const QString &  packageFormat)

Loads a PackageStructure for a given format.

The structure can then be used as paramenter for a Package instance constructor

Note
The returned pointer is managed by KPackage, and should never be deleted
Parameters
packageFormatthe package format, such as "KPackage/GenericQML"
Returns
the structure instance (ownership retained by KPackage)

◆ self()

static PackageLoader * KPackage::PackageLoader::self ( )
static

Return the active plugin loader.