ADTF  3.18.2
hash_value_map< STORAGE, INTERFACE >

implementation of the IHashValueMap. More...

Inheritance diagram for hash_value_map< STORAGE, INTERFACE >:
[legend]

Classes

class  cHashedValueGetter
 
class  cHashedValueSetter
 
struct  tHashValueStorageType
 

Public Types

typedef tHashValueStorageType value_type
 
- Public Types inherited from IHashValueMap
using tHashKey = adtf::util::cStringUtil::tHashKey32
 Type for the HashKey of the Value.
 

Public Member Functions

 hash_value_map ()
 CTOR.
 
 hash_value_map (size_t szPreAllocatedKeyValueSize)
 CTOR. More...
 
virtual ~hash_value_map ()
 DTOR.
 
 hash_value_map (const hash_value_map &oToCopy)
 Copy CTOR. More...
 
hash_value_mapoperator= (const hash_value_map &oToCopy)
 Copy operator. More...
 
 hash_value_map (hash_value_map &&oToCopy)=delete
 no move DTOR
 
hash_value_mapoperator= (hash_value_map &&oToCopy)=delete
 no move operator
 
bool Exists (const IHashValueMap::tHashKey &oKey) const override
 Tests is a value for the oKey exists. More...
 
tResult Get (IHashValueMap &oHashMap) const override
 Copy operation to the oHashMap. More...
 
tResult GetValue (const IHashValueMap::tHashKey &oHashKey, IHashValueMapValue &oValue) const override
 Retrieves the value for the hash key oHashKey to oValue if exists. More...
 
void Reset () override
 Clears the value map.
 
tResult SetValue (const IHashValueMap::tHashKey &oHashKey, const IHashValueMapValue &oValue) override
 Sets or resets the value for the hash key oHashKey as copy of oValue. More...
 
size_t GetCapacity () const
 Retrieve the current count of value can be stored. More...
 
bool IsEmpty () const override
 Tests if value map is empty. More...
 
tResult FromRaw (const IRawMemory &oRawValue) override
 Implement to create a fast value copy in memory. More...
 
tResult ToRaw (IRawMemory &&oRawValue) const override
 Implement to create a fast value copy in memory. More...
 
uint8_t GetRawMemoryLayoutVersion () const
 Return the Version of the memory layout used to store the values. More...
 
void * GetPtr () const
 

Protected Member Functions

 hash_value_map (size_t szPreallocateMemorySize, bool bZeroMemory)
 
- Protected Member Functions inherited from IHashValueMap
virtual ~IHashValueMap ()=default
 protected DTOR
 
- Protected Member Functions inherited from IRawValue
virtual ~IRawValue ()=default
 protected DTOR
 

Protected Attributes

size_t m_szPreAllocatedKeyValueSize = 0
 Value count for preallocation of the memory.
 

Private Member Functions

value_typeGetValueT (const IHashValueMap::tHashKey &oKey, value_type **ppFirstInvalid) const
 

Private Attributes

STORAGE m_oStorage
 

Detailed Description

template<typename STORAGE = adtf::util::cMemoryBlock, typename INTERFACE = IHashValueMap>
class adtf::base::ant::hash_value_map< STORAGE, INTERFACE >

implementation of the IHashValueMap.

Template Parameters
STORAGEMemory storage type
INTERFACEinterface derived from

Definition at line 26 of file hashedvaluemap.h.

Constructor & Destructor Documentation

◆ hash_value_map() [1/2]

hash_value_map ( size_t  szPreAllocatedKeyValueSize)
inline

CTOR.

Parameters
[in]szPreAllocatedKeyValueSizecount of values to preallocate memory

Definition at line 126 of file hashedvaluemap.h.

References hash_value_map< STORAGE, INTERFACE >::m_szPreAllocatedKeyValueSize, and hash_value_map< STORAGE, INTERFACE >::Reset().

◆ hash_value_map() [2/2]

hash_value_map ( const hash_value_map< STORAGE, INTERFACE > &  oToCopy)
inline

Copy CTOR.

Parameters
[in]oToCopymap to copy from

Definition at line 139 of file hashedvaluemap.h.

References hash_value_map< STORAGE, INTERFACE >::m_szPreAllocatedKeyValueSize, and hash_value_map< STORAGE, INTERFACE >::ToRaw().

Member Function Documentation

◆ Exists()

bool Exists ( const IHashValueMap::tHashKey oKey) const
inlineoverridevirtual

Tests is a value for the oKey exists.

Parameters
[in]oKeyhash key to check.
Return values
truevalue exists
falsevalue does not exists

Implements IHashValueMap.

Definition at line 171 of file hashedvaluemap.h.

◆ FromRaw()

tResult FromRaw ( const IRawMemory oRawValue)
inlineoverridevirtual

Implement to create a fast value copy in memory.

Usually this method is called if types are equal implementation is within the same binary!

Parameters
oRawValue[in] Memory representation of the value
Return values
ERR_NOERRORSuccessfully copied.
ERR_MEMORYYou have to return ERR_MEMORY if size of oRawValue does not fit !!
any_errorDepends on the implementation.

Implements IRawValue.

Definition at line 274 of file hashedvaluemap.h.

References IRawMemory::Get(), and IRawMemory::GetSize().

◆ Get()

tResult Get ( IHashValueMap oHashMap) const
inlineoverridevirtual

Copy operation to the oHashMap.

Parameters
[in]oHashMaphash map to copy values to another hash map
Remarks
if the implementation is equal you should use IRawValue to copy memory other use SetValue!
Returns
returns the standard error code
Return values
ERR_NOERRORcopy operation succeeded
ERR_MEMORYIRawValue::FromRaw or SetValue returned error

Implements IHashValueMap.

Definition at line 177 of file hashedvaluemap.h.

References IRawValue::FromRaw(), hash_value_map< STORAGE, INTERFACE >::GetCapacity(), hash_value_map< STORAGE, INTERFACE >::GetRawMemoryLayoutVersion(), IHashValueMap::GetRawMemoryLayoutVersion(), IHashValueMapValue::HVT_Invalid, RETURN_IF_FAILED, RETURN_NOERROR, and IHashValueMap::SetValue().

◆ GetCapacity()

size_t GetCapacity ( ) const
inline

Retrieve the current count of value can be stored.

Returns
The capacity

Definition at line 263 of file hashedvaluemap.h.

Referenced by hash_value_map< STORAGE, INTERFACE >::Get(), hash_value_map< STORAGE, INTERFACE >::IsEmpty(), and hash_value_map< STORAGE, INTERFACE >::SetValue().

◆ GetRawMemoryLayoutVersion()

uint8_t GetRawMemoryLayoutVersion ( ) const
inlinevirtual

Return the Version of the memory layout used to store the values.

Returns
The version number of the Memory layout.

Implements IHashValueMap.

Definition at line 283 of file hashedvaluemap.h.

Referenced by hash_value_map< STORAGE, INTERFACE >::Get().

◆ GetValue()

tResult GetValue ( const IHashValueMap::tHashKey oHashKey,
IHashValueMapValue oValue 
) const
inlineoverridevirtual

Retrieves the value for the hash key oHashKey to oValue if exists.

Parameters
[in]oHashKeyhashkey
[out]oValuevalue
Returns
returns the standard error code
Return values
ERR_NOERRORsuccedded
ERR_INVALID_TYPEType not supported
anydepends on implementation of IHashedValue.
See also
get_hashed_value

Implements IHashValueMap.

Definition at line 205 of file hashedvaluemap.h.

References RETURN_ERROR, and IHashValueMapValue::Set().

◆ IsEmpty()

bool IsEmpty ( ) const
inlineoverridevirtual

Tests if value map is empty.

Return values
falsevalues exist
trueno values exist, map is empty.

Implements IHashValueMap.

Definition at line 268 of file hashedvaluemap.h.

References hash_value_map< STORAGE, INTERFACE >::GetCapacity(), and IHashValueMapValue::HVT_Invalid.

◆ operator=()

hash_value_map& operator= ( const hash_value_map< STORAGE, INTERFACE > &  oToCopy)
inline

Copy operator.

Parameters
[in]oToCopymap to copy from
Returns
this instance

Definition at line 148 of file hashedvaluemap.h.

References hash_value_map< STORAGE, INTERFACE >::m_szPreAllocatedKeyValueSize, and hash_value_map< STORAGE, INTERFACE >::ToRaw().

◆ SetValue()

tResult SetValue ( const IHashValueMap::tHashKey oHashKey,
const IHashValueMapValue oValue 
)
inlineoverridevirtual

Sets or resets the value for the hash key oHashKey as copy of oValue.

Parameters
[in]oHashKeyhashkey
[in]oValuevalue to set
Returns
returns the standard error code
Return values
ERR_NOERRORcopy operation succeeded
ERR_MEMORYIRawValue::FromRaw returned error
See also
set_hashed_value

Implements IHashValueMap.

Definition at line 230 of file hashedvaluemap.h.

References hash_value_map< STORAGE, INTERFACE >::GetCapacity(), IHashValueMapValue::GetType(), RETURN_IF_FAILED, and IRawValue::ToRaw().

◆ ToRaw()

tResult ToRaw ( IRawMemory &&  oRawValue) const
inlineoverridevirtual

Implement to create a fast value copy in memory.

Usually this method is called if types are equal implementation is within the same binary!

Parameters
oRawValue[oRawValue] copy of the memory representation of the value
Return values
ERR_NOERRORSuccessfully copied.
any_errorDepends on the implementation. You are adviced to return the return value of IRawMemory::Set.

Implements IRawValue.

Definition at line 279 of file hashedvaluemap.h.

Referenced by hash_value_map< STORAGE, INTERFACE >::hash_value_map(), and hash_value_map< STORAGE, INTERFACE >::operator=().