Astarte device API for C++ 0.8.1
Astarte device SDK for C++
Loading...
Searching...
No Matches
astarte::device::DatastreamObject Class Reference

Astarte object class, representing the Astarte object datastream data. More...

#include <object.hpp>

Public Types

using MapType = std::unordered_map<std::string, Data>
 Helper type for the map of paths and Astarte datas.
 
using iterator = MapType::iterator
 Helper type for the iterator over the map of paths and Astarte datas.
 
using const_iterator = MapType::const_iterator
 Helper type for the const iterator over the map of paths and Astarte datas.
 
using size_type = MapType::size_type
 Helper type for size type of the map of paths and Astarte datas.
 
using value_type = MapType::value_type
 Helper type for value type of the map of paths and Astarte datas.
 

Public Member Functions

 DatastreamObject ()
 Constructs an empty DatastreamObject.
 
 DatastreamObject (std::initializer_list< value_type > init)
 Constructs a DatastreamObject with initial content.
 
auto at (const std::string &key) -> Data &
 Accesses the specified element with bounds checking.
 
auto at (const std::string &key) const -> const Data &
 Accesses the specified element with bounds checking.
 
auto begin () -> iterator
 Returns an iterator to the beginning of the map.
 
auto begin () const -> const_iterator
 Returns an iterator to the beginning of the map.
 
auto end () -> iterator
 Returns an iterator to the end of the map.
 
auto end () const -> const_iterator
 Returns an iterator to the end of the map.
 
auto size () const -> size_type
 Returns the number of elements in the map.
 
auto empty () const -> bool
 Checks if the map is empty.
 
void insert (const std::string &key, const Data &data)
 Inserts elements into the map.
 
auto erase (const std::string &key) -> size_type
 Erases elements from the map.
 
void clear ()
 Clears the contents of the map.
 
auto find (const std::string &key) -> iterator
 Finds an element with a specific key.
 
auto find (const std::string &key) const -> const_iterator
 Finds an element with a specific key.
 
auto get_raw_data () const -> const MapType &
 Returns the raw data contained in this class instance.
 
auto operator== (const DatastreamObject &other) const -> bool
 Overloader for the comparison operator ==.
 
auto operator!= (const DatastreamObject &other) const -> bool
 Overloader for the comparison operator !=.
 

Detailed Description

Astarte object class, representing the Astarte object datastream data.

This class acts as a specialized container for mapping relative paths (keys) to Astarte Data values. It is primarily used when transmitting data via interfaces configured with object aggregation.

Member Typedef Documentation

◆ const_iterator

using astarte::device::DatastreamObject::const_iterator = MapType::const_iterator

Helper type for the const iterator over the map of paths and Astarte datas.

◆ iterator

Helper type for the iterator over the map of paths and Astarte datas.

◆ MapType

using astarte::device::DatastreamObject::MapType = std::unordered_map<std::string, Data>

Helper type for the map of paths and Astarte datas.

◆ size_type

Helper type for size type of the map of paths and Astarte datas.

◆ value_type

using astarte::device::DatastreamObject::value_type = MapType::value_type

Helper type for value type of the map of paths and Astarte datas.

Constructor & Destructor Documentation

◆ DatastreamObject() [1/2]

astarte::device::DatastreamObject::DatastreamObject ( )

Constructs an empty DatastreamObject.

◆ DatastreamObject() [2/2]

astarte::device::DatastreamObject::DatastreamObject ( std::initializer_list< value_type > init)

Constructs a DatastreamObject with initial content.

Parameters
[in]initThe initialize list to use as initial content.

Member Function Documentation

◆ at() [1/2]

auto astarte::device::DatastreamObject::at ( const std::string & key) -> Data &

Accesses the specified element with bounds checking.

Soft wrapper for the equivalent method in the std::unordered_map.

Parameters
[in]keyThe key to search for.
Returns
A reference to the value corresponding to the key.

◆ at() [2/2]

auto astarte::device::DatastreamObject::at ( const std::string & key) const -> const Data &

Accesses the specified element with bounds checking.

Soft wrapper for the equivalent method in the std::unordered_map.

Parameters
[in]keyThe key to search for.
Returns
A constant reference to the value corresponding to the key.

◆ begin() [1/2]

auto astarte::device::DatastreamObject::begin ( ) -> iterator

Returns an iterator to the beginning of the map.

Soft wrapper for the equivalent method in the std::unordered_map.

Returns
An iterator pointing at the beginning of the map.

◆ begin() [2/2]

auto astarte::device::DatastreamObject::begin ( ) const -> const_iterator

Returns an iterator to the beginning of the map.

Soft wrapper for the equivalent method in the std::unordered_map.

Returns
A constant iterator pointing at the beginning of the map.

◆ clear()

void astarte::device::DatastreamObject::clear ( )

Clears the contents of the map.

Soft wrapper for the equivalent method in the std::unordered_map.

◆ empty()

auto astarte::device::DatastreamObject::empty ( ) const -> bool

Checks if the map is empty.

Soft wrapper for the equivalent method in the std::unordered_map.

Returns
True if the map is empty, false otherwise.

◆ end() [1/2]

auto astarte::device::DatastreamObject::end ( ) -> iterator

Returns an iterator to the end of the map.

Soft wrapper for the equivalent method in the std::unordered_map.

Returns
An iterator pointing at the end of the map.

◆ end() [2/2]

auto astarte::device::DatastreamObject::end ( ) const -> const_iterator

Returns an iterator to the end of the map.

Soft wrapper for the equivalent method in the std::unordered_map.

Returns
A constant iterator pointing at the end of the map.

◆ erase()

auto astarte::device::DatastreamObject::erase ( const std::string & key) -> size_type

Erases elements from the map.

Soft wrapper for the equivalent method in the std::unordered_map.

Parameters
[in]keyThe key of the element to erase.
Returns
The number of elements removed (0 or 1).

◆ find() [1/2]

auto astarte::device::DatastreamObject::find ( const std::string & key) -> iterator

Finds an element with a specific key.

Soft wrapper for the equivalent method in the std::unordered_map.

Parameters
[in]keyThe key to find.
Returns
An iterator to the requested element.

◆ find() [2/2]

auto astarte::device::DatastreamObject::find ( const std::string & key) const -> const_iterator

Finds an element with a specific key.

Soft wrapper for the equivalent method in the std::unordered_map.

Parameters
[in]keyThe key to find.
Returns
A constant iterator to the requested element.

◆ get_raw_data()

auto astarte::device::DatastreamObject::get_raw_data ( ) const -> const MapType &

Returns the raw data contained in this class instance.

Returns
A constant reference to the internal map containing the object data.

◆ insert()

void astarte::device::DatastreamObject::insert ( const std::string & key,
const Data & data )

Inserts elements into the map.

Soft wrapper for the equivalent method in the std::unordered_map.

Parameters
[in]keyThe key to insert.
[in]dataThe value to insert.

◆ operator!=()

auto astarte::device::DatastreamObject::operator!= ( const DatastreamObject & other) const -> bool
nodiscard

Overloader for the comparison operator !=.

Parameters
[in]otherThe object to compare to.
Returns
True when different, false otherwise.

◆ operator==()

auto astarte::device::DatastreamObject::operator== ( const DatastreamObject & other) const -> bool
nodiscard

Overloader for the comparison operator ==.

Parameters
[in]otherThe object to compare to.
Returns
True when equal, false otherwise.

◆ size()

auto astarte::device::DatastreamObject::size ( ) const -> size_type

Returns the number of elements in the map.

Soft wrapper for the equivalent method in the std::unordered_map.

Returns
The number of elements in the map.

The documentation for this class was generated from the following file: