MetroCollect  2.3.4
MetricsStatsArray.cc
Go to the documentation of this file.
1 //
2 // MetricsStatsArray.cc
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 #include "MetricsStatsArray.h"
22 
23 
24 namespace MetroCollect {
25  template<typename T>
27 
28 
29  template<typename T>
30  const std::chrono::system_clock::time_point& MetricsStatsArray<T>::startTime() const noexcept {
31  return this->startTime_;
32  }
33 
34  template<typename T>
35  const std::chrono::system_clock::time_point& MetricsStatsArray<T>::endTime() const noexcept {
36  return this->timestamp_;
37  }
38 
39 
40  template<typename T>
41  void MetricsStatsArray<T>::setStartTime(std::chrono::system_clock::time_point startTime) noexcept {
42  this->startTime_ = std::move(startTime);
43  }
44 
45  template<typename T>
46  void MetricsStatsArray<T>::setEndTime(std::chrono::system_clock::time_point endTime) noexcept {
47  this->timestamp_ = std::move(endTime);
48  }
49 
50 
51  template<typename T>
52  const std::set<size_t>& MetricsStatsArray<T>::indexes() const noexcept {
53  return this->indexes_;
54  }
55 
56  template<typename T>
57  void MetricsStatsArray<T>::setIndexes(std::set<size_t> indexes) noexcept {
58  this->indexes_ = std::move(indexes);
59  this->values_.clear();
60 
61  for (size_t i : this->indexes_)
62  this->values_.emplace_back(i, this->data_[i]);
63  }
64 
65 
66  template<typename T>
67  size_t MetricsStatsArray<T>::indexCount() const noexcept {
68  return this->indexes_.size();
69  }
70 
71 
72  template<typename T>
73  const std::vector<typename MetricsStatsArray<T>::IndexedValue>& MetricsStatsArray<T>::indexedValues() const noexcept {
74  return this->values_;
75  }
76 
77 
78  template class MetricsStatsArray<size_t>;
79  template class MetricsStatsArray<DiffValueType>;
80 }
const std::chrono::system_clock::time_point & endTime() const noexcept
Get time of latest metrics.
MetricsStatsArray() noexcept
Construct a new Metrics Stats Array object.
Generic class to store and manage metrics.
Definition: MetricsArray.h:40
void setEndTime(std::chrono::system_clock::time_point endTime) noexcept
Set the time of latest metrics used to compute statistics.
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.
const std::chrono::system_clock::time_point & startTime() const noexcept
Get time of earlier metrics.
void setIndexes(std::set< size_t > indexes) noexcept
Set which indexes are requested.