geopm  3.1.1.dev272+gdfb40a8d
GEOPM - Global Extensible Open Power Manager
ServiceProxy.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - 2024 Intel Corporation
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef SERVICEPROXY_HPP_INCLUDE
7 #define SERVICEPROXY_HPP_INCLUDE
8 
9 #include <memory>
10 #include <string>
11 #include <vector>
12 
13 #include "geopm_public.h"
14 
15 struct geopm_request_s;
16 
17 namespace geopm
18 {
19  class SDBus;
20  class SDBusMessage;
21 
26  std::string name;
28  std::string description;
31  int domain;
42  int behavior;
43  };
44 
49  std::string name;
51  std::string description;
54  int domain;
55  };
56 
60  {
61  public:
63  ServiceProxy() = default;
65  virtual ~ServiceProxy() = default;
68  static std::unique_ptr<ServiceProxy> make_unique(void);
78  std::vector<std::string> &signal_names,
79  std::vector<std::string> &control_names) = 0;
86  virtual std::vector<signal_info_s> platform_get_signal_info(
87  const std::vector<std::string> &signal_names) = 0;
94  virtual std::vector<control_info_s> platform_get_control_info(
95  const std::vector<std::string> &control_names) = 0;
98  virtual void platform_open_session(void) = 0;
101  virtual void platform_close_session(void) = 0;
114  virtual void platform_start_batch(
115  const std::vector<struct geopm_request_s> &signal_config,
116  const std::vector<struct geopm_request_s> &control_config,
117  int &server_pid,
118  std::string &server_key) = 0;
123  virtual void platform_stop_batch(int server_pid) = 0;
133  virtual double platform_read_signal(const std::string &signal_name,
134  int domain,
135  int domain_idx) = 0;
145  virtual void platform_write_control(const std::string &control_name,
146  int domain,
147  int domain_idx,
148  double setting) = 0;
151  virtual void platform_restore_control() = 0;
155  virtual std::string topo_get_cache(void) = 0;
156  virtual void platform_start_profile(const std::string &profile_name) = 0;
157  virtual void platform_stop_profile(const std::vector<std::string> &region_names) = 0;
158  virtual std::vector<int> platform_get_profile_pids(const std::string &profile_name) = 0;
159  virtual std::vector<std::string> platform_pop_profile_region_names(const std::string &profile_name) = 0;
160  };
161 
163  {
164  public:
165  ServiceProxyImp();
166  ServiceProxyImp(std::shared_ptr<SDBus> bus);
167  virtual ~ServiceProxyImp() = default;
168  void platform_get_user_access(std::vector<std::string> &signal_names,
169  std::vector<std::string> &control_names) override;
170  std::vector<signal_info_s> platform_get_signal_info(const std::vector<std::string> &signal_names) override;
171  std::vector<control_info_s> platform_get_control_info(const std::vector<std::string> &control_names) override;
172  void platform_open_session(void) override;
173  void platform_close_session(void) override;
174  void platform_start_batch(const std::vector<struct geopm_request_s> &signal_config,
175  const std::vector<struct geopm_request_s> &control_config,
176  int &server_pid,
177  std::string &server_key) override;
178  void platform_stop_batch(int server_pid) override;
179  double platform_read_signal(const std::string &signal_name,
180  int domain,
181  int domain_idx) override;
182  void platform_write_control(const std::string &control_name,
183  int domain,
184  int domain_idx,
185  double setting) override;
186  void platform_restore_control() override;
187  std::string topo_get_cache(void) override;
188  void platform_start_profile(const std::string &profile_name) override;
189  void platform_stop_profile(const std::vector<std::string> &region_names) override;
190  std::vector<int> platform_get_profile_pids(const std::string &profile_name) override;
191  std::vector<std::string> platform_pop_profile_region_names(const std::string &profile_name) override;
192  private:
193  std::vector<std::string> GEOPM_PRIVATE
194  read_string_array(std::shared_ptr<SDBusMessage> bus_message);
195  std::shared_ptr<SDBus> m_bus;
196  };
197 }
198 
199 #endif
Proxy object for the io.github.geopm D-Bus interface used to implement the ServiceIOGroup.
Definition: ServiceProxy.hpp:60
virtual void platform_stop_profile(const std::vector< std::string > &region_names)=0
virtual void platform_get_user_access(std::vector< std::string > &signal_names, std::vector< std::string > &control_names)=0
Calls the PlatformGetUserAccess API defined in the io.github.geopm D-Bus namespace.
ServiceProxy()=default
ServiceProxy constructor.
virtual std::string topo_get_cache(void)=0
Calls the TopoGetCache API defined in the io.github.geopm D-Bus namespace.
virtual void platform_start_batch(const std::vector< struct geopm_request_s > &signal_config, const std::vector< struct geopm_request_s > &control_config, int &server_pid, std::string &server_key)=0
Calls the PlatformStartBatch API defined in the io.github.geopm D-Bus namespace.
virtual void platform_start_profile(const std::string &profile_name)=0
virtual void platform_restore_control()=0
Calls the PlatformRestoreControl API defined in the io.github.geopm D-Bus namespace.
virtual std::vector< signal_info_s > platform_get_signal_info(const std::vector< std::string > &signal_names)=0
Calls the PlatformGetSignalInfo API defined in the io.github.geopm D-Bus namespace.
virtual void platform_stop_batch(int server_pid)=0
Calls the PlatformStopBatch API defined in the io.github.geopm D-Bus namespace.
virtual ~ServiceProxy()=default
ServiceProxy destructor.
virtual double platform_read_signal(const std::string &signal_name, int domain, int domain_idx)=0
Calls the PlatformReadSignal API defined in the io.github.geopm D-Bus namespace.
virtual void platform_open_session(void)=0
Calls the PlatformOpenSession API defined in the io.github.geopm D-Bus namespace.
virtual void platform_write_control(const std::string &control_name, int domain, int domain_idx, double setting)=0
Calls the PlatformWriteControl API defined in the io.github.geopm D-Bus namespace.
virtual std::vector< std::string > platform_pop_profile_region_names(const std::string &profile_name)=0
virtual std::vector< int > platform_get_profile_pids(const std::string &profile_name)=0
virtual std::vector< control_info_s > platform_get_control_info(const std::vector< std::string > &control_names)=0
Calls the PlatformGetControlInfo API defined in the io.github.geopm D-Bus namespace.
virtual void platform_close_session(void)=0
Calls the PlatformCloseSession API defined in the io.github.geopm D-Bus namespace.
Definition: ServiceProxy.hpp:163
virtual ~ServiceProxyImp()=default
#define GEOPM_PUBLIC
Definition: geopm_public.h:10
#define GEOPM_PRIVATE
Definition: geopm_public.h:15
Definition: Agg.cpp:20
std::unique_ptr< Type > make_unique(Args &&...args)
Implementation of std::make_unique (C++14) for C++11. Note that this version will only work for non-a...
Definition: Helper.hpp:28
Information pertaining to a particular control supported by PlatformIO.
Definition: ServiceProxy.hpp:47
std::string name
Name of the control.
Definition: ServiceProxy.hpp:49
std::string description
Description of the control.
Definition: ServiceProxy.hpp:51
int domain
Topology domain that supports the signal. One of the geopm_domain_e values defined in geopm_topo....
Definition: ServiceProxy.hpp:54
Information pertaining to a particular signal supported by PlatformIO.
Definition: ServiceProxy.hpp:24
int domain
Topology domain that supports the signal. One of the geopm_domain_e values defined in geopm_topo....
Definition: ServiceProxy.hpp:31
int string_format
The format method to convert a signal to a string. One of the geopm::string_format_e values defined i...
Definition: ServiceProxy.hpp:38
std::string name
Name of the signal.
Definition: ServiceProxy.hpp:26
int behavior
The signal behavior type. One of the geopm::IOGroup::m_signal_behavior_e values defined in geopm/IOGr...
Definition: ServiceProxy.hpp:42
std::string description
Description of the signal.
Definition: ServiceProxy.hpp:28
int aggregation
The signal aggregation type. One of the the geopm::Agg::m_type_e values defined in geopm/Agg....
Definition: ServiceProxy.hpp:34
Definition: geopm_pio.h:387