28 #include <string_view> 42 static constexpr std::string_view sourcePrefix =
"ethtool"sv;
43 static constexpr std::string_view fieldNameAll =
"*"sv;
44 static constexpr std::string_view fieldNameInterfaceDescription =
"interface"sv;
45 static constexpr std::string_view fieldNameIndexDescription =
"index"sv;
46 static constexpr std::array fieldUnitsAssociation = {
KeyUnit{
"bytes"sv,
"bytes"sv},
KeyUnit{
"packets"sv,
"packets"sv},
KeyUnit{
"pkts"sv,
"packets"sv} };
47 static constexpr std::string_view defaultUnit =
""sv;
56 template<
typename T,
typename P =
char>
64 T* pointer_ =
nullptr;
79 this->paddingSize_ = padding;
80 this->pointer_ =
static_cast<T*
>(calloc(1,
sizeof(T) + padding *
sizeof(P)));
81 this->pointer_->cmd = cmd;
92 *
this = std::move(other);
109 if (this->pointer_ != other.pointer_) {
110 free(static_cast<void*>(this->pointer_));
111 this->pointer_ =
nullptr;
112 std::swap(this->pointer_, other.pointer_);
126 free(static_cast<void*>(this->pointer_));
136 return *this->pointer_;
145 return *this->pointer_;
154 return this->pointer_;
163 return this->pointer_;
173 return this->paddingSize_;
182 return sizeof(T) + this->paddingSize_ *
sizeof(P);
190 inline caddr_t
raw() const noexcept {
191 return reinterpret_cast<caddr_t
>(this->pointer_);
252 size_t fieldCount() const noexcept override final;
253 const
std::vector<
size_t> indexesOfFieldName(const
FieldName& fieldName,
Interests* interests =
nullptr) const noexcept override final;
254 const
std::
string fieldNameSourcePrefix() const noexcept override final;
255 const
FieldInfo fieldInfoAtIndex(
size_t index) const noexcept override final;
256 const
std::vector<
FieldInfo> allFieldsInfo() const noexcept override final;
258 void fetchData(const
Interests& interests, DataArray::
Iterator current) override final;
Object used to describe a field (or metric)
Stuct to associate a field name containing a certain key with a unit.
std::vector< std::string > FieldName
Type used for field names (an array of strings)
Namespace for sources of metrics objects and operations.
std::vector< DataValueType >::const_iterator ConstIterator
Const iterator type of MetricsDataArray.
Boolean array to keep track of which fields a source has to fetch metrics for.
Singleton abstract class, base class of all metric sources classes.
std::vector< DataValueType >::iterator Iterator
Iterator type of MetricsDataArray.