Cypress  1.0
C++ Spiking Neural Network Simulation Framework
power.hpp
Go to the documentation of this file.
1 /*
2  * Cypress -- C++ Spiking Neural Network Simulation Framework
3  * Copyright (C) 2016 Andreas Stöckel
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
28 #pragma once
29 
30 #ifndef CYPRESS_BACKEND_POWER_POWER_HPP
31 #define CYPRESS_BACKEND_POWER_POWER_HPP
32 
33 #include <memory>
34 #include <stdexcept>
35 #include <string>
36 #include <vector>
37 
38 #include <cypress/core/backend.hpp>
39 
40 namespace cypress {
45 class PowerDevice {
46 public:
47  virtual ~PowerDevice(){};
48 
49  virtual bool has_config() = 0;
50 
60  virtual bool state(const std::string &device) = 0;
61 
69  virtual bool switch_on(const std::string &device) = 0;
70 
78  virtual bool switch_off(const std::string &device) = 0;
79 };
80 
93 private:
94  std::shared_ptr<PowerDevice> m_device;
95  std::unique_ptr<Backend> m_backend;
96 
100  void do_run(NetworkBase &network, Real duration) const override;
101 
102 public:
110  PowerManagementBackend(std::shared_ptr<PowerDevice> device,
111  std::unique_ptr<Backend> backend);
112 
113  PowerManagementBackend(std::unique_ptr<Backend> backend,
114  const std::string &config_filename = "");
115 
119  ~PowerManagementBackend() override;
120 
124  std::unordered_set<const NeuronType *> supported_neuron_types()
125  const override
126  {
127  return m_backend->supported_neuron_types();
128  }
129 
134  std::string name() const override { return m_backend->name(); }
135 };
136 } // namespace cypress
137 
138 #endif /* CYPRESS_BACKEND_POWER_POWER_HPP */
std::unordered_set< const NeuronType * > supported_neuron_types() const override
Definition: power.hpp:124
virtual bool switch_off(const std::string &device)=0
Definition: backend.hpp:50
double Real
Definition: types.hpp:56
virtual bool state(const std::string &device)=0
Definition: network_base.hpp:116
std::string name() const override
Definition: power.hpp:134
virtual bool has_config()=0
Definition: brainscales_lib.hpp:39
Definition: power.hpp:45
Definition: power.hpp:92
virtual ~PowerDevice()
Definition: power.hpp:47
virtual bool switch_on(const std::string &device)=0