Skip to content
Snippets Groups Projects
Commit 88b2c6c7 authored by Roman's avatar Roman
Browse files

blockparam: added support for external parameter copy

parent 0510d2cb
No related branches found
No related tags found
No related merge requests found
......@@ -82,9 +82,10 @@ BlockParamBase::BlockParamBase(Block *parent, const char *name, bool parent_pref
template <class T>
BlockParam<T>::BlockParam(Block *block, const char *name,
bool parent_prefix) :
bool parent_prefix, T *extern_address) :
BlockParamBase(block, name, parent_prefix),
_val()
_val(),
_extern_address(extern_address)
{
update();
}
......@@ -93,12 +94,25 @@ template <class T>
T BlockParam<T>::get() { return _val; }
template <class T>
void BlockParam<T>::set(T val) { _val = val; }
void BlockParam<T>::set(T val)
{
_val = val;
if (_extern_address != NULL) {
*_extern_address = val;
}
}
template <class T>
void BlockParam<T>::update()
{
if (_handle != PARAM_INVALID) { param_get(_handle, &_val); }
if (_handle != PARAM_INVALID) {
param_get(_handle, &_val);
if (_extern_address != NULL) {
*_extern_address = _val;
}
}
}
template <class T>
......
......@@ -77,7 +77,7 @@ class BlockParam : public BlockParamBase
{
public:
BlockParam(Block *block, const char *name,
bool parent_prefix = true);
bool parent_prefix = true, T *extern_address = NULL);
T get();
void commit();
void set(T val);
......@@ -85,6 +85,7 @@ public:
virtual ~BlockParam();
protected:
T _val;
T *_extern_address;
};
typedef BlockParam<float> BlockParamFloat;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment