This commit is contained in:
2024-10-31 17:17:16 +03:00
parent 222691d2e9
commit 3b1a318ee7
3 changed files with 56 additions and 41 deletions

View File

@@ -122,7 +122,7 @@ public:
AdcGenericDevice& addCommand(CommandT&& cmd)
{
_deviceCommands.insert(std::move(cmd));
_deviceCommands.insert({cmd.ident(), std::move(cmd)});
return *this;
}
@@ -131,9 +131,10 @@ public:
template <typename... CtorArgTs>
AdcGenericDevice& addCommand(CtorArgTs&&... ctor_args)
{
_deviceCommands.emplace(std::forward<CtorArgTs>(ctor_args)...);
// _deviceCommands.emplace(std::forward<CtorArgTs>(ctor_args)...);
return addCommand({std::forward<CtorArgTs>(ctor_args)...});
return *this;
// return *this;
}
AdcGenericDevice& delCommand(const cmd_ident_t& cmd_ident)
@@ -146,7 +147,7 @@ public:
AdcGenericDevice& addAttribute(AttributeT&& attr)
{
_deviceAttributes.insert(std::move(attr));
_deviceAttributes.insert({attr.ident(), std::move(attr)});
return *this;
}
@@ -154,9 +155,11 @@ public:
template <typename... CtorArgTs>
AdcGenericDevice& addAttribute(CtorArgTs&&... ctor_args)
{
_deviceAttributes.emplace(std::forward<CtorArgTs>(ctor_args)...);
// _deviceAttributes.emplace(std::forward<CtorArgTs>(ctor_args)...);
return *this;
return addAttribute({std::forward<CtorArgTs>(ctor_args)...});
// return *this;
}

View File

@@ -294,6 +294,15 @@ public:
_serializerFunc<SerializedT>.emplace(other, _serializerFunc<SerializedT>[this]);
_deserializerFunc<SerializedT>.emplace(other, _deserializerFunc<SerializedT>[this]);
// define copy-function for newly constructed object
other->_copyFunc = [other](AdcDeviceAttribute* o_next) {
_getterFunc<ValueT>.emplace(o_next, _getterFunc<ValueT>[other]);
_setterFunc<ValueT>.emplace(o_next, _setterFunc<ValueT>[other]);
_serializerFunc<SerializedT>.emplace(o_next, _serializerFunc<SerializedT>[other]);
_deserializerFunc<SerializedT>.emplace(o_next, _deserializerFunc<SerializedT>[other]);
};
};
@@ -304,6 +313,15 @@ public:
_serializerFunc<SerializedT>.emplace(other, std::move(_serializerFunc<SerializedT>[this]));
_deserializerFunc<SerializedT>.emplace(other, std::move(_deserializerFunc<SerializedT>[this]));
// define move-function for newly constructed object
other->_moveFunc = [other](AdcDeviceAttribute* o_next) {
_getterFunc<ValueT>.emplace(o_next, std::move(_getterFunc<ValueT>[other]));
_setterFunc<ValueT>.emplace(o_next, std::move(_setterFunc<ValueT>[other]));
_serializerFunc<SerializedT>.emplace(o_next, std::move(_serializerFunc<SerializedT>[other]));
_deserializerFunc<SerializedT>.emplace(o_next, std::move(_deserializerFunc<SerializedT>[other]));
};
};
}
@@ -398,30 +416,34 @@ public:
AdcDeviceAttribute(const AdcDeviceAttribute& other)
{
_clearFunc();
// _clearFunc();
other._copyFunc(this);
if (&other != this) {
other._copyFunc(this);
}
_clearFunc = other._clearFunc;
_copyFunc = other._copyFunc;
_moveFunc = other._moveFunc;
// _clearFunc = other._clearFunc;
// _copyFunc = other._copyFunc;
// _moveFunc = other._moveFunc;
}
AdcDeviceAttribute(AdcDeviceAttribute&& other)
{
_clearFunc();
if (&other != this) {
other._moveFunc(this);
}
other._moveFunc(this);
// other._clearFunc();
_clearFunc = std::move(other._clearFunc);
_copyFunc = std::move(other._copyFunc);
_moveFunc = std::move(other._moveFunc);
// _clearFunc = std::move(other._clearFunc);
// _copyFunc = std::move(other._copyFunc);
// _moveFunc = std::move(other._moveFunc);
}
virtual ~AdcDeviceAttribute()
{
_clearFunc();
// _clearFunc();
}
@@ -559,13 +581,13 @@ public:
AdcDeviceAttribute& operator=(const AdcDeviceAttribute& other)
{
if (&other != this) {
_clearFunc();
// _clearFunc();
other._copyFunc(this);
_clearFunc = other._clearFunc;
_copyFunc = other._copyFunc;
_moveFunc = other._moveFunc;
// _clearFunc = other._clearFunc;
// _copyFunc = other._copyFunc;
// _moveFunc = other._moveFunc;
}
return *this;
@@ -575,13 +597,13 @@ public:
AdcDeviceAttribute& operator=(AdcDeviceAttribute&& other)
{
if (&other != this) {
_clearFunc();
// _clearFunc();
other._moveFunc(this);
_clearFunc = std::move(other._clearFunc);
_copyFunc = std::move(other._copyFunc);
_moveFunc = std::move(other._moveFunc);
// _clearFunc = std::move(other._clearFunc);
// _copyFunc = std::move(other._copyFunc);
// _moveFunc = std::move(other._moveFunc);
}
return *this;