MetroCollect  2.3.4
SourceField.h
Go to the documentation of this file.
1 //
2 // SourceField.h
3 //
4 // Created on August 27th 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 <vector>
25 
26 
31  using FieldName = std::vector<std::string>;
32 
33 
37  struct FieldInfo {
39  size_t index;
40  std::string description;
41 
42  IndexAndDescription(size_t anIndex, std::string aDescription) : index(anIndex), description(std::move(aDescription)) { }
43  };
44 
46  std::string description;
47  std::string unit;
48  std::vector<IndexAndDescription> dynamicIndexes;
49 
50 
54  FieldInfo() { }
55 
63  FieldInfo(FieldName aName, std::string aDescription, std::string aUnit) :
64  name(aName), description(aDescription), unit(aUnit) { }
65 
75  FieldInfo(FieldName aName, std::string aDescription, std::string aUnit, size_t anIndex, std::string aDynamicDescription) :
76  name(aName), description(aDescription), unit(aUnit), dynamicIndexes({ IndexAndDescription{anIndex, std::move(aDynamicDescription)} }) { }
77 
78 
85  bool isDynamic() {
86  return dynamicIndexes.size() == 0;
87  }
88  };
89 }
Object used to describe a field (or metric)
Definition: SourceField.h:37
FieldName name
Name of the field.
Definition: SourceField.h:45
std::string description
Description of the field.
Definition: SourceField.h:46
std::vector< std::string > FieldName
Type used for field names (an array of strings)
Definition: SourceField.h:31
Namespace for sources of metrics objects and operations.
FieldInfo(FieldName aName, std::string aDescription, std::string aUnit, size_t anIndex, std::string aDynamicDescription)
Construct a new Field Info object.
Definition: SourceField.h:75
STL namespace.
IndexAndDescription(size_t anIndex, std::string aDescription)
Definition: SourceField.h:42
FieldInfo(FieldName aName, std::string aDescription, std::string aUnit)
Construct a new Field Info object.
Definition: SourceField.h:63
bool isDynamic()
Checks if the field name contains any dynamic part.
Definition: SourceField.h:85
std::string unit
Unit of the field&#39;s metric.
Definition: SourceField.h:47
std::vector< IndexAndDescription > dynamicIndexes
Indexes and descriptions of the dynamic parts of the field name.
Definition: SourceField.h:48
FieldInfo()
Construct a new Field Info object.
Definition: SourceField.h:54