powerd++  0.4.4
Public Member Functions | Private Types | Private Attributes | List of all members
anonymous_namespace{libloadplay.cpp}::Sysctls Class Reference

Singleton class representing the sysctl table for this library. More...

Collaboration diagram for anonymous_namespace{libloadplay.cpp}::Sysctls:
[legend]

Public Member Functions

void addValue (mib_t const &mib, std::string const &value)
 Add a value to the sysctls map. More...
 
void addValue (std::string const &name, std::string const &value)
 Add a value to the sysctls map. More...
 
const mib_tgetMib (char const *const name) const
 Returns a mib for a given symbolic name. More...
 
const mib_tgetBaseMib (char const *const name) const
 Retrieves the base mib for a given mib name. More...
 
SysctlValueoperator[] (char const *const name)
 Returns a reference to a sysctl value container. More...
 
SysctlValueoperator[] (mib_t const &mib)
 Returns a reference to a sysctl value container. More...
 

Private Types

typedef std::lock_guard< decltype(mtx)> lock_guard
 The appropriate lock guard type for mtx.
 

Private Attributes

std::mutex mtx
 A simple mutex.
 
std::unordered_map< std::string, mib_tmibs
 Maps name → mib. More...
 
std::map< mib_t, SysctlValuesysctls
 Maps mib → (type, value). More...
 

Detailed Description

Singleton class representing the sysctl table for this library.

Member Function Documentation

◆ addValue() [1/2]

void anonymous_namespace{libloadplay.cpp}::Sysctls::addValue ( mib_t const &  mib,
std::string const &  value 
)
inline

Add a value to the sysctls map.

Parameters
mibThe mib to add the value for
valueThe value to store

◆ addValue() [2/2]

void anonymous_namespace{libloadplay.cpp}::Sysctls::addValue ( std::string const &  name,
std::string const &  value 
)
inline

Add a value to the sysctls map.

Parameters
nameThe symbolic name of the mib to add the value for
valueThe value to store

◆ getBaseMib()

const mib_t& anonymous_namespace{libloadplay.cpp}::Sysctls::getBaseMib ( char const *const  name) const
inline

Retrieves the base mib for a given mib name.

E.g. the base mib for "dev.cpu.0.freq" is the mib for "dev.cpu.%d.freq".

Parameters
nameThe MIB name
Returns
The MIB of the base name

◆ getMib()

const mib_t& anonymous_namespace{libloadplay.cpp}::Sysctls::getMib ( char const *const  name) const
inline

Returns a mib for a given symbolic name.

Parameters
nameThe MIB name
Returns
The MIB

◆ operator[]() [1/2]

SysctlValue& anonymous_namespace{libloadplay.cpp}::Sysctls::operator[] ( char const *const  name)
inline

Returns a reference to a sysctl value container.

Parameters
nameThe MIB name to return the reference for
Returns
A SysctlValue reference

◆ operator[]() [2/2]

SysctlValue& anonymous_namespace{libloadplay.cpp}::Sysctls::operator[] ( mib_t const &  mib)
inline

Returns a reference to a sysctl value container.

Parameters
mibThe MIB to return the reference for
Returns
A SysctlValue reference

Member Data Documentation

◆ mibs

std::unordered_map<std::string, mib_t> anonymous_namespace{libloadplay.cpp}::Sysctls::mibs
private
Initial value:
{
{"hw.machine", {CTL_HW, HW_MACHINE}},
{"hw.model", {CTL_HW, HW_MODEL}},
{"hw.ncpu", {CTL_HW, HW_NCPU}},
{ACLINE, {1000}},
{FREQ, {1001, -1}},
{FREQ_LEVELS, {1002, -1}},
{CP_TIMES, {1003}},
{LOADREC_FEATURES, {1004}},
{FREQ_DRIVER, {1005, -1}},
{TEMPERATURE, {1006, -1}},
{TJMAX_SOURCES[0], {1007, -1}}
}

Maps name → mib.

◆ sysctls

std::map<mib_t, SysctlValue> anonymous_namespace{libloadplay.cpp}::Sysctls::sysctls
private
Initial value:
{
{{CTL_HW, HW_MACHINE}, {CTLTYPE_STRING, "hw.machine"}},
{{CTL_HW, HW_MODEL}, {CTLTYPE_STRING, "hw.model"}},
{{CTL_HW, HW_NCPU}, {CTLTYPE_INT, "0"}},
{{1000}, {CTLTYPE_INT, "2"}},
{{1001, -1}, {CTLTYPE_INT, "0"}},
{{1002, -1}, {CTLTYPE_STRING, ""}},
{{1003}, {CTLTYPE_LONG, ""}},
{{1004}, {CTLTYPE_U64, "0"}},
{{1005, -1}, {CTLTYPE_STRING, ""}},
{{1006, -1}, {CTLTYPE_INT, "-1"}},
{{1007, -1}, {CTLTYPE_INT, "-1"}},
}

Maps mib → (type, value).


The documentation for this class was generated from the following file:
version::LOADREC_FEATURES
const char *const LOADREC_FEATURES
The pseudo MIB name for the load recording feature flags.
Definition: version.hpp:22
constants::FREQ
const char *const FREQ
The MIB name for CPU frequencies.
Definition: constants.hpp:34
constants::FREQ_LEVELS
const char *const FREQ_LEVELS
The MIB name for CPU frequency levels.
Definition: constants.hpp:39
constants::ACLINE
const char *const ACLINE
The MIB name for the AC line state.
Definition: constants.hpp:29
constants::FREQ_DRIVER
const char *const FREQ_DRIVER
The MIB name for the CPU frequency drivers.
Definition: constants.hpp:56
constants::TJMAX_SOURCES
const char *const TJMAX_SOURCES[]
An array of maximum temperature sources.
Definition: constants.hpp:49
constants::CP_TIMES
const char *const CP_TIMES
The MIB name for per-CPU time statistics.
Definition: constants.hpp:24
constants::TEMPERATURE
const char *const TEMPERATURE
The MIB name for CPU temperatures.
Definition: constants.hpp:44