Patrick Venture | aca9813 | 2019-03-18 11:14:16 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <cstdint> |
| 4 | #include <string> |
| 5 | |
| 6 | namespace ethstats |
| 7 | { |
| 8 | |
| 9 | class EthStatsInterface |
| 10 | { |
| 11 | public: |
| 12 | virtual ~EthStatsInterface() = default; |
| 13 | |
| 14 | /** Given an ifname and a statistic, validate both. |
| 15 | * |
| 16 | * @param[in] path - the interface name and statistics field |
| 17 | * @return true if both valid, false otherwise. |
| 18 | */ |
| 19 | virtual bool validIfNameAndField(const std::string& path) const = 0; |
| 20 | |
| 21 | /** Given an ifname and a statistic, return the value. |
| 22 | * |
| 23 | * @param[in] path - the interface name and statistics field |
| 24 | * @return the value of that statistic for that interface. |
| 25 | */ |
| 26 | virtual std::uint64_t readStatistic(const std::string& path) const = 0; |
| 27 | }; |
| 28 | |
| 29 | class EthStats : public EthStatsInterface |
| 30 | { |
| 31 | public: |
| 32 | EthStats() = default; |
| 33 | ~EthStats() = default; |
| 34 | |
| 35 | bool validIfNameAndField(const std::string& path) const override; |
| 36 | std::uint64_t readStatistic(const std::string& path) const override; |
| 37 | }; |
| 38 | |
Patrick Venture | aca9813 | 2019-03-18 11:14:16 -0700 | [diff] [blame] | 39 | } // namespace ethstats |