1 /* 2 // Copyright (c) 2018 Intel Corporation 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 */ 16 17 #pragma once 18 19 #include "interfaces.hpp" 20 #include "util.hpp" 21 22 #include <sdbusplus/bus.hpp> 23 24 #include <memory> 25 #include <string> 26 27 class DbusWritePercent : public WriteInterface 28 { 29 public: 30 static std::unique_ptr<WriteInterface> 31 createDbusWrite(const std::string& path, int64_t min, int64_t max, 32 DbusHelperInterface& helper); 33 34 DbusWritePercent(const std::string& path, int64_t min, int64_t max, 35 const std::string& connectionName) : 36 WriteInterface(min, max), 37 path(path), connectionName(connectionName) 38 {} 39 40 void write(double value) override; 41 42 private: 43 std::string path; 44 std::string connectionName; 45 int64_t oldValue = -1; 46 }; 47 48 class DbusWrite : public WriteInterface 49 { 50 public: 51 static std::unique_ptr<WriteInterface> 52 createDbusWrite(const std::string& path, int64_t min, int64_t max, 53 DbusHelperInterface& helper); 54 55 DbusWrite(const std::string& path, int64_t min, int64_t max, 56 const std::string& connectionName) : 57 WriteInterface(min, max), 58 path(path), connectionName(connectionName) 59 {} 60 61 void write(double value) override; 62 63 private: 64 std::string path; 65 std::string connectionName; 66 int64_t oldValue = -1; 67 }; 68