blob: 4e7e213590ef6d45f16fb185bb8943cafbb481a1 [file] [log] [blame]
Matthew Barth0620be72021-04-14 13:31:12 -05001/**
2 * Copyright © 2021 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 "action.hpp"
Matthew Barthe8441c62021-05-13 16:50:56 -050019#include "init.hpp"
Matthew Barth0620be72021-04-14 13:31:12 -050020#include "manager.hpp"
Matthew Barthbaeeb8f2021-05-13 16:03:54 -050021#include "signal.hpp"
Matthew Barth93341e02021-04-14 13:56:28 -050022#include "timer.hpp"
Matthew Barth0620be72021-04-14 13:31:12 -050023
24#include <nlohmann/json.hpp>
25
26#include <functional>
27#include <map>
28#include <memory>
29#include <vector>
30
31namespace phosphor::fan::control::json::trigger
32{
33
34using json = nlohmann::json;
35
36// Trigger creation function
37using createTrigger =
38 std::function<void(const json&, const std::string&, Manager*,
39 std::vector<std::unique_ptr<ActionBase>>&)>;
40
41// Mapping of trigger class name to its creation function
Matthew Barth93341e02021-04-14 13:56:28 -050042static const std::map<std::string, createTrigger> triggers = {
Matthew Barthe8441c62021-05-13 16:50:56 -050043 {"timer", timer::triggerTimer},
44 {"signal", signal::triggerSignal},
45 {"init", init::triggerInit}};
Matthew Barth0620be72021-04-14 13:31:12 -050046
47} // namespace phosphor::fan::control::json::trigger