MetroCollect  2.3.4
MetricsStatsArray.h
Go to the documentation of this file.
1 //
2 // MetricsStatsArray.h
3 //
4 // Created on July 25th 2018
5 //
6 // Copyright 2018 CFM (www.cfm.fr)
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 //
20 
21 #pragma once
22 
23 #include <set>
24 
25 #include "MetricsArray.h"
26 #include "Statistics.h"
27 
28 
29 namespace MetroCollect {
35  template<typename T>
36  class MetricsStatsArray : public MetricsArray<T> {
37  public:
41  struct IndexedValue {
42  size_t index;
43  T& value;
44 
51  IndexedValue(size_t anIndex, T& aValue) : index(anIndex), value(aValue) { }
52  };
53 
54  protected:
55  std::set<size_t> indexes_;
56  std::vector<IndexedValue> values_;
57 
58  std::chrono::system_clock::time_point startTime_;
59 
60  public:
64  MetricsStatsArray() noexcept;
65 
71  const std::chrono::system_clock::time_point& startTime() const noexcept;
72 
78  const std::chrono::system_clock::time_point& endTime() const noexcept;
79 
80 
86  void setStartTime(std::chrono::system_clock::time_point startTime) noexcept;
87 
93  void setEndTime(std::chrono::system_clock::time_point endTime) noexcept;
94 
95 
101  const std::set<size_t>& indexes() const noexcept;
102 
108  void setIndexes(std::set<size_t> indexes) noexcept;
109 
115  size_t indexCount() const noexcept;
116 
117 
123  const std::vector<IndexedValue>& indexedValues() const noexcept;
124  };
125 }
const std::chrono::system_clock::time_point & endTime() const noexcept
Get time of latest metrics.
Class to store metric statistics, and the indexes of those requested.
IndexedValue(size_t anIndex, T &aValue)
Construct a new Indexed Value object.
STL namespace.
MetricsStatsArray() noexcept
Construct a new Metrics Stats Array object.
Generic class to store and manage metrics.
Definition: MetricsArray.h:40
size_t index
Index of the value in the container.
std::set< size_t > indexes_
Set of requested metrics.
void setEndTime(std::chrono::system_clock::time_point endTime) noexcept
Set the time of latest metrics used to compute statistics.
std::vector< IndexedValue > values_
Array of requested metrics.
const std::set< size_t > & indexes() const noexcept
Returns set of requested metrics.
const std::vector< IndexedValue > & indexedValues() const noexcept
Returns the requested metric indexes and values.
size_t indexCount() const noexcept
Returns the number of requested metrics.
void setStartTime(std::chrono::system_clock::time_point startTime) noexcept
Set the time of earlier metrics used to compute statistics.
Small struct to store an index of a value in a container and a reference to its value.
const std::chrono::system_clock::time_point & startTime() const noexcept
Get time of earlier metrics.
std::chrono::system_clock::time_point startTime_
Time of the earlier metric.
void setIndexes(std::set< size_t > indexes) noexcept
Set which indexes are requested.