openDAQ
Open data acquisition platform
DictObjectPtr< T, KeyT, ValueT, KeyPtr, ValuePtr > Class Template Reference

Represents a collection of key/value pairs. More...

Detailed Description

template<typename T, typename KeyT, typename ValueT, typename KeyPtr, typename ValuePtr>
class DictObjectPtr< T, KeyT, ValueT, KeyPtr, ValuePtr >

Represents a collection of key/value pairs.

Public Member Functions

ValuePtr get (const KeyPtr &key) const
 Gets the element with the specified key. More...
 
bool tryGet (const KeyPtr &key, ValuePtr &value) const
 Gets the element with the specified key. More...
 
void set (const KeyPtr &key, const ValuePtr &value)
 Sets the element with the specified key. More...
 
ValuePtr remove (const KeyPtr &key)
 Removes the element with the specified key. More...
 
bool tryRemove (const KeyPtr &key)
 Removes the element with the specified key. More...
 
void deleteItem (const KeyPtr &key)
 Deletes the element with the specified key. More...
 
SizeT getCount () const
 Gets the number of elements contained in the dictionary. More...
 
void clear ()
 Removes all elements from the list.
 
bool hasKey (const KeyPtr &key) const
 Checks if the element with the specified key exists in the dictionary. More...
 
ListPtr< KeyT, KeyPtr > getKeyList () const
 Gets the list of all keys in the dictionary. More...
 
ListPtr< ValueT, ValuePtr > getValueList () const
 Gets the list of all elements in the dictionary. More...
 
IterablePtr< KeyT, KeyPtr > getKeys () const
 Gets the iterable interface of the keys. More...
 
IterablePtr< ValueT, ValuePtr > getValues () const
 Gets the iterable interface of the elements. More...
 
IntfID getKeyInterfaceId () const
 Returns the interface id of the expected key type. More...
 
IntfID getValueInterfaceId () const
 Returns the interface id of the expected value type. More...
 
IteratorType begin () const
 Creates start iterator for the dictionary.
 
IteratorType end () const
 Creates end iterator for the dictionary.
 

Member Function Documentation

◆ deleteItem()

void deleteItem ( const KeyPtr &  key)

Deletes the element with the specified key.

Parameters
keyThe key of the element to delete.

◆ get()

ValuePtr get ( const KeyPtr &  key) const

Gets the element with the specified key.

Parameters
keyThe key of the element to get.
Returns
The element with the specified key.

Throws an exception if the key does not exist.

◆ getCount()

SizeT getCount

Gets the number of elements contained in the dictionary.

Returns
The number of elements contained in the dictionary.

◆ getKeyInterfaceId()

IntfID getKeyInterfaceId

Returns the interface id of the expected key type.

Returns
The interface id of the expected key type otherwise returns the id of IUnknown.

◆ getKeyList()

ListPtr< KeyT, KeyPtr > getKeyList

Gets the list of all keys in the dictionary.

Returns
The list of the keys.

The order of the keys is not defined.

◆ getKeys()

IterablePtr< KeyT, KeyPtr > getKeys

Gets the iterable interface of the keys.

Returns
The iterable interface of the keys.

The Iterable object enables iteration through the keys.

◆ getValueInterfaceId()

IntfID getValueInterfaceId

Returns the interface id of the expected value type.

Returns
The interface id of the expected value type otherwise returns the id of IUnknown.

◆ getValueList()

ListPtr< ValueT, ValuePtr > getValueList

Gets the list of all elements in the dictionary.

Returns
The list of the elements.

The order of the elements is not defined.

◆ getValues()

IterablePtr< ValueT, ValuePtr > getValues

Gets the iterable interface of the elements.

Returns
The iterable interface of the elements.

The Iterable object enables iteration through the elements.

◆ hasKey()

bool hasKey ( const KeyPtr &  key) const

Checks if the element with the specified key exists in the dictionary.

Parameters
keyThe key of the element to check.
Returns
True if the element exists, False otherwise.

◆ remove()

ValuePtr remove ( const KeyPtr &  key)

Removes the element with the specified key.

Parameters
keyThe key of the element to remove.
Returns
The element with the specified key.

Throws an exception if the key does not exist.

◆ set()

void set ( const KeyPtr &  key,
const ValuePtr &  value 
)

Sets the element with the specified key.

Parameters
keyThe key of the element to set.
valueThe element with the specified key.

◆ tryGet()

bool tryGet ( const KeyPtr &  key,
ValuePtr &  value 
) const

Gets the element with the specified key.

Parameters
keyThe key of the element to get.
[out]valueThe element with the specified key.
Returns
True if they exists, False otherwise.

◆ tryRemove()

bool tryRemove ( const KeyPtr &  key)

Removes the element with the specified key.

Parameters
keyThe key of the element to remove.
Returns
True if the key exists, False otherwise.