25 template <
typename STORAGE = adtf::util::cMemoryBlock,
typename INTERFACE = IHashValueMap>
40 static uint8_t GetVersion()
46 ui8StorageVersion(GetVersion())
49 uint8_t ui8StorageVersion;
75 m_pCurrent->nByteSize =
static_cast<uint8_t
>(szSize);
76 adtf::util::cMemoryBlock::MemCopy(&m_pCurrent->eStorage[0], pData, szSize);
81 const void*
Get()
const override
83 return &m_pCurrent->eStorage[0];
87 return static_cast<size_t>(m_pCurrent->nByteSize);
110 return oRawValue.Set(&m_pCurrent->eStorage[0],
static_cast<size_t>(m_pCurrent->nByteSize));
115 return (m_pCurrent->eType);
142 oToCopy.
ToRaw(*
this);
151 oToCopy.
ToRaw(*
this);
161 hash_value_map(
size_t szPreallocateMemorySize,
bool bZeroMemory) : m_oStorage()
163 m_oStorage.Alloc(szPreallocateMemorySize);
164 if (szPreallocateMemorySize > 0 && bZeroMemory)
166 adtf::util::cMemoryBlock::MemZero(m_oStorage.GetPtr(), szPreallocateMemorySize);
173 value_type* pValue = GetValueT(oKey,
nullptr);
174 return (pValue !=
nullptr);
188 for (
size_t szIdx = 0; szIdx < szCurrentSize; ++szIdx)
207 value_type* pValue = GetValueT(oHashKey,
nullptr);
211 return oValue.
Set(oValueGetter);
222 m_oStorage.Alloc(szNewSize);
225 adtf::util::cMemoryBlock::MemZero(m_oStorage.GetPtr(), szNewSize);
233 value_type* pKeyValue = GetValueT(oHashKey, &pFirstInvalidValue);
234 if (pKeyValue !=
nullptr)
241 if (pFirstInvalidValue)
243 pKeyValue = pFirstInvalidValue;
251 pKeyValue = &pNewFirstValue[szNewLastPos];
255 pKeyValue->oKey = oHashKey;
256 pKeyValue->eType = oValue.
GetType();
257 pKeyValue->ui8StorageVersion = value_type::GetVersion();
265 return m_oStorage.GetSize() /
sizeof(
value_type);
276 return m_oStorage.Set(oRawValue.
Get(), oRawValue.
GetSize());
281 return oRawValue.Set(m_oStorage.GetPtr(), m_oStorage.GetSize());
285 return value_type::GetVersion();
289 return m_oStorage.GetPtr();
297 *ppFirstInvalid =
nullptr;
299 value_type* pKeyValue =
reinterpret_cast<value_type*
>(m_oStorage.GetPtr());
301 for (
size_t szIdx = 0; szIdx < szCurrentSize; ++szIdx)
305 if (pKeyValue[szIdx].oKey == oKey)
307 return &pKeyValue[szIdx];
312 if (ppFirstInvalid && *ppFirstInvalid ==
nullptr)
314 *ppFirstInvalid = &pKeyValue[szIdx];
332 const adtf::util::cVariant oDefault);
344 const adtf::util::cVariant oValue);
Copyright © Audi Electronics Venture GmbH.
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
A common result class usable as return value throughout.
The hashed vlaue table store interface to set and retrieve values via a hash key.
virtual uint8_t GetRawMemoryLayoutVersion() const =0
Return the Version of the memory layout used to store the values.
adtf::util::cStringUtil::tHashKey32 tHashKey
Type for the HashKey of the Value.
virtual tResult SetValue(const tHashKey &oHashKey, const IHashValueMapValue &oValue)=0
Sets or resets the value for the hash key oHashKey as copy of oValue.
Value Interface for the IHashedValueMap.
virtual tType GetType() const =0
Retrieves the type of the Value.
tType
Enumeration of variant types for the HashValueMap Values.
@ HVT_Invalid
Invalid type.
virtual tResult Set(const IHashValueMapValue &oValue)=0
Sets the the Value.
The IRawMemory interface provides methods for getting and setting memory values through abstract inte...
virtual size_t GetSize() const =0
Returns the size in bytes of the memory.
virtual const void * Get() const =0
Returns the raw memory pointer.
virtual tResult ToRaw(IRawMemory &&oRawValue) const =0
Implement to create a fast value copy in memory.
virtual tResult FromRaw(const IRawMemory &oRawValue)=0
Implement to create a fast value copy in memory.
tResult Set(const IHashValueMapValue &oValue) override
Sets the the Value.
tResult FromRaw(const IRawMemory &oRawValue)
Implement to create a fast value copy in memory.
tResult ToRaw(IRawMemory &&oRawValue) const
Implement to create a fast value copy in memory.
tType GetType() const override
Retrieves the type of the Value.
tResult Set(const void *pData, size_t szSize) override
Sets the Raw pointer memory.
size_t GetSize() const override
Returns the size in bytes of the memory.
const void * Get() const override
Returns the raw memory pointer.
implementation of the IHashValueMap.
tResult FromRaw(const IRawMemory &oRawValue) override
Implement to create a fast value copy in memory.
virtual ~hash_value_map()
DTOR.
hash_value_map(size_t szPreAllocatedKeyValueSize)
CTOR.
hash_value_map & operator=(hash_value_map &&oToCopy)=delete
no move operator
tResult GetValue(const IHashValueMap::tHashKey &oHashKey, IHashValueMapValue &oValue) const override
Retrieves the value for the hash key oHashKey to oValue if exists.
tResult ToRaw(IRawMemory &&oRawValue) const override
Implement to create a fast value copy in memory.
hash_value_map & operator=(const hash_value_map &oToCopy)
Copy operator.
bool IsEmpty() const override
Tests if value map is empty.
uint8_t GetRawMemoryLayoutVersion() const
Return the Version of the memory layout used to store the values.
hash_value_map(hash_value_map &&oToCopy)=delete
no move DTOR
tResult SetValue(const IHashValueMap::tHashKey &oHashKey, const IHashValueMapValue &oValue) override
Sets or resets the value for the hash key oHashKey as copy of oValue.
size_t GetCapacity() const
Retrieve the current count of value can be stored.
tResult Get(IHashValueMap &oHashMap) const override
Copy operation to the oHashMap.
bool Exists(const IHashValueMap::tHashKey &oKey) const override
Tests is a value for the oKey exists.
size_t m_szPreAllocatedKeyValueSize
Value count for preallocation of the memory.
void Reset() override
Clears the value map.
hash_value_map(const hash_value_map &oToCopy)
Copy CTOR.
Copyright © Audi Electronics Venture GmbH.
IHashValueMap::tHashKey create_hash_value_key(const char *strToHash)
Generation of unambigious hash key for a string.
tResult set_hash_value(IHashValueMap &oMap, const IHashValueMap::tHashKey &oHash, const adtf::util::cVariant oValue)
Sets a variant value for the hash key oHash into the hashed value map oMap.
adtf::util::cVariant get_hash_value(const IHashValueMap &oMap, const IHashValueMap::tHashKey &oHash, const adtf::util::cVariant oDefault)
Retrieves a variant value for the hash key oHash out of the hashed value map oMap.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.