MetroCollect  2.3.4
MetricsDataArray.cc
Go to the documentation of this file.
1 //
2 // MetricsDataArray.cc
3 //
4 // Created on July 18th 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 "MetricsDataArray.h"
22 
23 
24 namespace MetroCollect {
26 
27  MetricsDataArray::MetricsDataArray(MetricsSource::SourceInterests sourceInterests) noexcept : MetricsArray(sourceInterests) { }
28 
29 
31  this->sources_.forEach([&](auto& source, size_t sourceIndex) {
32  if ((*this->sourceInterests_)[sourceIndex].any())
33  source.fetchData((*this->sourceInterests_)[sourceIndex], this->sourceIterators_[sourceIndex].first);
34  });
35 
36  this->timestamp_ = std::chrono::system_clock::now();
37  }
38 }
MetricsSource::SourceInterests sourceInterests_
Boolean arrays to store source interests.
Definition: MetricsArray.h:47
std::chrono::system_clock::time_point timestamp_
Time at which metrics were collected.
Definition: MetricsArray.h:48
std::shared_ptr< std::vector< MetricsSource::Interests > > SourceInterests
Type used to store and share interests of multiple sources.
void updateData()
Fetch new metric values from each source.
Generic class to store and manage metrics.
Definition: MetricsArray.h:40
void forEach(Function func)
Execute a function for each source.
MetricsDataArray() noexcept
Construct a new Metrics Data Array object.
MetricsSource::MetricsSourceArray sources_
Array of sources to fetch data from.
Definition: MetricsArray.h:51