17136a5aeSJames Feist /* 27136a5aeSJames Feist // Copyright (c) 2018 Intel Corporation 37136a5aeSJames Feist // 47136a5aeSJames Feist // Licensed under the Apache License, Version 2.0 (the "License"); 57136a5aeSJames Feist // you may not use this file except in compliance with the License. 67136a5aeSJames Feist // You may obtain a copy of the License at 77136a5aeSJames Feist // 87136a5aeSJames Feist // http://www.apache.org/licenses/LICENSE-2.0 97136a5aeSJames Feist // 107136a5aeSJames Feist // Unless required by applicable law or agreed to in writing, software 117136a5aeSJames Feist // distributed under the License is distributed on an "AS IS" BASIS, 127136a5aeSJames Feist // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137136a5aeSJames Feist // See the License for the specific language governing permissions and 147136a5aeSJames Feist // limitations under the License. 157136a5aeSJames Feist */ 167136a5aeSJames Feist 177136a5aeSJames Feist #pragma once 187136a5aeSJames Feist 19da4a5dd1SPatrick Venture #include "interfaces.hpp" 20*0c8223b5SJames Feist #include "util.hpp" 217136a5aeSJames Feist 22f5e770b3SPatrick Venture #include <memory> 237136a5aeSJames Feist #include <sdbusplus/bus.hpp> 24da4a5dd1SPatrick Venture #include <string> 257136a5aeSJames Feist 267136a5aeSJames Feist class DbusWritePercent : public WriteInterface 277136a5aeSJames Feist { 287136a5aeSJames Feist public: 29f5e770b3SPatrick Venture static std::unique_ptr<WriteInterface> 30f5e770b3SPatrick Venture createDbusWrite(const std::string& path, int64_t min, int64_t max, 31f5e770b3SPatrick Venture DbusHelperInterface& helper); 32f5e770b3SPatrick Venture 337136a5aeSJames Feist DbusWritePercent(const std::string& path, int64_t min, int64_t max, 34f5e770b3SPatrick Venture const std::string& connectionName) : 357136a5aeSJames Feist WriteInterface(min, max), 36f5e770b3SPatrick Venture path(path), connectionName(connectionName) 377136a5aeSJames Feist { 387136a5aeSJames Feist } 397136a5aeSJames Feist 407136a5aeSJames Feist void write(double value) override; 417136a5aeSJames Feist 427136a5aeSJames Feist private: 437136a5aeSJames Feist std::string path; 447136a5aeSJames Feist std::string connectionName; 45cd9e109fSJames Feist int64_t oldValue = -1; 467136a5aeSJames Feist }; 477136a5aeSJames Feist 487136a5aeSJames Feist class DbusWrite : public WriteInterface 497136a5aeSJames Feist { 507136a5aeSJames Feist public: 51f5e770b3SPatrick Venture static std::unique_ptr<WriteInterface> 52f5e770b3SPatrick Venture createDbusWrite(const std::string& path, int64_t min, int64_t max, 53f5e770b3SPatrick Venture DbusHelperInterface& helper); 54f5e770b3SPatrick Venture 557136a5aeSJames Feist DbusWrite(const std::string& path, int64_t min, int64_t max, 56f5e770b3SPatrick Venture const std::string& connectionName) : 577136a5aeSJames Feist WriteInterface(min, max), 58f5e770b3SPatrick Venture path(path), connectionName(connectionName) 597136a5aeSJames Feist { 607136a5aeSJames Feist } 617136a5aeSJames Feist 627136a5aeSJames Feist void write(double value) override; 637136a5aeSJames Feist 647136a5aeSJames Feist private: 657136a5aeSJames Feist std::string path; 667136a5aeSJames Feist std::string connectionName; 67cd9e109fSJames Feist int64_t oldValue = -1; 687136a5aeSJames Feist }; 69