fourdst_plugin 0.0.1a
C++ Plugin Manager
Loading...
Searching...
No Matches
fourdst::plugin::bundle::PluginBundle Class Reference

Manages a bundle of plugins. More...

#include <bundle.h>

Public Member Functions

 PluginBundle (const std::string &filename)
 Construct a new PluginBundle from a filename with default load policy.
 
 PluginBundle (const char *filename)
 Construct a new PluginBundle from a C-style filename with default load policy.
 
 PluginBundle (const std::filesystem::path &filename)
 Construct a new PluginBundle from a filesystem path with default load policy.
 
 PluginBundle (const std::string &filename, PluginLoadPolicy policy)
 Construct a new PluginBundle with a custom load policy.
 
 PluginBundle (const char *filename, PluginLoadPolicy policy)
 Construct a new PluginBundle with a custom load policy from a C-string.
 
 PluginBundle (const std::filesystem::path &filename, PluginLoadPolicy policy)
 Construct a new PluginBundle with a custom load policy from a filesystem path.
 
 ~PluginBundle ()=default
 
 PluginBundle (const PluginBundle &)=delete
 
PluginBundleoperator= (const PluginBundle &)=delete
 
 PluginBundle (PluginBundle &&)=delete
 
PluginBundleoperator= (PluginBundle &&)=delete
 
bool has (const std::string &pluginName) const
 Check if a plugin exists in the bundle.
 
void load (const std::string &pluginName) const
 Load a plugin from the bundle.
 
std::vector< std::string > getPluginNames () const
 Get a list of all plugin names in the bundle.
 
std::string getBundleAuthor () const
 Get the bundle author.
 
std::string getBundleVersion () const
 Get the bundle version.
 
std::string getBundleComment () const
 Get the bundle comment.
 
std::string getBundledDatetime () const
 Get the bundle creation datetime.
 
bool isBundleTrusted () const
 Check if the bundle is trusted.
 
bool isBundleSigned () const
 Check if the bundle is signed.
 

Private Member Functions

void load (const std::vector< PluginPlatforms > &plugins) const
 Load plugins from the specified platforms.
 
bool verify_bundle ()
 Verify the bundle's signature.
 
void build_host_metadata ()
 Build metadata about the host system.
 
std::vector< PluginPlatformsparse_manifest (std::filesystem::path manifestPath)
 Parse the bundle manifest.
 

Static Private Member Functions

static void unpackBundle (const std::filesystem::path &archivePath, const utils::TemporaryDirectory &temporaryDirectory)
 Unpack a bundle to a temporary directory.
 
static std::string getHostABISignature ()
 Get the ABI signature of the host system.
 
static std::string getHostArchitecture ()
 Get the architecture of the host system.
 
static std::string getHostOperatingSystem ()
 Get the operating system name of the host.
 

Private Attributes

std::filesystem::path m_filepath
 Path to the bundle file.
 
manager::PluginManagerm_pluginManager
 Reference to the plugin manager.
 
std::unordered_map< std::string, bool > m_loadedMap
 Map of loaded plugins.
 
std::string m_hostABISignature
 ABI signature of the host system.
 
std::string m_hostArchitecture
 Architecture of the host system.
 
std::string m_hostOperatingSystem
 Operating system of the host.
 
std::string m_triplet
 System triplet (e.g., x86_64-linux-gnu)
 
YAML::Node m_bundleManifest
 Parsed bundle manifest.
 
std::string m_bundleName
 Name of the bundle.
 
std::string m_bundleVersion
 Version of the bundle.
 
std::string m_bundleAuthor
 Author of the bundle.
 
std::string m_bundleComment
 Comment/description of the bundle.
 
std::string m_bundledDatetime
 When the bundle was created.
 
std::optional< std::string > m_bundleAuthorKeyFingerprint
 Fingerprint of the signing key.
 
std::optional< std::vector< unsigned char > > m_bundleSignature
 Bundle signature.
 
std::vector< std::string > m_pluginNames
 List of plugin names in the bundle.
 
std::unordered_map< std::string, std::string > m_pluginAuthors
 Map of plugin names to authors.
 
std::unordered_map< std::string, std::string > m_pluginVersions
 Map of plugin names to versions.
 
bool m_signed
 Whether the bundle is signed.
 
bool m_trusted
 Whether the bundle is trusted.
 
PluginLoadPolicy m_loadPolicy
 Current load policy.
 
utils::TemporaryDirectory m_temporaryDirectory
 Temporary directory for bundle extraction.
 

Detailed Description

Manages a bundle of plugins.

This class handles loading, verifying, and managing a bundle of plugins. It supports signed and unsigned bundles, with optional signature verification.

Example: Loading and using a plugin bundle
try {
// Create a bundle with default load policy (ALL_PLUGINS_ABI_COMPATIBLE)
// Check if a specific plugin exists in the bundle
if (bundle.has("my_plugin")) {
// Load the plugin
bundle.load("my_plugin");
// Get bundle metadata
std::cout << "Bundle author: " << bundle.getBundleAuthor() << std::endl;
std::cout << "Bundle version: " << bundle.getBundleVersion() << std::endl;
}
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
Manages a bundle of plugins.
Definition bundle.h:84
Definition bundle.h:23

Constructor & Destructor Documentation

◆ PluginBundle() [1/8]

fourdst::plugin::bundle::PluginBundle::PluginBundle ( const std::string & filename)
explicit

Construct a new PluginBundle from a filename with default load policy.

Parameters
[in]filenamePath to the bundle file.

◆ PluginBundle() [2/8]

fourdst::plugin::bundle::PluginBundle::PluginBundle ( const char * filename)
explicit

Construct a new PluginBundle from a C-style filename with default load policy.

Parameters
[in]filenamePath to the bundle file as a C-string.

◆ PluginBundle() [3/8]

fourdst::plugin::bundle::PluginBundle::PluginBundle ( const std::filesystem::path & filename)
explicit

Construct a new PluginBundle from a filesystem path with default load policy.

Parameters
[in]filenamePath to the bundle file.

◆ PluginBundle() [4/8]

fourdst::plugin::bundle::PluginBundle::PluginBundle ( const std::string & filename,
PluginLoadPolicy policy )
explicit

Construct a new PluginBundle with a custom load policy.

Parameters
[in]filenamePath to the bundle file.
[in]policyLoad policy for ABI compatibility checks.

◆ PluginBundle() [5/8]

fourdst::plugin::bundle::PluginBundle::PluginBundle ( const char * filename,
PluginLoadPolicy policy )
explicit

Construct a new PluginBundle with a custom load policy from a C-string.

Parameters
[in]filenamePath to the bundle file as a C-string.
[in]policyLoad policy for ABI compatibility checks.

◆ PluginBundle() [6/8]

fourdst::plugin::bundle::PluginBundle::PluginBundle ( const std::filesystem::path & filename,
PluginLoadPolicy policy )
explicit

Construct a new PluginBundle with a custom load policy from a filesystem path.

Parameters
[in]filenamePath to the bundle file.
[in]policyLoad policy for ABI compatibility checks.

◆ ~PluginBundle()

fourdst::plugin::bundle::PluginBundle::~PluginBundle ( )
default

◆ PluginBundle() [7/8]

fourdst::plugin::bundle::PluginBundle::PluginBundle ( const PluginBundle & )
delete

◆ PluginBundle() [8/8]

fourdst::plugin::bundle::PluginBundle::PluginBundle ( PluginBundle && )
delete

Member Function Documentation

◆ build_host_metadata()

void fourdst::plugin::bundle::PluginBundle::build_host_metadata ( )
private

Build metadata about the host system.

◆ getBundleAuthor()

std::string fourdst::plugin::bundle::PluginBundle::getBundleAuthor ( ) const

Get the bundle author.

Returns
std::string Author of the bundle.

◆ getBundleComment()

std::string fourdst::plugin::bundle::PluginBundle::getBundleComment ( ) const

Get the bundle comment.

Returns
std::string Comment/description of the bundle.

◆ getBundledDatetime()

std::string fourdst::plugin::bundle::PluginBundle::getBundledDatetime ( ) const

Get the bundle creation datetime.

Returns
std::string Datetime string when the bundle was created.

◆ getBundleVersion()

std::string fourdst::plugin::bundle::PluginBundle::getBundleVersion ( ) const

Get the bundle version.

Returns
std::string Version string of the bundle.

◆ getHostABISignature()

std::string fourdst::plugin::bundle::PluginBundle::getHostABISignature ( )
staticnodiscardprivate

Get the ABI signature of the host system.

Returns
std::string ABI signature string.

◆ getHostArchitecture()

std::string fourdst::plugin::bundle::PluginBundle::getHostArchitecture ( )
staticnodiscardprivate

Get the architecture of the host system.

Returns
std::string Architecture string.

◆ getHostOperatingSystem()

std::string fourdst::plugin::bundle::PluginBundle::getHostOperatingSystem ( )
staticnodiscardprivate

Get the operating system name of the host.

Returns
std::string Operating system name.

◆ getPluginNames()

std::vector< std::string > fourdst::plugin::bundle::PluginBundle::getPluginNames ( ) const

Get a list of all plugin names in the bundle.

Returns
std::vector<std::string> List of plugin names.

◆ has()

bool fourdst::plugin::bundle::PluginBundle::has ( const std::string & pluginName) const

Check if a plugin exists in the bundle.

Parameters
[in]pluginNameName of the plugin to check.
Returns
true If the plugin exists in the bundle.
false If the plugin does not exist in the bundle.

◆ isBundleSigned()

bool fourdst::plugin::bundle::PluginBundle::isBundleSigned ( ) const

Check if the bundle is signed.

Returns
true If the bundle has a signature.
false If the bundle is not signed.

◆ isBundleTrusted()

bool fourdst::plugin::bundle::PluginBundle::isBundleTrusted ( ) const

Check if the bundle is trusted.

A bundle is considered trusted if its signature is valid and the signing key is in the system's trusted keys.

Returns
true If the bundle is trusted.
false If the bundle is not trusted.

◆ load() [1/2]

void fourdst::plugin::bundle::PluginBundle::load ( const std::string & pluginName) const

Load a plugin from the bundle.

Parameters
[in]pluginNameName of the plugin to load.
Exceptions
std::runtime_errorIf the plugin cannot be loaded.

◆ load() [2/2]

void fourdst::plugin::bundle::PluginBundle::load ( const std::vector< PluginPlatforms > & plugins) const
private

Load plugins from the specified platforms.

Parameters
[in]pluginsList of platform-specific plugin information.

◆ operator=() [1/2]

PluginBundle & fourdst::plugin::bundle::PluginBundle::operator= ( const PluginBundle & )
delete

◆ operator=() [2/2]

PluginBundle & fourdst::plugin::bundle::PluginBundle::operator= ( PluginBundle && )
delete

◆ parse_manifest()

std::vector< PluginPlatforms > fourdst::plugin::bundle::PluginBundle::parse_manifest ( std::filesystem::path manifestPath)
private

Parse the bundle manifest.

Parameters
[in]manifestPathPath to the manifest file.
Returns
std::vector<PluginPlatforms> List of platform-specific plugin information.
Exceptions
std::runtime_errorIf the manifest is invalid or missing required fields.

◆ unpackBundle()

void fourdst::plugin::bundle::PluginBundle::unpackBundle ( const std::filesystem::path & archivePath,
const utils::TemporaryDirectory & temporaryDirectory )
staticprivate

Unpack a bundle to a temporary directory.

Parameters
[in]archivePathPath to the bundle archive.
[in]temporaryDirectoryTemporary directory to extract to.
Exceptions
std::runtime_errorIf unpacking fails.

◆ verify_bundle()

bool fourdst::plugin::bundle::PluginBundle::verify_bundle ( )
private

Verify the bundle's signature.

Returns
true If the bundle's signature is valid.
false If the bundle's signature is invalid or missing.

Member Data Documentation

◆ m_bundleAuthor

std::string fourdst::plugin::bundle::PluginBundle::m_bundleAuthor
private

Author of the bundle.

◆ m_bundleAuthorKeyFingerprint

std::optional<std::string> fourdst::plugin::bundle::PluginBundle::m_bundleAuthorKeyFingerprint
private

Fingerprint of the signing key.

◆ m_bundleComment

std::string fourdst::plugin::bundle::PluginBundle::m_bundleComment
private

Comment/description of the bundle.

◆ m_bundledDatetime

std::string fourdst::plugin::bundle::PluginBundle::m_bundledDatetime
private

When the bundle was created.

◆ m_bundleManifest

YAML::Node fourdst::plugin::bundle::PluginBundle::m_bundleManifest
private

Parsed bundle manifest.

◆ m_bundleName

std::string fourdst::plugin::bundle::PluginBundle::m_bundleName
private

Name of the bundle.

◆ m_bundleSignature

std::optional<std::vector<unsigned char> > fourdst::plugin::bundle::PluginBundle::m_bundleSignature
private

Bundle signature.

◆ m_bundleVersion

std::string fourdst::plugin::bundle::PluginBundle::m_bundleVersion
private

Version of the bundle.

◆ m_filepath

std::filesystem::path fourdst::plugin::bundle::PluginBundle::m_filepath
private

Path to the bundle file.

◆ m_hostABISignature

std::string fourdst::plugin::bundle::PluginBundle::m_hostABISignature
private

ABI signature of the host system.

◆ m_hostArchitecture

std::string fourdst::plugin::bundle::PluginBundle::m_hostArchitecture
private

Architecture of the host system.

◆ m_hostOperatingSystem

std::string fourdst::plugin::bundle::PluginBundle::m_hostOperatingSystem
private

Operating system of the host.

◆ m_loadedMap

std::unordered_map<std::string, bool> fourdst::plugin::bundle::PluginBundle::m_loadedMap
private

Map of loaded plugins.

◆ m_loadPolicy

PluginLoadPolicy fourdst::plugin::bundle::PluginBundle::m_loadPolicy
private

Current load policy.

◆ m_pluginAuthors

std::unordered_map<std::string, std::string> fourdst::plugin::bundle::PluginBundle::m_pluginAuthors
private

Map of plugin names to authors.

◆ m_pluginManager

manager::PluginManager& fourdst::plugin::bundle::PluginBundle::m_pluginManager
private

Reference to the plugin manager.

◆ m_pluginNames

std::vector<std::string> fourdst::plugin::bundle::PluginBundle::m_pluginNames
private

List of plugin names in the bundle.

◆ m_pluginVersions

std::unordered_map<std::string, std::string> fourdst::plugin::bundle::PluginBundle::m_pluginVersions
private

Map of plugin names to versions.

◆ m_signed

bool fourdst::plugin::bundle::PluginBundle::m_signed
private

Whether the bundle is signed.

◆ m_temporaryDirectory

utils::TemporaryDirectory fourdst::plugin::bundle::PluginBundle::m_temporaryDirectory
private

Temporary directory for bundle extraction.

◆ m_triplet

std::string fourdst::plugin::bundle::PluginBundle::m_triplet
private

System triplet (e.g., x86_64-linux-gnu)

◆ m_trusted

bool fourdst::plugin::bundle::PluginBundle::m_trusted
private

Whether the bundle is trusted.


The documentation for this class was generated from the following files: