MetroCollect  2.3.4
MetroCollect::MetricsArray< T > Class Template Reference

Generic class to store and manage metrics. More...

#include <MetricsArray.h>

Inheritance diagram for MetroCollect::MetricsArray< T >:
Collaboration diagram for MetroCollect::MetricsArray< T >:

Public Types

using ValueType = T
 Type of stored metrics on the container. More...
 
using Iterator = typename std::vector< T >::iterator
 Iterator type. More...
 
using ConstIterator = typename std::vector< T >::const_iterator
 Const iterator type. More...
 

Public Member Functions

 MetricsArray () noexcept
 Construct a new Metrics Array object. More...
 
 MetricsArray (MetricsSource::SourceInterests sourceInterests) noexcept
 Construct a new Metrics Array object. More...
 
 MetricsArray (const MetricsArray &other) noexcept
 Copy constructor. More...
 
MetricsArrayoperator= (const MetricsArray &other) noexcept
 Assignment operator. More...
 
MetricsSource::SourceInterests sourceInterests () const noexcept
 Returns the source interests. More...
 
void setSourcesInterests (MetricsSource::SourceInterests sourceInterests) noexcept
 Set the source interests. More...
 
const std::chrono::system_clock::time_point & timestamp () const noexcept
 Returns the timestamp of stored metrics. More...
 
size_t fieldCount () const noexcept
 Returns the total number of available metrics. More...
 
const std::vector< size_t > indexesOfFieldName (const MetricsSource::FieldName &fieldName, bool setInterest=true) const noexcept
 Finds indexes of a field from its name across sources. More...
 
const MetricsSource::FieldInfo fieldInfoAtIndex (size_t index) const noexcept
 Get details about a specific metric field. More...
 
const std::vector< MetricsSource::FieldInfoallFieldsInfo () const noexcept
 Get details about all fields. More...
 
size_t size () const noexcept
 Returns the size of the underlying array. More...
 
T & at (size_t index)
 Access specified element. More...
 
const T & at (size_t index) const
 Access specified element. More...
 
T & operator[] (size_t index)
 Access specified element. More...
 
const T & operator[] (size_t index) const
 Access specified element. More...
 
std::pair< Iterator, IteratormetricsSliceForSource (size_t sourceIndex)
 Returns the iterator pair associated with a source. More...
 
Iterator begin () noexcept
 Returns an iterator to the first element of the container. More...
 
const ConstIterator begin () const noexcept
 Returns an iterator to the first element of the container. More...
 
Iterator end () noexcept
 Returns an iterator to the element following the last element of the container. More...
 
const ConstIterator end () const noexcept
 Returns an iterator to the element following the last element of the container. More...
 

Protected Member Functions

void setSize () noexcept
 Resize the underlying container to fit the total number of metrics. More...
 
void setIterators () noexcept
 Update internal iterators pairs. More...
 

Protected Attributes

MetricsSource::SourceInterests sourceInterests_
 Boolean arrays to store source interests. More...
 
std::chrono::system_clock::time_point timestamp_
 Time at which metrics were collected. More...
 
std::vector< T > data_
 Underlying data storage. More...
 
MetricsSource::MetricsSourceArray sources_
 Array of sources to fetch data from. More...
 
std::array< std::pair< Iterator, Iterator >, MetricsSource::MetricsSourceArray::countsourceIterators_
 Iterators pairs associating metrics to a source. More...
 
friend MetricsDiffArray
 To allow internal access by subclass. More...
 

Detailed Description

template<typename T>
class MetroCollect::MetricsArray< T >

Generic class to store and manage metrics.

Template Parameters
TType of stored metrics on the container

Definition at line 40 of file MetricsArray.h.

Member Typedef Documentation

◆ ConstIterator

template<typename T>
using MetroCollect::MetricsArray< T >::ConstIterator = typename std::vector<T>::const_iterator

Const iterator type.

Definition at line 44 of file MetricsArray.h.

◆ Iterator

template<typename T>
using MetroCollect::MetricsArray< T >::Iterator = typename std::vector<T>::iterator

Iterator type.

Definition at line 43 of file MetricsArray.h.

◆ ValueType

template<typename T>
using MetroCollect::MetricsArray< T >::ValueType = T

Type of stored metrics on the container.

Definition at line 42 of file MetricsArray.h.

Constructor & Destructor Documentation

◆ MetricsArray() [1/3]

template<typename T >
MetroCollect::MetricsArray< T >::MetricsArray ( )
noexcept

Construct a new Metrics Array object.

Definition at line 31 of file MetricsArray.cc.

◆ MetricsArray() [2/3]

template<typename T >
MetroCollect::MetricsArray< T >::MetricsArray ( MetricsSource::SourceInterests  sourceInterests)
explicitnoexcept

Construct a new Metrics Array object.

Parameters
sourceInterestsboolean arrays to store source interests

Definition at line 36 of file MetricsArray.cc.

◆ MetricsArray() [3/3]

template<typename T >
MetroCollect::MetricsArray< T >::MetricsArray ( const MetricsArray< T > &  other)
noexcept

Copy constructor.

Parameters
otherMetrics Array to copy from

Definition at line 42 of file MetricsArray.cc.

Member Function Documentation

◆ allFieldsInfo()

template<typename T >
const std::vector< MetricsSource::FieldInfo > MetroCollect::MetricsArray< T >::allFieldsInfo ( ) const
noexcept

Get details about all fields.

Returns
Details of all fields

Definition at line 122 of file MetricsArray.cc.

Here is the caller graph for this function:

◆ at() [1/2]

template<typename T >
T & MetroCollect::MetricsArray< T >::at ( size_t  index)

Access specified element.

Parameters
indexposition of the element to return
Returns
Reference to the requested element

Definition at line 140 of file MetricsArray.cc.

Here is the caller graph for this function:

◆ at() [2/2]

template<typename T >
const T & MetroCollect::MetricsArray< T >::at ( size_t  index) const

Access specified element.

Parameters
indexposition of the element to return
Returns
Const reference to the requested element

Definition at line 145 of file MetricsArray.cc.

◆ begin() [1/2]

template<typename T >
MetricsArray< T >::Iterator MetroCollect::MetricsArray< T >::begin ( )
noexcept

Returns an iterator to the first element of the container.

Returns
Iterator to the first element

Definition at line 157 of file MetricsArray.cc.

Here is the caller graph for this function:

◆ begin() [2/2]

template<typename T >
const MetricsArray< T >::ConstIterator MetroCollect::MetricsArray< T >::begin ( ) const
noexcept

Returns an iterator to the first element of the container.

Returns
Const iterator to the first element

Definition at line 162 of file MetricsArray.cc.

◆ end() [1/2]

template<typename T >
MetricsArray< T >::Iterator MetroCollect::MetricsArray< T >::end ( )
noexcept

Returns an iterator to the element following the last element of the container.

Returns
Iterator to the element following the last element

Definition at line 167 of file MetricsArray.cc.

Here is the caller graph for this function:

◆ end() [2/2]

template<typename T >
const MetricsArray< T >::ConstIterator MetroCollect::MetricsArray< T >::end ( ) const
noexcept

Returns an iterator to the element following the last element of the container.

Returns
Const iterator to the element following the last element

Definition at line 172 of file MetricsArray.cc.

◆ fieldCount()

template<typename T >
size_t MetroCollect::MetricsArray< T >::fieldCount ( ) const
noexcept

Returns the total number of available metrics.

It is the same as the size of the underlying array

Returns
The total number of available metrics

Definition at line 74 of file MetricsArray.cc.

Here is the caller graph for this function:

◆ fieldInfoAtIndex()

template<typename T >
const MetricsSource::FieldInfo MetroCollect::MetricsArray< T >::fieldInfoAtIndex ( size_t  index) const
noexcept

Get details about a specific metric field.

Parameters
indexIndex of field to get details of
Returns
Details of the field

Definition at line 103 of file MetricsArray.cc.

Here is the caller graph for this function:

◆ indexesOfFieldName()

template<typename T >
const std::vector< size_t > MetroCollect::MetricsArray< T >::indexesOfFieldName ( const MetricsSource::FieldName fieldName,
bool  setInterest = true 
) const
noexcept

Finds indexes of a field from its name across sources.

Parameters
fieldNamename of the field to search
setInterestwhether to activate the corresponding source interests
Returns
const std::vector<size_t> indexes of fields with given name

Definition at line 85 of file MetricsArray.cc.

◆ metricsSliceForSource()

template<typename T >
std::pair< typename MetricsArray< T >::Iterator, typename MetricsArray< T >::Iterator > MetroCollect::MetricsArray< T >::metricsSliceForSource ( size_t  sourceIndex)

Returns the iterator pair associated with a source.

Parameters
sourceIndexindex of the source to get metric iterators
Returns
Iterator pair (begin, end) of metrics given by the specified source

Definition at line 151 of file MetricsArray.cc.

◆ operator=()

template<typename T >
MetricsArray< T > & MetroCollect::MetricsArray< T >::operator= ( const MetricsArray< T > &  other)
noexcept

Assignment operator.

Parameters
otherMetrics Array to copy from
Returns
this with updated values

Definition at line 47 of file MetricsArray.cc.

◆ operator[]() [1/2]

template<typename T>
T& MetroCollect::MetricsArray< T >::operator[] ( size_t  index)
inline

Access specified element.

Parameters
indexposition of the element to return
Returns
Reference to the requested element

Definition at line 177 of file MetricsArray.h.

◆ operator[]() [2/2]

template<typename T>
const T& MetroCollect::MetricsArray< T >::operator[] ( size_t  index) const
inline

Access specified element.

Parameters
indexposition of the element to return
Returns
Const reference to the requested element

Definition at line 185 of file MetricsArray.h.

◆ setIterators()

template<typename T >
void MetroCollect::MetricsArray< T >::setIterators ( )
protectednoexcept

Update internal iterators pairs.

Definition at line 185 of file MetricsArray.cc.

◆ setSize()

template<typename T >
void MetroCollect::MetricsArray< T >::setSize ( )
protectednoexcept

Resize the underlying container to fit the total number of metrics.

Definition at line 178 of file MetricsArray.cc.

◆ setSourcesInterests()

template<typename T >
void MetroCollect::MetricsArray< T >::setSourcesInterests ( MetricsSource::SourceInterests  sourceInterests)
noexcept

Set the source interests.

Parameters
sourceInterestsnew source interests to copy

Definition at line 62 of file MetricsArray.cc.

◆ size()

template<typename T >
size_t MetroCollect::MetricsArray< T >::size ( ) const
noexcept

Returns the size of the underlying array.

It returns the same value as fieldCount().

Returns
the size of the underlying array

Definition at line 135 of file MetricsArray.cc.

Here is the caller graph for this function:

◆ sourceInterests()

template<typename T >
MetricsSource::SourceInterests MetroCollect::MetricsArray< T >::sourceInterests ( ) const
noexcept

Returns the source interests.

Returns
The source interests

Definition at line 57 of file MetricsArray.cc.

Here is the caller graph for this function:

◆ timestamp()

template<typename T >
const std::chrono::system_clock::time_point & MetroCollect::MetricsArray< T >::timestamp ( ) const
noexcept

Returns the timestamp of stored metrics.

Returns
The timestamp of stored metrics

Definition at line 68 of file MetricsArray.cc.

Member Data Documentation

◆ data_

template<typename T>
std::vector<T> MetroCollect::MetricsArray< T >::data_
protected

Underlying data storage.

Definition at line 50 of file MetricsArray.h.

◆ MetricsDiffArray

template<typename T>
friend MetroCollect::MetricsArray< T >::MetricsDiffArray
protected

To allow internal access by subclass.

Definition at line 54 of file MetricsArray.h.

◆ sourceInterests_

template<typename T>
MetricsSource::SourceInterests MetroCollect::MetricsArray< T >::sourceInterests_
protected

Boolean arrays to store source interests.

Definition at line 47 of file MetricsArray.h.

◆ sourceIterators_

template<typename T>
std::array<std::pair<Iterator, Iterator>, MetricsSource::MetricsSourceArray::count> MetroCollect::MetricsArray< T >::sourceIterators_
protected

Iterators pairs associating metrics to a source.

Definition at line 52 of file MetricsArray.h.

◆ sources_

template<typename T>
MetricsSource::MetricsSourceArray MetroCollect::MetricsArray< T >::sources_
protected

Array of sources to fetch data from.

Definition at line 51 of file MetricsArray.h.

◆ timestamp_

template<typename T>
std::chrono::system_clock::time_point MetroCollect::MetricsArray< T >::timestamp_
protected

Time at which metrics were collected.

Definition at line 48 of file MetricsArray.h.


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