MetroCollect  2.3.4
Source.h
Go to the documentation of this file.
1 //
2 // MetricsSourceArray.h
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 #pragma once
22 
23 #include <string>
24 #include <string_view>
25 #include <vector>
26 
27 #include "MetricTypes.h"
28 #include "SourceField.h"
29 #include "SourceInterests.h"
30 #include "SourceTools.h"
31 
32 
42  class SourceBase {
43  protected:
44  SourceBase() {}
46 
47  public:
48  SourceBase(const SourceBase&) = delete;
49  void operator=(const SourceBase&) = delete;
50 
51 
57  virtual size_t fieldCount() const noexcept = 0;
58 
66  virtual const std::vector<size_t> indexesOfFieldName(const FieldName& fieldName, Interests* interests = nullptr) const noexcept = 0;
67 
73  virtual const std::string fieldNameSourcePrefix() const noexcept = 0;
74 
81  virtual const FieldInfo fieldInfoAtIndex(size_t index) const noexcept = 0;
82 
88  virtual const std::vector<FieldInfo> allFieldsInfo() const noexcept = 0;
89 
90 
97  virtual void fetchData(const Interests& interests, DataArray::Iterator current) = 0;
98 
99 
109  virtual void computeDiff(const Interests& interests, DiffArray::Iterator diff, DataArray::ConstIterator current, DataArray::ConstIterator previous, double factor = 1) noexcept = 0;
110  };
111 }
Object used to describe a field (or metric)
Definition: SourceField.h:37
SourceBase()
Protected default constructor.
Definition: Source.h:44
std::vector< std::string > FieldName
Type used for field names (an array of strings)
Definition: SourceField.h:31
virtual const std::string fieldNameSourcePrefix() const noexcept=0
Get the prefix by which all field names should begin with.
Namespace for sources of metrics objects and operations.
std::vector< DataValueType >::const_iterator ConstIterator
Const iterator type of MetricsDataArray.
Definition: MetricTypes.h:37
STL namespace.
void operator=(const SourceBase &)=delete
Deleted copy operator.
virtual void computeDiff(const Interests &interests, DiffArray::Iterator diff, DataArray::ConstIterator current, DataArray::ConstIterator previous, double factor=1) noexcept=0
Compute the variation (in appropriate unit) of metrics.
virtual void fetchData(const Interests &interests, DataArray::Iterator current)=0
Fetch the latest metrics.
virtual const FieldInfo fieldInfoAtIndex(size_t index) const noexcept=0
Get details about a specific field.
Boolean array to keep track of which fields a source has to fetch metrics for.
~SourceBase()
Protected default destructor.
Definition: Source.h:45
virtual const std::vector< size_t > indexesOfFieldName(const FieldName &fieldName, Interests *interests=nullptr) const noexcept=0
Search for fields associated to a specific name.
virtual const std::vector< FieldInfo > allFieldsInfo() const noexcept=0
Get all fields details, field which share a common name should appear only once.
Singleton abstract class, base class of all metric sources classes.
Definition: Source.h:42
std::vector< DataValueType >::iterator Iterator
Iterator type of MetricsDataArray.
Definition: MetricTypes.h:36
virtual size_t fieldCount() const noexcept=0
Get the number of field the source has.