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

Abstraction around sd_bus interfaces that read from or append to sd_bus_message types. More...

#include <SDBusMessage.hpp>

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

Public Member Functions

 SDBusMessage ()=default
 
virtual ~SDBusMessage ()=default
 
virtual sd_bus_message * get_sd_ptr (void)=0
 Get raw pointer to sd_bus struct. More...
 
virtual void enter_container (char type, const std::string &contents)=0
 Enter a container in the message for reading. More...
 
virtual void exit_container (void)=0
 Exit a container in the message for reading. More...
 
virtual void open_container (char type, const std::string &contents)=0
 Open a container in the message for writing. More...
 
virtual void close_container (void)=0
 Close a container in the message for writing. More...
 
virtual std::string read_string (void)=0
 Read a string out of the message. More...
 
virtual double read_double (void)=0
 Read a double out of the message. More...
 
virtual int read_integer (void)=0
 Read an integer out of the message. More...
 
virtual void append_strings (const std::vector< std::string > &write_values)=0
 Write an array of strings into the message. More...
 
virtual void append_request (const geopm_request_s &request)=0
 Write an array of geopm_request_s into the message. More...
 
virtual bool was_success (void)=0
 Determine if end of array has been reached. More...
 

Static Public Member Functions

static std::unique_ptr< SDBusMessagemake_unique (sd_bus_message *bus_message)
 Factory method for SDBusMessage interface. More...
 

Static Public Attributes

static const char M_MESSAGE_TYPE_STRUCT = SD_BUS_TYPE_STRUCT
 Used with enter_container() method to specify a structure container. More...
 
static const char M_MESSAGE_TYPE_ARRAY = SD_BUS_TYPE_ARRAY
 Used with enter_container() method to specify an array container. More...
 

Detailed Description

Abstraction around sd_bus interfaces that read from or append to sd_bus_message types.

A mock-able C++ interface wrapper around the sd_bus functions that read or modify messages. To read messages methods can enter or exit containers, as well as reading strings, doubles and integers. The abstraction also enables appending a list of strings to a container to write to the message.

Constructor & Destructor Documentation

◆ SDBusMessage()

geopm::SDBusMessage::SDBusMessage ( )
default

◆ ~SDBusMessage()

virtual geopm::SDBusMessage::~SDBusMessage ( )
virtualdefault

Member Function Documentation

◆ append_request()

virtual void geopm::SDBusMessage::append_request ( const geopm_request_s request)
pure virtual

Write an array of geopm_request_s into the message.

Wrapper around the "sd_bus_message_append(3)" function.

Parameters
[in]Vectorof geopm_request_s to write into the message as an array.

Implemented in geopm::SDBusMessageImp.

◆ append_strings()

virtual void geopm::SDBusMessage::append_strings ( const std::vector< std::string > &  write_values)
pure virtual

Write an array of strings into the message.

Wrapper around the "sd_bus_message_append_strv(3)" function.

Parameters
[in]Vectorof strings to write into the message as an array.

Implemented in geopm::SDBusMessageImp.

◆ close_container()

virtual void geopm::SDBusMessage::close_container ( void  )
pure virtual

Close a container in the message for writing.

Wrapper around sd_bus_message_close_open_container(3)

Implemented in geopm::SDBusMessageImp.

◆ enter_container()

virtual void geopm::SDBusMessage::enter_container ( char  type,
const std::string &  contents 
)
pure virtual

Enter a container in the message for reading.

Wrapper around sd_bus_message_enter_container(3) function.

Parameters
type[in] One of M_MESSAGE_TYPE_STRUCT or M_MESSAGE_TYPE_ARRAY which map to the related char values defined in "sd-bus.h".
contents[in] The sd_bus string expression that describes the data types in the message.

Implemented in geopm::SDBusMessageImp.

◆ exit_container()

virtual void geopm::SDBusMessage::exit_container ( void  )
pure virtual

Exit a container in the message for reading.

Wrapper around sd_bus_message_exit_container(3) function.

Implemented in geopm::SDBusMessageImp.

◆ get_sd_ptr()

virtual sd_bus_message* geopm::SDBusMessage::get_sd_ptr ( void  )
pure virtual

Get raw pointer to sd_bus struct.

This value can be used to make sd_bus interface calls that require the raw pointer in the SDBus class.

Returns
Pointer used to construct the object.

Implemented in geopm::SDBusMessageImp.

◆ make_unique()

std::unique_ptr< SDBusMessage > geopm::SDBusMessage::make_unique ( sd_bus_message *  bus_message)
static

Factory method for SDBusMessage interface.

Returns
Unique pointer to an implementation of the SDBusMessage interface.

◆ open_container()

virtual void geopm::SDBusMessage::open_container ( char  type,
const std::string &  contents 
)
pure virtual

Open a container in the message for writing.

Wrapper around sd_bus_message_open_container(3)

Parameters
type[in] One of M_MESSAGE_TYPE_STRUCT or M_MESSAGE_TYPE_ARRAY which map to the related char values defined in "sd-bus.h".
contents[in] The sd_bus string expression that describes the data types in the message.

Implemented in geopm::SDBusMessageImp.

◆ read_double()

virtual double geopm::SDBusMessage::read_double ( void  )
pure virtual

Read a double out of the message.

Wrapper around the "sd_bus_message_read(3)" function.

Returns
The double that is next in the message.

Implemented in geopm::SDBusMessageImp.

◆ read_integer()

virtual int geopm::SDBusMessage::read_integer ( void  )
pure virtual

Read an integer out of the message.

Wrapper around the "sd_bus_message_read(3)" function.

Returns
The integer that is next in the message.

Implemented in geopm::SDBusMessageImp.

◆ read_string()

virtual std::string geopm::SDBusMessage::read_string ( void  )
pure virtual

Read a string out of the message.

Wrapper around the "sd_bus_message_read(3)" function.

Returns
The string that is next in the message.

Implemented in geopm::SDBusMessageImp.

◆ was_success()

virtual bool geopm::SDBusMessage::was_success ( void  )
pure virtual

Determine if end of array has been reached.

When iterating through an array container, the was_success() method can be used to determine if the last read from the container was successful. After a read from an array was successful the was_success() will return true, and if the end of the array has been reached, was_success() will return false. The return value from a read from an array container that was unsuccessful should be ignored.

Returns
Will return true if last read from object was successful and false otherwise.

Implemented in geopm::SDBusMessageImp.

Member Data Documentation

◆ M_MESSAGE_TYPE_ARRAY

const char geopm::SDBusMessage::M_MESSAGE_TYPE_ARRAY = SD_BUS_TYPE_ARRAY
static

Used with enter_container() method to specify an array container.

◆ M_MESSAGE_TYPE_STRUCT

const char geopm::SDBusMessage::M_MESSAGE_TYPE_STRUCT = SD_BUS_TYPE_STRUCT
static

Used with enter_container() method to specify a structure container.


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