geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
Public Member Functions | Static Public Member Functions | List of all members
geopm::SDBus Class Referenceabstract

Abstraction around sd_bus interface for calling methods. More...

#include <SDBus.hpp>

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

Public Member Functions

 SDBus ()=default
 
virtual ~SDBus ()=default
 
virtual std::shared_ptr< SDBusMessagecall_method (std::shared_ptr< SDBusMessage > message)=0
 Wrapper for the sd_bus_call(3) function. More...
 
virtual std::shared_ptr< SDBusMessagecall_method (const std::string &member)=0
 Wrapper for the sd_bus_call_method(3) function. More...
 
virtual std::shared_ptr< SDBusMessagecall_method (const std::string &member, const std::string &arg0, int arg1, int arg2)=0
 Wrapper for the sd_bus_call_method(3) function. More...
 
virtual std::shared_ptr< SDBusMessagecall_method (const std::string &member, const std::string &arg0, int arg1, int arg2, double arg3)=0
 Wrapper for the sd_bus_call_method(3) function. More...
 
virtual std::shared_ptr< SDBusMessagecall_method (const std::string &member, int arg0)=0
 Wrapper for the sd_bus_call_method(3) function. More...
 
virtual std::shared_ptr< SDBusMessagemake_call_message (const std::string &member)=0
 Wrapper for the sd_bus_message_new_method_call(3) function. More...
 
virtual std::shared_ptr< SDBusMessagecall_method (const std::string &member, const std::string &arg0)=0
 

Static Public Member Functions

static std::unique_ptr< SDBusmake_unique (void)
 Factory method for SDBus interface. More...
 

Detailed Description

Abstraction around sd_bus interface for calling methods.

A mock-able C++ interface wrapper around the sd_bus functions that initiate calls to GEOPM D-Bus methods. The sd_bus functions are provided by the libsystemd.so library and defined int the systemd/sd-bus.h" header file. The messages passed to and from these calls are abstracted by the SDBusMessage interface. The SDBus method syntax reflects the syntax of the underlying sd_bus interface, and for further information look at the sd-bus(3) man page and links therein.

Constructor & Destructor Documentation

◆ SDBus()

geopm::SDBus::SDBus ( )
default

◆ ~SDBus()

virtual geopm::SDBus::~SDBus ( )
virtualdefault

Member Function Documentation

◆ call_method() [1/6]

virtual std::shared_ptr<SDBusMessage> geopm::SDBus::call_method ( const std::string &  member)
pure virtual

Wrapper for the sd_bus_call_method(3) function.

Used to execute a GEOPM D-Bus API that takes no arguments.

Parameters
member[in] Name of the API from the io.github.geopm interface.
Returns
Reply message that resulted from the call.

Implemented in geopm::SDBusImp.

◆ call_method() [2/6]

virtual std::shared_ptr<SDBusMessage> geopm::SDBus::call_method ( const std::string &  member,
const std::string &  arg0 
)
pure virtual

Implemented in geopm::SDBusImp.

◆ call_method() [3/6]

virtual std::shared_ptr<SDBusMessage> geopm::SDBus::call_method ( const std::string &  member,
const std::string &  arg0,
int  arg1,
int  arg2 
)
pure virtual

Wrapper for the sd_bus_call_method(3) function.

Used to execute a GEOPM D-Bus API that takes three arguments with types (string, integer, integer).

Parameters
member[in] Name of the API from the io.github.geopm interface.
arg0[in] First parameter to pass to the D-Bus API.
arg1[in] Second parameter to pass to the D-Bus API.
arg2[in] Third parameter to pass to the D-Bus API.
Returns
Reply message that resulted from the call.

Implemented in geopm::SDBusImp.

◆ call_method() [4/6]

virtual std::shared_ptr<SDBusMessage> geopm::SDBus::call_method ( const std::string &  member,
const std::string &  arg0,
int  arg1,
int  arg2,
double  arg3 
)
pure virtual

Wrapper for the sd_bus_call_method(3) function.

Used to execute a GEOPM D-Bus API that takes four arguments with types (string, integer, integer, double).

Parameters
member[in] Name of the API from the io.github.geopm interface.
arg0[in] First parameter to pass to the D-Bus API.
arg1[in] Second parameter to pass to the D-Bus API.
arg2[in] Third parameter to pass to the D-Bus API.
arg2[in] Fourth parameter to pass to the D-Bus API.
Returns
Reply message that resulted from the call.

Implemented in geopm::SDBusImp.

◆ call_method() [5/6]

virtual std::shared_ptr<SDBusMessage> geopm::SDBus::call_method ( const std::string &  member,
int  arg0 
)
pure virtual

Wrapper for the sd_bus_call_method(3) function.

Used to execute a GEOPM D-Bus API that takes one integer argument.

Parameters
member[in] Name of the API from the io.github.geopm interface.
arg0[in] First parameter to pass to the D-Bus API.
Returns
Reply message that resulted from the call.

Implemented in geopm::SDBusImp.

◆ call_method() [6/6]

virtual std::shared_ptr<SDBusMessage> geopm::SDBus::call_method ( std::shared_ptr< SDBusMessage message)
pure virtual

Wrapper for the sd_bus_call(3) function.

Used to execute a GEOPM D-Bus API using an SDBusMessage created by the make_call_message() method. This enables the user to update the message with complex data types like arrays and structs to pass into the method.

One use case is to to pass lists of strings as inputs to GEOPM D-Bus APIs. The SDBusMessage that is created by make_call_message() is updated using SDBusMessage::append_strings() prior to passing the SDBusMessage to the call() method.

Parameters
message[in] Complete SDBusMessage returned by call to make_call_message().
Returns
Reply message that resulted from the call.

Implemented in geopm::SDBusImp.

◆ make_call_message()

virtual std::shared_ptr<SDBusMessage> geopm::SDBus::make_call_message ( const std::string &  member)
pure virtual

Wrapper for the sd_bus_message_new_method_call(3) function.

This is used to create a SDBusMessage that can be passed to the call() method. The user can append data to the message prior to passing the result to the call() method in order to send complex data types like arrays and structures. The D-Bus API that will be called later is a parameter to this function.

Parameters
member[in] Name of the API from the io.github.geopm interface.
Returns
Complete message that can be passed to the call() method.

Implemented in geopm::SDBusImp.

◆ make_unique()

std::unique_ptr< SDBus > geopm::SDBus::make_unique ( void  )
static

Factory method for SDBus interface.

Returns
Unique pointer to an implementation of the SDBus interface.

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