Inheritance diagram for lm::LoadMonitor::StatsProvider:
Public Member Functions | |
StatsProvider (void) | |
Constructor. | |
virtual | ~StatsProvider (void) |
Destructor. | |
virtual bool | QueryData (LoadSample &target)=0 |
virtual bool | QueryData (HardwareDescription &target)=0 |
Protected Member Functions | |
bool | ReadLines (const char *file_name, std::vector< std::string > &target) const |
Read lines from text file. | |
template<typename T> | |
bool | GetFieldValue (const std::string &line, const size_t index, T &result, const size_t start_at=0, const char *delim=" \t") const |
Extract value of given column from the line. | |
std::pair< std::string, size_t > | GetFieldName (const std::string &line, const std::string &end=":", const size_t start_at=0) const |
Extract name of the field. | |
bool | BeginsWith (const std::string &str, const std::string &what) const |
Test if string begins with another string. | |
Static Protected Member Functions | |
static int | GetKernelVersionCode (void) |
Get version code of the current kernel. | |
Private Member Functions | |
StatsProvider (const StatsProvider &) | |
Empty private copy-ctor to prevent copying. |
lm::LoadMonitor::StatsProvider::StatsProvider | ( | void | ) |
Constructor.
lm::LoadMonitor::StatsProvider::~StatsProvider | ( | void | ) | [virtual] |
Destructor.
lm::LoadMonitor::StatsProvider::StatsProvider | ( | const StatsProvider & | ) | [inline, private] |
Empty private copy-ctor to prevent copying.
bool lm::LoadMonitor::StatsProvider::BeginsWith | ( | const std::string & | str, | |
const std::string & | what | |||
) | const [protected] |
Test if string begins with another string.
str | String to test. | |
what | String to search for. |
std::pair< std::string, size_t > lm::LoadMonitor::StatsProvider::GetFieldName | ( | const std::string & | line, | |
const std::string & | end = ":" , |
|||
const size_t | start_at = 0 | |||
) | const [protected] |
Extract name of the field.
Retrieve name of the current line. Name is string that does not contain white-space characters at the beginning or at the end (white-spaces in the middle are allowed).
line | String which contains data and name. | |
end | String which marks end of the field name. Default value is ":" which is suitable for files in the /proc directory. | |
start_at | First character of the name. May be whitespace. Default value is 0. |
bool lm::LoadMonitor::StatsProvider::GetFieldValue | ( | const std::string & | line, | |
const size_t | index, | |||
T & | result, | |||
const size_t | start_at = 0 , |
|||
const char * | delims = " \t" | |||
) | const [protected] |
Extract value of given column from the line.
Retrieve value of the column with given index. Columns can be separated by custom delimiter characters. Value will be automatically converted to the target type.
line | String which contains requested value. | |
index | Index of the column which contains given value. First column has index of 1. | |
start_at | Index of the first character (or some delimiter directly before) of the first column. | |
delims | Delimiters that are between columns. Each character of this string is threated as a delimiter. | |
result | Reference to the variable which will receive value of the given column. Value is automatically converted to the target type via the stream operator >>. If an error occured during conversion or if column with given index does not exist, original value remains unchanged. |
int lm::LoadMonitor::StatsProvider::GetKernelVersionCode | ( | void | ) | [static, protected] |
Get version code of the current kernel.
0x10000 * major + 0x100 * minor + release
, where major, minor and release are version numbers as determined by uname
. Zero is returned if the uname
call or string conversion failed. virtual bool lm::LoadMonitor::StatsProvider::QueryData | ( | HardwareDescription & | target | ) | [pure virtual] |
Query data and store their descriptions.
target | Structure which will receive data collected by this provider. |
Implemented in lm::LoadMonitor::MemoryStats, lm::LoadMonitor::ProcessorStats, lm::LoadMonitor::NetworkStats, lm::LoadMonitor::DriveStats, and lm::LoadMonitor::SystemStats.
virtual bool lm::LoadMonitor::StatsProvider::QueryData | ( | LoadSample & | target | ) | [pure virtual] |
Query data and store them in given sample.
target | Sample which will receive data collected by this provider. |
Implemented in lm::LoadMonitor::MemoryStats, lm::LoadMonitor::ProcessorStats, lm::LoadMonitor::NetworkStats, lm::LoadMonitor::DriveStats, and lm::LoadMonitor::SystemStats.
bool lm::LoadMonitor::StatsProvider::ReadLines | ( | const char * | file_name, | |
std::vector< std::string > & | target | |||
) | const [protected] |
Read lines from text file.
This will read all lines from the text file into given vector.
file_name | Name of the file to read. | |
target | Vector which will receive lines read from the file. Note that lines are added at the end of the vector and data from vector are not removed automatically. |