diff options
author | Anton Babushkin <anton.babushkin@me.com> | 2014-03-30 00:25:26 +0400 |
---|---|---|
committer | Anton Babushkin <anton.babushkin@me.com> | 2014-03-30 00:25:26 +0400 |
commit | d2553bfd2930eb02664d564559fa361b80c63f61 (patch) | |
tree | 21cda568519c33a261edaaa9c370cc9ba9c7f466 /src/modules/controllib/block/BlockParam.hpp | |
parent | 0789189c0588ebebd24a523f9639411be89c6a9b (diff) | |
parent | 9b1de5004c673ebe8bdf68f1b518565cccd6b05b (diff) | |
download | px4-firmware-d2553bfd2930eb02664d564559fa361b80c63f61.tar.gz px4-firmware-d2553bfd2930eb02664d564559fa361b80c63f61.tar.bz2 px4-firmware-d2553bfd2930eb02664d564559fa361b80c63f61.zip |
Merge branch 'master' into offboard2
Diffstat (limited to 'src/modules/controllib/block/BlockParam.hpp')
-rw-r--r-- | src/modules/controllib/block/BlockParam.hpp | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/src/modules/controllib/block/BlockParam.hpp b/src/modules/controllib/block/BlockParam.hpp index 36bc8c24b..a64d0139e 100644 --- a/src/modules/controllib/block/BlockParam.hpp +++ b/src/modules/controllib/block/BlockParam.hpp @@ -42,7 +42,7 @@ #include <systemlib/param/param.h> #include "Block.hpp" -#include "List.hpp" +#include <containers/List.hpp> namespace control { @@ -70,38 +70,21 @@ protected: * Parameters that are tied to blocks for updating and nameing. */ -class __EXPORT BlockParamFloat : public BlockParamBase +template <class T> +class BlockParam : public BlockParamBase { public: - BlockParamFloat(Block *block, const char *name, bool parent_prefix=true) : - BlockParamBase(block, name, parent_prefix), - _val() { - update(); - } - float get() { return _val; } - void set(float val) { _val = val; } - void update() { - if (_handle != PARAM_INVALID) param_get(_handle, &_val); - } + BlockParam(Block *block, const char *name, + bool parent_prefix=true); + T get(); + void set(T val); + void update(); + virtual ~BlockParam(); protected: - float _val; + T _val; }; -class __EXPORT BlockParamInt : public BlockParamBase -{ -public: - BlockParamInt(Block *block, const char *name, bool parent_prefix=true) : - BlockParamBase(block, name, parent_prefix), - _val() { - update(); - } - int get() { return _val; } - void set(int val) { _val = val; } - void update() { - if (_handle != PARAM_INVALID) param_get(_handle, &_val); - } -protected: - int _val; -}; +typedef BlockParam<float> BlockParamFloat; +typedef BlockParam<int> BlockParamInt; } // namespace control |