Expose Control Expression variables to mappings UI

-add a way to reset their value (from the mappings UI)
-fix "memory leak" where they would never be cleaned,
one would be created every time you wrote a character after a "$"
-fix ability to create variables with an empty string by just writing "$" (+added error for it)
-Add $ operator to the UI operators list, to expose this functionality even more
This commit is contained in:
Filoppi
2021-03-12 00:01:18 +02:00
parent 975f8e2a25
commit 93e3e691f9
6 changed files with 112 additions and 12 deletions

View File

@ -143,7 +143,7 @@ public:
class ControlEnvironment
{
public:
using VariableContainer = std::map<std::string, ControlState>;
using VariableContainer = std::map<std::string, std::shared_ptr<ControlState>>;
ControlEnvironment(const Core::DeviceContainer& container_, const Core::DeviceQualifier& default_,
VariableContainer& vars)
@ -154,7 +154,10 @@ public:
std::shared_ptr<Core::Device> FindDevice(ControlQualifier qualifier) const;
Core::Device::Input* FindInput(ControlQualifier qualifier) const;
Core::Device::Output* FindOutput(ControlQualifier qualifier) const;
ControlState* GetVariablePtr(const std::string& name);
// Returns an existing variable by the specified name if already existing. Creates it otherwise.
std::shared_ptr<ControlState> GetVariablePtr(const std::string& name);
void CleanUnusedVariables();
private:
VariableContainer& m_variables;