dbusactiveread: delete unused class
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I52ae5968f0d10d6eae04fea9b96e38df6f226b0c
diff --git a/dbus/dbusactiveread.cpp b/dbus/dbusactiveread.cpp
deleted file mode 100644
index 3d0ed79..0000000
--- a/dbus/dbusactiveread.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright 2017 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "dbusactiveread.hpp"
-
-#include "dbushelper_interface.hpp"
-#include "util.hpp"
-
-#include <chrono>
-#include <cmath>
-#include <iostream>
-
-namespace pid_control
-{
-
-ReadReturn DbusActiveRead::read(void)
-{
- SensorProperties settings;
- double value;
-
- _helper->getProperties(_service, _path, &settings);
-
- value = settings.value * pow(10, settings.scale);
-
- /*
- * Technically it might not be a value from now, but there's no timestamp
- * on Sensor.Value yet.
- */
- ReadReturn r = {value, std::chrono::high_resolution_clock::now()};
-
- return r;
-}
-
-} // namespace pid_control
diff --git a/dbus/dbusactiveread.hpp b/dbus/dbusactiveread.hpp
deleted file mode 100644
index 9a80e0e..0000000
--- a/dbus/dbusactiveread.hpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#pragma once
-
-#include "dbushelper_interface.hpp"
-#include "interfaces.hpp"
-#include "util.hpp"
-
-#include <sdbusplus/bus.hpp>
-
-#include <memory>
-#include <string>
-
-namespace pid_control
-{
-
-/*
- * This ReadInterface will actively reach out over dbus upon calling read to
- * get the value from whomever owns the associated dbus path.
- */
-class DbusActiveRead : public ReadInterface
-{
- public:
- DbusActiveRead(sdbusplus::bus_t& bus, const std::string& path,
- const std::string& service,
- std::unique_ptr<DbusHelperInterface> helper) :
- ReadInterface(), _bus(bus), _path(path), _service(service),
- _helper(std::move(helper))
- {}
-
- ReadReturn read(void) override;
-
- private:
- // Inform the compiler that this variable might not be used,
- // which suppresses the warning "private field '_bus' is not used"
- [[maybe_unused]] sdbusplus::bus_t& _bus;
- const std::string _path;
- const std::string _service; // the sensor service.
- std::unique_ptr<DbusHelperInterface> _helper;
-};
-
-} // namespace pid_control
diff --git a/meson.build b/meson.build
index 06c9404..13d6175 100644
--- a/meson.build
+++ b/meson.build
@@ -114,7 +114,6 @@
'dbus/dbushelper.cpp',
'dbus/dbuspassiveredundancy.cpp',
'dbus/dbuspassive.cpp',
- 'dbus/dbusactiveread.cpp',
'dbus/dbuswrite.cpp',
'failsafeloggers/builder.cpp',
'failsafeloggers/failsafe_logger_utility.cpp',
diff --git a/test/dbus_active_unittest.cpp b/test/dbus_active_unittest.cpp
deleted file mode 100644
index c9f663e..0000000
--- a/test/dbus_active_unittest.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "dbus/dbusactiveread.hpp"
-#include "test/dbushelper_mock.hpp"
-
-#include <sdbusplus/test/sdbus_mock.hpp>
-
-#include <memory>
-#include <string>
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-namespace pid_control
-{
-namespace
-{
-
-using ::testing::_;
-using ::testing::Invoke;
-using ::testing::NotNull;
-
-TEST(DbusActiveReadTest, BoringConstructorTest)
-{
- // Verify we can construct it.
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
- auto helper = std::make_unique<DbusHelperMock>();
- std::string path = "/asdf";
- std::string service = "asdfasdf.asdfasdf";
-
- DbusActiveRead ar(bus_mock, path, service, std::move(helper));
-}
-
-TEST(DbusActiveReadTest, Read_VerifyCallsToDbusForValue)
-{
- // Verify it calls to get the value from dbus when requested.
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
- auto helper = std::make_unique<DbusHelperMock>();
- std::string path = "/asdf";
- std::string service = "asdfasdf.asdfasdf";
-
- EXPECT_CALL(*helper, getProperties(service, path, NotNull()))
- .WillOnce(Invoke([&]([[maybe_unused]] const std::string& service,
- [[maybe_unused]] const std::string& path,
- SensorProperties* prop) {
- prop->scale = -3;
- prop->value = 10000;
- prop->unit = "x";
- }));
-
- DbusActiveRead ar(bus_mock, path, service, std::move(helper));
-
- ReadReturn r = ar.read();
- EXPECT_EQ(10, r.value);
-}
-
-// WARN: getProperties will raise an exception on failure
-// Instead of just not updating the value.
-
-} // namespace
-} // namespace pid_control
diff --git a/test/meson.build b/test/meson.build
index 69b883c..b1c93e9 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -20,7 +20,6 @@
swampd_sources = include_directories('../')
unit_tests = [
- 'dbus_active_unittest',
'dbus_passive_unittest',
'dbus_util_unittest',
'json_parse_unittest',
@@ -37,7 +36,6 @@
]
unittest_source = {
- 'dbus_active_unittest': ['../dbus/dbusactiveread.cpp'],
'dbus_passive_unittest': [
'../dbus/dbuspassive.cpp',
'../dbus/dbuspassiveredundancy.cpp',