Profiles and families, the C++ side

Profiles covers the PL/PS protocol events from the client’s point of view. This page covers the same mechanism from inside the module — the actual Basemodule methods those two events end up calling, and the handful of related accessors.

PL/PS are just loadProfile()/saveProfile() on this

Basemodule::onExternalEventBase() — the first hook in the event chain (see The event chain) — handles PL/PS by calling these two methods directly on itself:

// libs/basemodule.cpp, onExternalEventBase()
if (this->loadProfile(o["profile"].toString()))
    ...
if (this->saveProfile(o["profile"].toString()))
    ...
bool saveProfile(const QString &pProfileName);
bool loadProfile(const QString &pProfileName);

No core module calls either one on itself today — the protocol path above already covers the normal case (the user clicking load/save in the frontend). A module would only call them directly for something the protocol doesn’t offer, e.g. silently auto-saving the current state under a fixed name on some internal timer, or loading a named preset in response to its own logic rather than a user click.

The controller, on the other hand, calls loadProfile() on other modules from outside — once at startup for the shared global datastore, and again whenever a module is (re)loaded with a specific profile already chosen:

// src/controller.cpp
mGlobalDatastore->loadProfile("default");
...
mod->loadProfile(profile);

getCurrentProfile(): which profile is this, right now

Plain accessor for the name last loaded or saved — used wherever a module needs to stamp its own output with the profile that produced it, rather than hardcoding "default" or leaving it out:

// src/modules/sequencer/sequencer.cpp, writeLiveSequenceStats()
QString profile = getCurrentProfile();
...
// written into sequence-report-<timestamp>.txt's header, and into
// sequence-history.json's per-run record

getCurrentProfileChanged() is the companion boolean — true once anything has changed since the profile was last loaded/saved, false right after either. No core module reads it on itself; it exists for the dump sent to the frontend, so the UI can show an unsaved-changes indicator:

// libs/utils/modulejsondumper.cpp
profile["name"]    = mod->getCurrentProfile();
profile["changed"] = mod->getCurrentProfileChanged();

getFamilies()/hasFamily(): the read side of declareFamily()

Ready-made families shows declareFamily()/defineMeAsXxx() — how a module advertises a capability. getFamilies() (the full QStringList) and hasFamily(const QString &family) (a yes/no check) are how that gets read back. In the core, only the controller reads it — to maintain each family-<name> list of values as modules load and unload:

// src/controller.cpp
for (const QString &family : mod->getFamilies())
    ...

No core module calls getFamilies()/hasFamily() on itself or on another module today, but both are public — a module that behaves differently depending on its own declared capabilities (rather than on a fixed isFocuser()/isGuider()/… flag, already mentioned in passing in Ready-made families) would reach for hasFamily("guiding") rather than re-deriving it from scratch.