Extracted one logic block
To increase readability
This commit is contained in:
parent
5cb591a063
commit
424c82ce16
@ -14,33 +14,13 @@ PoolRawAccess::PoolRawAccess(uint32_t set_id, uint8_t setArrayEntry,
|
||||
}
|
||||
}
|
||||
|
||||
PoolRawAccess::~PoolRawAccess() {
|
||||
|
||||
}
|
||||
PoolRawAccess::~PoolRawAccess() {}
|
||||
|
||||
ReturnValue_t PoolRawAccess::read() {
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
PoolEntryIF* read_out = ::dataPool.getRawData(dataPoolId);
|
||||
if (read_out != NULL) {
|
||||
valid = read_out->getValid();
|
||||
if (read_out->getSize() > arrayEntry) {
|
||||
arraySize = read_out->getSize();
|
||||
typeSize = read_out->getByteSize() / read_out->getSize();
|
||||
type = read_out->getType();
|
||||
if (typeSize <= sizeof(value)) {
|
||||
uint16_t arrayPosition = arrayEntry * typeSize;
|
||||
sizeTillEnd = read_out->getByteSize() - arrayPosition;
|
||||
uint8_t* ptr =
|
||||
&((uint8_t*) read_out->getRawData())[arrayPosition];
|
||||
memcpy(value, ptr, typeSize);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
} else {
|
||||
result = READ_TYPE_TOO_LARGE;
|
||||
}
|
||||
} else {
|
||||
//debug << "PoolRawAccess: Size: " << (int)read_out->getSize() << std::endl;
|
||||
result = READ_INDEX_TOO_LARGE;
|
||||
}
|
||||
result = handleReadOut(read_out);
|
||||
} else {
|
||||
result = READ_ENTRY_NON_EXISTENT;
|
||||
}
|
||||
@ -62,6 +42,29 @@ ReturnValue_t PoolRawAccess::read() {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PoolRawAccess::handleReadOut(PoolEntryIF* read_out) {
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
valid = read_out->getValid();
|
||||
if (read_out->getSize() > arrayEntry) {
|
||||
arraySize = read_out->getSize();
|
||||
typeSize = read_out->getByteSize() / read_out->getSize();
|
||||
type = read_out->getType();
|
||||
if (typeSize <= sizeof(value)) {
|
||||
uint16_t arrayPosition = arrayEntry * typeSize;
|
||||
sizeTillEnd = read_out->getByteSize() - arrayPosition;
|
||||
uint8_t* ptr = &((uint8_t*) read_out->getRawData())[arrayPosition];
|
||||
memcpy(value, ptr, typeSize);
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
result = READ_TYPE_TOO_LARGE;
|
||||
}
|
||||
} else {
|
||||
//debug << "PoolRawAccess: Size: " << (int)read_out->getSize() << std::endl;
|
||||
result = READ_INDEX_TOO_LARGE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PoolRawAccess::commit() {
|
||||
PoolEntryIF* write_back = ::dataPool.getRawData(dataPoolId);
|
||||
if ((write_back != NULL) && (readWriteMode != VAR_READ)) {
|
||||
|
@ -156,6 +156,7 @@ protected:
|
||||
*/
|
||||
ReturnValue_t commit();
|
||||
|
||||
ReturnValue_t handleReadOut(PoolEntryIF* read_out);
|
||||
private:
|
||||
/**
|
||||
* \brief To access the correct data pool entry on read and commit calls, the data pool id
|
||||
|
Loading…
Reference in New Issue
Block a user