From 0c4195e63bf9fc4d37f79d053d73ed8d1f4b89fc Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 28 Nov 2021 06:00:04 -0500 Subject: [PATCH] Add doc comments saying the Module::config*() can only be called from the Module subclass constructor. --- include/engine/Module.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/engine/Module.hpp b/include/engine/Module.hpp index 49d16914..77c2dff4 100644 --- a/include/engine/Module.hpp +++ b/include/engine/Module.hpp @@ -106,11 +106,14 @@ struct Module { } virtual ~Module(); - /** Configures the number of Params, Outputs, Inputs, and Lights. */ + /** Configures the number of Params, Outputs, Inputs, and Lights. + Should only be called from a Module subclass's constructor. + */ void config(int numParams, int numInputs, int numOutputs, int numLights = 0); /** Helper for creating a ParamQuantity and setting its properties. See ParamQuantity for documentation of arguments. + Should only be called from a Module subclass's constructor. */ template TParamQuantity* configParam(int paramId, float minValue, float maxValue, float defaultValue, std::string name = "", std::string unit = "", float displayBase = 0.f, float displayMultiplier = 1.f, float displayOffset = 0.f) { @@ -138,6 +141,7 @@ struct Module { /** Helper for creating a SwitchQuantity and setting its label strings. See ParamQuantity and SwitchQuantity for documentation of arguments. + Should only be called from a Module subclass's constructor. */ template TSwitchQuantity* configSwitch(int paramId, float minValue, float maxValue, float defaultValue, std::string name = "", std::vector labels = {}) { @@ -146,6 +150,9 @@ struct Module { return sq; } + /** Helper for creating a SwitchQuantity with no label. + Should only be called from a Module subclass's constructor. + */ template TSwitchQuantity* configButton(int paramId, std::string name = "") { TSwitchQuantity* sq = configParam(paramId, 0.f, 1.f, 0.f, name); @@ -155,6 +162,7 @@ struct Module { /** Helper for creating a PortInfo for an input port and setting its properties. See PortInfo for documentation of arguments. + Should only be called from a Module subclass's constructor. */ template TPortInfo* configInput(int portId, std::string name = "") { @@ -173,6 +181,7 @@ struct Module { /** Helper for creating a PortInfo for an output port and setting its properties. See PortInfo for documentation of arguments. + Should only be called from a Module subclass's constructor. */ template TPortInfo* configOutput(int portId, std::string name = "") { @@ -192,6 +201,7 @@ struct Module { /** Helper for creating a LightInfo and setting its properties. For multi-colored lights, use the first lightId. See LightInfo for documentation of arguments. + Should only be called from a Module subclass's constructor. */ template TLightInfo* configLight(int lightId, std::string name = "") { @@ -208,6 +218,7 @@ struct Module { } /** Adds a direct route from an input to an output when the module is bypassed. + Should only be called from a Module subclass's constructor. */ void configBypass(int inputId, int outputId) { assert(inputId < (int) inputs.size());