control: Remove `json_parser` source
The `json_parser` source is no longer needed in the conversion to
support JSON based configurations.
Change-Id: Ie62ab3b1155f83ab71d1f5dbd768c97b80bbc9f4
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/Makefile.am b/control/Makefile.am
index 1088ce0..74f28dc 100644
--- a/control/Makefile.am
+++ b/control/Makefile.am
@@ -24,7 +24,6 @@
if WANT_JSON_CONTROL
phosphor_fan_control_SOURCES += \
- json_parser.cpp \
json/manager.cpp \
json/profile.cpp \
json/fan.cpp \
diff --git a/control/json_parser.cpp b/control/json_parser.cpp
deleted file mode 100644
index bdd99b3..0000000
--- a/control/json_parser.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright © 2020 IBM Corporation
- *
- * 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 "json_parser.hpp"
-
-#include "json/event.hpp"
-#include "json/fan.hpp"
-#include "json/group.hpp"
-#include "json/manager.hpp"
-#include "json/profile.hpp"
-#include "json/zone.hpp"
-#include "types.hpp"
-
-#include <sdbusplus/bus.hpp>
-
-#include <algorithm>
-#include <cstdlib>
-#include <string>
-#include <tuple>
-#include <vector>
-
-namespace phosphor::fan::control
-{
-
-bool checkEntry(const std::vector<std::string>& activeProfiles,
- const std::vector<std::string>& entryProfiles)
-{
- // Include entry if its list of profiles to be included in is empty
- if (entryProfiles.empty())
- {
- // Entry always to be included
- return true;
- }
- else
- {
- for (const auto& profile : activeProfiles)
- {
- auto iter =
- std::find(entryProfiles.begin(), entryProfiles.end(), profile);
- if (iter != entryProfiles.end())
- {
- // Entry configured to be included in active profile
- return true;
- }
- }
- }
- return false;
-}
-
-const unsigned int getPowerOnDelay(sdbusplus::bus::bus& bus,
- const sdeventplus::Event& event)
-{
- json::Manager mgr{bus, event};
- return mgr.getPowerOnDelay();
-}
-
-} // namespace phosphor::fan::control
diff --git a/control/json_parser.hpp b/control/json_parser.hpp
deleted file mode 100644
index a703ab6..0000000
--- a/control/json_parser.hpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * Copyright © 2020 IBM Corporation
- *
- * 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.
- */
-#pragma once
-
-#include "json_config.hpp"
-#include "types.hpp"
-
-#include <nlohmann/json.hpp>
-#include <sdbusplus/bus.hpp>
-
-#include <map>
-#include <memory>
-#include <utility>
-#include <vector>
-
-namespace phosphor::fan::control
-{
-
-/* Application name to be appended to the path for loading a JSON config file */
-constexpr auto confAppName = "control";
-
-/**
- * Configuration object key to uniquely map to the configuration object
- * Pair constructed of:
- * std::string = Configuration object's name
- * std::vector<std::string> = List of profiles the configuration object
- * is included in
- */
-using configKey = std::pair<std::string, std::vector<std::string>>;
-
-/**
- * @brief Load the configuration of a given JSON class object type that requires
- * a dbus object
- *
- * @param[in] bus - The dbus bus object
- * @param[in] isOptional - JSON configuration file is optional or not
- * Defaults to false
- *
- * @return Map of configuration entries
- * Map of configuration keys to their corresponding configuration object
- */
-template <typename T>
-std::map<configKey, std::unique_ptr<T>> getConfig(sdbusplus::bus::bus& bus,
- bool isOptional = false)
-{
- std::map<configKey, std::unique_ptr<T>> config;
-
- auto confFile = fan::JsonConfig::getConfFile(bus, confAppName,
- T::confFileName, isOptional);
- if (!confFile.empty())
- {
- for (const auto& entry : fan::JsonConfig::load(confFile))
- {
- auto obj = std::make_unique<T>(bus, entry);
- config.emplace(std::make_pair(obj->getName(), obj->getProfiles()),
- std::move(obj));
- }
- }
- return config;
-}
-
-/**
- * @brief Load the configuration of a given JSON class object type that does not
- * require a dbus object
- *
- * @param[in] isOptional - JSON configuration file is optional or not
- * Defaults to false
- *
- * @return Map of configuration entries
- * Map of configuration keys to their corresponding configuration object
- */
-template <typename T>
-std::map<configKey, std::unique_ptr<T>> getConfig(bool isOptional = false)
-{
- // Dbus object is needed to retrieve the JSON configuration file
- auto bus = sdbusplus::bus::new_default();
- std::map<configKey, std::unique_ptr<T>> config;
-
- auto confFile = fan::JsonConfig::getConfFile(bus, confAppName,
- T::confFileName, isOptional);
- if (!confFile.empty())
- {
- for (const auto& entry : fan::JsonConfig::load(confFile))
- {
- auto obj = std::make_unique<T>(entry);
- config.emplace(std::make_pair(obj->getName(), obj->getProfiles()),
- std::move(obj));
- }
- }
- return config;
-}
-
-/**
- * @brief Helper function to determine when a configuration entry is included
- * based on the list of active profiles and its list of profiles
- *
- * A configuration entry may include a list of profiles that when any one of
- * the profiles are active, the entry should be included. When the list of
- * profiles for a configuration entry is empty, that results in always
- * including the entry. An empty list of active profiles results in including
- * only those entries configured without a list of profiles.
- *
- * i.e.) No profiles configured results in always being included, whereas
- * providing a list of profiles on an entry results only in that entry being
- * included when a profile in the list is active.
- *
- * @param[in] activeProfiles - List of active system profiles
- * @param[in] entryProfiles - List of the configuration entry's profiles
- *
- * @return Whether the configuration entry should be included or not
- */
-bool checkEntry(const std::vector<std::string>& activeProfiles,
- const std::vector<std::string>& entryProfiles);
-
-/**
- * @brief Get the delay(in seconds) to allow the fans to ramp up to the defined
- * power on speed
- *
- * @param[in] bus - The dbus bus object
- *
- * @return Time to delay in seconds
- * Amount of time to delay in seconds after a power on
- */
-const unsigned int getPowerOnDelay(sdbusplus::bus::bus& bus,
- const sdeventplus::Event& event);
-
-} // namespace phosphor::fan::control