geopm  3.1.1.dev272+gdfb40a8d
GEOPM - Global Extensible Open Power Manager
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
geopm::SysfsDriver Class Referenceabstract

Class used to implement the SysfsIOGroup base class. More...

#include <SysfsDriver.hpp>

Inheritance diagram for geopm::SysfsDriver:
Inheritance graph
[legend]

Classes

struct  properties_s
 The properties about a signal or control. More...
 

Public Member Functions

 SysfsDriver ()=default
 
virtual ~SysfsDriver ()=default
 
virtual int domain_type (const std::string &name) const =0
 Get the PlatformTopo domain type for an named attribute. More...
 
virtual std::string attribute_path (const std::string &name, int domain_idx)=0
 Get the path to the sysfs entry for signal. More...
 
virtual std::function< double(const std::string &)> signal_parse (const std::string &signal_name) const =0
 Get function to convert contents of sysfs file into signal. More...
 
virtual std::function< std::string(double)> control_gen (const std::string &control_name) const =0
 Get a function to convert a control into a sysfs string. More...
 
virtual std::string driver (void) const =0
 
virtual std::map< std::string, SysfsDriver::properties_sproperties (void) const =0
 Query the meta data about a signal or control. More...
 

Static Public Member Functions

static std::map< std::string, SysfsDriver::properties_sparse_properties_json (const std::string &iogroup_name, const std::string &properties_json)
 

Static Public Attributes

static constexpr size_t M_IO_BUFFER_SIZE = 128
 Arbitrary buffer size. More...
 

Detailed Description

Class used to implement the SysfsIOGroup base class.

This virtual interface can be adapted for each Linux device driver. A concrete implementation can be used to construct a SysfsIOGroup object.

Constructor & Destructor Documentation

◆ SysfsDriver()

geopm::SysfsDriver::SysfsDriver ( )
default

◆ ~SysfsDriver()

virtual geopm::SysfsDriver::~SysfsDriver ( )
virtualdefault

Member Function Documentation

◆ attribute_path()

virtual std::string geopm::SysfsDriver::attribute_path ( const std::string &  name,
int  domain_idx 
)
pure virtual

Get the path to the sysfs entry for signal.

Parameters
[in]nameThe name of the signal or control
[in]domain_idxThe index of the domain within the set of domains of the same type on the platform.
Returns
File path to the sysfs entry to be read.

Implemented in geopm::DrmSysfsDriver, and geopm::CpufreqSysfsDriver.

◆ control_gen()

virtual std::function<std::string(double)> geopm::SysfsDriver::control_gen ( const std::string &  control_name) const
pure virtual

Get a function to convert a control into a sysfs string.

Converts from the SI unit control into the text representation required by the device driver.

Parameters
[in]signal_nameThe name of the signal.
Returns
Function returning string content to be written to sysfs file.

Implemented in geopm::DrmSysfsDriver, and geopm::CpufreqSysfsDriver.

◆ domain_type()

virtual int geopm::SysfsDriver::domain_type ( const std::string &  name) const
pure virtual

Get the PlatformTopo domain type for an named attribute.

Parameters
[in]nameThe name of the signal or control
Returns
geopm_domain_e domain type

Implemented in geopm::DrmSysfsDriver, and geopm::CpufreqSysfsDriver.

◆ driver()

virtual std::string geopm::SysfsDriver::driver ( void  ) const
pure virtual

Name of the Linux kernel device driver

Returns
Name of device driver

Implemented in geopm::DrmSysfsDriver, and geopm::CpufreqSysfsDriver.

◆ parse_properties_json()

std::map< std::string, SysfsDriver::properties_s > geopm::SysfsDriver::parse_properties_json ( const std::string &  iogroup_name,
const std::string &  properties_json 
)
static

◆ properties()

virtual std::map<std::string, SysfsDriver::properties_s> geopm::SysfsDriver::properties ( void  ) const
pure virtual

Query the meta data about a signal or control.

Implemented in geopm::DrmSysfsDriver, and geopm::CpufreqSysfsDriver.

◆ signal_parse()

virtual std::function<double(const std::string&)> geopm::SysfsDriver::signal_parse ( const std::string &  signal_name) const
pure virtual

Get function to convert contents of sysfs file into signal.

This parsing includes the conversion of the numerical data into SI units.

Parameters
[in]properties_idThe unique identifier of the signal.
[in]contentThe string content read from the sysfs file.
Returns
The parsed signal value in SI units.

Implemented in geopm::DrmSysfsDriver, and geopm::CpufreqSysfsDriver.

Member Data Documentation

◆ M_IO_BUFFER_SIZE

constexpr size_t geopm::SysfsDriver::M_IO_BUFFER_SIZE = 128
staticconstexpr

Arbitrary buffer size.

We're generally looking at integer values much shorter than 100 digits in length. The IOGroup performs string truncation checks in case that ever changes.


The documentation for this class was generated from the following files: