diff options
author | randomdan <randomdan@localhost> | 2013-03-16 17:35:08 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2013-03-16 17:35:08 +0000 |
commit | 7f8946eae1eae62c3140bed25bde9719c720bf35 (patch) | |
tree | 461a6ea8c73a8472a6dd6a3b70d8eba591e09253 /project2/common/variables/localparam.cpp | |
parent | Fix the case where the routing table wasn't cleared before reload (diff) | |
download | project2-7f8946eae1eae62c3140bed25bde9719c720bf35.tar.bz2 project2-7f8946eae1eae62c3140bed25bde9719c720bf35.tar.xz project2-7f8946eae1eae62c3140bed25bde9719c720bf35.zip |
Folderise variables and another test
Diffstat (limited to 'project2/common/variables/localparam.cpp')
-rw-r--r-- | project2/common/variables/localparam.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/project2/common/variables/localparam.cpp b/project2/common/variables/localparam.cpp new file mode 100644 index 0000000..1b789a7 --- /dev/null +++ b/project2/common/variables/localparam.cpp @@ -0,0 +1,31 @@ +#include <pch.hpp> +#include "../variables.h" +#include "../scriptLoader.h" +#include "../scriptStorage.h" +#include "../iHaveParameters.h" + +/// Variable implementation to access call parameters +class VariableLocalParam : public VariableImplDyn { + public: + VariableLocalParam(ScriptNodePtr e) : + VariableImplDyn(e), + name(e->value("name").as<Glib::ustring>()) + { + } + VariableType value() const + { + try { + return IHaveParameters::getScopedParameter(name); + } + catch (ParamNotFound) { + if (!defaultValue) { + throw; + } + return (*defaultValue)(); + } + } + private: + const Glib::ustring name; +}; +DECLARE_COMPONENT_LOADER("local", VariableLocalParam, VariableLoader); + |