Try BCValue as smartptr

This commit is contained in:
2026-01-02 01:43:49 +01:00
parent 43f72d1be6
commit fc5ab611bd
11 changed files with 60 additions and 69 deletions

View File

@@ -176,11 +176,11 @@ void BCXmlLoader::loadXmlBikeDeviceData(BCDevice::ID deviceID)
};
// nur gültige Werte sind vorhanden und können gespeichert werden
std::optional<BCValue> newValue = makeDataValue( deviceID, params );
std::optional<BCValuePtr> newValue = makeDataValue( deviceID, params );
if(newValue)
{
// wir merken uns gleich den index in der Werteliste
(*newValue).indexRow = currentValues.size();
(*newValue)->indexRow = currentValues.size();
currentValues.push_back( *newValue );
}
@@ -195,7 +195,7 @@ void BCXmlLoader::loadXmlBikeDeviceData(BCDevice::ID deviceID)
}
std::optional<BCValue> BCXmlLoader::makeDataValue( BCDevice::ID deviceID, const BCDataParams& params )
std::optional<BCValuePtr> BCXmlLoader::makeDataValue( BCDevice::ID deviceID, const BCDataParams& params )
{
/*
@@ -221,7 +221,7 @@ std::optional<BCValue> BCXmlLoader::makeDataValue( BCDevice::ID deviceID, const
*/
std::optional<BCValue> newValue;
bool ok;
//std::optional<quint64> IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
@@ -233,7 +233,7 @@ std::optional<BCValue> BCXmlLoader::makeDataValue( BCDevice::ID deviceID, const
auto valueType = BCValueType::fetchValueType(params.UnitType);
if( valueType.has_value() )
{
newValue = BCValue( *valueType, deviceID, static_cast<BC::ID>(IDVal) );
BCValuePtr newValue = std::make_shared<BCValue>( *valueType, deviceID, static_cast<BC::ID>(IDVal) );
/*
setIfExists( params.Factor, newValue.factor );
@@ -242,10 +242,12 @@ std::optional<BCValue> BCXmlLoader::makeDataValue( BCDevice::ID deviceID, const
*/
newValue->label = params.Label;
qDebug() << " --- created: " << params.Label;
return std::optional<BCValuePtr>( newValue );
}
}
return newValue;
return std::nullopt;
}
// --- NEU: Speichern mit QXmlStreamWriter ---