geopm  3.1.1.dev272+gdfb40a8d
GEOPM - Global Extensible Open Power Manager
EndpointUser.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 ENDPOINTUSER_HPP_INCLUDE
7 #define ENDPOINTUSER_HPP_INCLUDE
8 
9 #include <cstddef>
10 
11 #include <vector>
12 #include <string>
13 #include <set>
14 #include <memory>
15 
16 namespace geopm
17 {
19  {
20  public:
21  EndpointUser() = default;
22  virtual ~EndpointUser() = default;
28  virtual double read_policy(std::vector<double> &policy) = 0;
32  virtual void write_sample(const std::vector<double> &sample) = 0;
35  static std::unique_ptr<EndpointUser> make_unique(const std::string &policy_path,
36  const std::set<std::string> &hosts);
37  };
38 
39  class SharedMemory;
40 
42  {
43  public:
44  EndpointUserImp() = delete;
45  EndpointUserImp &operator=(const EndpointUserImp &other) = delete;
46  EndpointUserImp(const EndpointUserImp &other) = delete;
47  EndpointUserImp(const std::string &data_path,
48  const std::set<std::string> &hosts);
49  EndpointUserImp(const std::string &data_path,
50  std::unique_ptr<SharedMemory> policy_shmem,
51  std::unique_ptr<SharedMemory> sample_shmem,
52  const std::string &agent_name,
53  int num_sample,
54  const std::string &profile_name,
55  const std::string &hostlist_path,
56  const std::set<std::string> &hosts);
57  virtual ~EndpointUserImp();
58  double read_policy(std::vector<double> &policy) override;
59  void write_sample(const std::vector<double> &sample) override;
60  private:
61  std::string m_path;
62  std::unique_ptr<SharedMemory> m_policy_shmem;
63  std::unique_ptr<SharedMemory> m_sample_shmem;
64  std::string m_hostlist_path;
65  size_t m_num_sample;
66  };
67 }
68 
69 #endif
Definition: EndpointUser.hpp:19
virtual double read_policy(std::vector< double > &policy)=0
Read the latest policy values. All NAN indicates that a policy has not been written yet.
virtual ~EndpointUser()=default
EndpointUser()=default
virtual void write_sample(const std::vector< double > &sample)=0
Write sample values and update the sample age.
static std::unique_ptr< EndpointUser > make_unique(const std::string &policy_path, const std::set< std::string > &hosts)
Factory method for the EndpointUser receiving the policy.
Definition: EndpointUser.cpp:24
Definition: EndpointUser.hpp:42
double read_policy(std::vector< double > &policy) override
Read the latest policy values. All NAN indicates that a policy has not been written yet.
Definition: EndpointUser.cpp:113
EndpointUserImp & operator=(const EndpointUserImp &other)=delete
void write_sample(const std::vector< double > &sample) override
Write sample values and update the sample age.
Definition: EndpointUser.cpp:130
EndpointUserImp(const EndpointUserImp &other)=delete
virtual ~EndpointUserImp()
Definition: EndpointUser.cpp:102
Definition: Accumulator.cpp:12