Examples

The Shape host

Shape : public Plugin<Shape> — an abstract base with setSize / printOn, one CREATECATALOG(Shape) line in a .cpp, and the free operator<<. This is everything a host application exposes so add-ons can extend it.

The Shape host
Read walkthrough
PLUGINCREATECATALOGBASE-CLASS
Three plugins

Square uses REGISTER(Square, Shape) — default construction only. Circle and Ellipse carry a Config struct and use REGISTER_WITH_CONFIG, so Shape::create("Circle", Circle::Config{42}) type-checks the config through std::any.

Three plugins
Read walkthrough
REGISTERREGISTER_WITH_CONFIGCONFIG
The driver

testShape sets the lib filename prefix, loads ./libCircle.so, ./libEllipse.so, ./libSquare.so, creates one of each with and without a config, then drops into an interactive loop that loads a DSO on demand by name.

The driver
Read walkthrough
DSOLOADERPREFIXCATALOG
Signing an add-on

Generate a key with dso-keygen, sign libCircle.so with dso-sign, trust the public key, then replace DSOLoader::load with loadVerified(..., TrustLevel::TRUSTED) so the unsigned libSquare.so is refused.

Signing an add-on
Read walkthrough
DSO-KEYGENDSO-SIGNLOADVERIFIED