xref: /openbmc/phosphor-fan-presence/control/json/profile.hpp (revision a56135b52adcb8f94ed074d4a23a3d97c4a3dbe5)
1 /**
2  * Copyright © 2020 IBM 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 #pragma once
17 
18 #include "config_base.hpp"
19 
20 #include <nlohmann/json.hpp>
21 #include <sdbusplus/bus.hpp>
22 
23 namespace phosphor::fan::control::json
24 {
25 
26 using json = nlohmann::json;
27 
28 /**
29  * @class Profile - Represents a configured fan control profile
30  *
31  * Fan control profiles are optional, therefore the "profiles.json" file is
32  * also optional. A profile can be used to load specific fan control events
33  * based on the configuration of the profile. Fan control events configured
34  * with no profile(s) are always used and events configured for a specified
35  * profile are included when that profile is enabled.
36  *
37  * When no profiles exist, all configured fan control events are used.
38  */
39 class Profile : public ConfigBase
40 {
41   public:
42     /* JSON file name for profiles */
43     static constexpr auto confFileName = "profiles.json";
44 
45     Profile() = delete;
46     Profile(const Profile&) = delete;
47     Profile(Profile&&) = delete;
48     Profile& operator=(const Profile&) = delete;
49     Profile& operator=(Profile&&) = delete;
50     ~Profile() = default;
51 
52     /**
53      * Constructor
54      * Parses and populates a zone profile from JSON object data
55      *
56      * @param[in] bus - sdbusplus bus object
57      * @param[in] jsonObj - JSON object
58      */
59     Profile(sdbusplus::bus::bus& bus, const json& jsonObj);
60 
61   private:
62     /* The sdbusplus bus object */
63     sdbusplus::bus::bus& _bus;
64 };
65 
66 } // namespace phosphor::fan::control::json
67