1*ccaf2db9SMatthew Barth /** 2*ccaf2db9SMatthew Barth * Copyright © 2020 IBM Corporation 3*ccaf2db9SMatthew Barth * 4*ccaf2db9SMatthew Barth * Licensed under the Apache License, Version 2.0 (the "License"); 5*ccaf2db9SMatthew Barth * you may not use this file except in compliance with the License. 6*ccaf2db9SMatthew Barth * You may obtain a copy of the License at 7*ccaf2db9SMatthew Barth * 8*ccaf2db9SMatthew Barth * http://www.apache.org/licenses/LICENSE-2.0 9*ccaf2db9SMatthew Barth * 10*ccaf2db9SMatthew Barth * Unless required by applicable law or agreed to in writing, software 11*ccaf2db9SMatthew Barth * distributed under the License is distributed on an "AS IS" BASIS, 12*ccaf2db9SMatthew Barth * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*ccaf2db9SMatthew Barth * See the License for the specific language governing permissions and 14*ccaf2db9SMatthew Barth * limitations under the License. 15*ccaf2db9SMatthew Barth */ 16*ccaf2db9SMatthew Barth #pragma once 17*ccaf2db9SMatthew Barth 18*ccaf2db9SMatthew Barth #include "json_config.hpp" 19*ccaf2db9SMatthew Barth 20*ccaf2db9SMatthew Barth #include <nlohmann/json.hpp> 21*ccaf2db9SMatthew Barth #include <sdbusplus/bus.hpp> 22*ccaf2db9SMatthew Barth 23*ccaf2db9SMatthew Barth namespace phosphor::fan::monitor 24*ccaf2db9SMatthew Barth { 25*ccaf2db9SMatthew Barth 26*ccaf2db9SMatthew Barth using json = nlohmann::json; 27*ccaf2db9SMatthew Barth 28*ccaf2db9SMatthew Barth constexpr auto confAppName = "monitor"; 29*ccaf2db9SMatthew Barth constexpr auto confFileName = "config.json"; 30*ccaf2db9SMatthew Barth 31*ccaf2db9SMatthew Barth /** 32*ccaf2db9SMatthew Barth * @brief Get the JSON object 33*ccaf2db9SMatthew Barth * 34*ccaf2db9SMatthew Barth * @param[in] bus - The dbus bus object 35*ccaf2db9SMatthew Barth * 36*ccaf2db9SMatthew Barth * @return JSON object 37*ccaf2db9SMatthew Barth * A JSON object created after loading the JSON configuration file 38*ccaf2db9SMatthew Barth */ 39*ccaf2db9SMatthew Barth inline const json getJsonObj(sdbusplus::bus::bus& bus) 40*ccaf2db9SMatthew Barth { 41*ccaf2db9SMatthew Barth return fan::JsonConfig::load( 42*ccaf2db9SMatthew Barth fan::JsonConfig::getConfFile(bus, confAppName, confFileName)); 43*ccaf2db9SMatthew Barth } 44*ccaf2db9SMatthew Barth 45*ccaf2db9SMatthew Barth } // namespace phosphor::fan::monitor 46