forked from Archive/PX4-Autopilot
Fixed block param template.
This commit is contained in:
parent
239a0cc155
commit
2c32cdf16b
|
@ -76,4 +76,29 @@ BlockParamBase::BlockParamBase(Block *parent, const char *name, bool parent_pref
|
||||||
printf("error finding param: %s\n", fullname);
|
printf("error finding param: %s\n", fullname);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
BlockParam<T>::BlockParam(Block *block, const char *name,
|
||||||
|
bool parent_prefix) :
|
||||||
|
BlockParamBase(block, name, parent_prefix),
|
||||||
|
_val() {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
T BlockParam<T>::get() { return _val; }
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void BlockParam<T>::set(T val) { _val = val; }
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void BlockParam<T>::update() {
|
||||||
|
if (_handle != PARAM_INVALID) param_get(_handle, &_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
BlockParam<T>::~BlockParam() {};
|
||||||
|
|
||||||
|
template class __EXPORT BlockParam<float>;
|
||||||
|
template class __EXPORT BlockParam<int>;
|
||||||
|
|
||||||
} // namespace control
|
} // namespace control
|
||||||
|
|
|
@ -70,38 +70,21 @@ protected:
|
||||||
* Parameters that are tied to blocks for updating and nameing.
|
* Parameters that are tied to blocks for updating and nameing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class __EXPORT BlockParamFloat : public BlockParamBase
|
template <class T>
|
||||||
|
class BlockParam : public BlockParamBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BlockParamFloat(Block *block, const char *name, bool parent_prefix=true) :
|
BlockParam(Block *block, const char *name,
|
||||||
BlockParamBase(block, name, parent_prefix),
|
bool parent_prefix=true);
|
||||||
_val() {
|
T get();
|
||||||
update();
|
void set(T val);
|
||||||
}
|
void update();
|
||||||
float get() { return _val; }
|
virtual ~BlockParam();
|
||||||
void set(float val) { _val = val; }
|
|
||||||
void update() {
|
|
||||||
if (_handle != PARAM_INVALID) param_get(_handle, &_val);
|
|
||||||
}
|
|
||||||
protected:
|
protected:
|
||||||
float _val;
|
T _val;
|
||||||
};
|
};
|
||||||
|
|
||||||
class __EXPORT BlockParamInt : public BlockParamBase
|
typedef BlockParam<float> BlockParamFloat;
|
||||||
{
|
typedef BlockParam<int> BlockParamInt;
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace control
|
} // namespace control
|
||||||
|
|
Loading…
Reference in New Issue