#include "triggers.hpp"

namespace phosphor
{
namespace fan
{
namespace control
{
namespace trigger
{

using namespace phosphor::fan;

Trigger timer(TimerConf&& tConf)
{
    return [tConf = std::move(tConf)](
               control::Zone& zone, const std::string& name, const Group& group,
               const std::vector<Action>& actions) {
        zone.addTimer(name, group, actions, tConf);
    };
}

Trigger signal(const std::string& match, SignalHandler&& handler)
{
    return [match = std::move(match), handler = std::move(handler)](
               control::Zone& zone, const std::string& name, const Group& group,
               const std::vector<Action>& actions) {
        // Setup signal matches of the property for event
        std::unique_ptr<EventData> eventData =
            std::make_unique<EventData>(group, match, handler, actions);
        std::unique_ptr<sdbusplus::bus::match_t> mPtr = nullptr;
        if (!match.empty())
        {
            // Subscribe to signal match
            mPtr = std::make_unique<sdbusplus::bus::match_t>(
                zone.getBus(), match.c_str(),
                std::bind(std::mem_fn(&Zone::handleEvent), &zone,
                          std::placeholders::_1, eventData.get()));
        }
        else
        {
            // When match is empty, handle if zone object member
            // Set event data for each host group member
            for (auto& entry : group)
            {
                if (std::get<pathPos>(entry) == zone.getPath())
                {
                    auto ifaces = zone.getIfaces();
                    // Group member interface in list owned by zone
                    if (std::find(ifaces.begin(), ifaces.end(),
                                  std::get<intfPos>(entry)) != ifaces.end())
                    {
                        // Store path,interface,property as a managed object
                        zone.setObjectData(
                            std::get<pathPos>(entry), std::get<intfPos>(entry),
                            std::get<propPos>(entry), eventData.get());
                    }
                }
            }
        }
        zone.addSignal(name, std::move(eventData), std::move(mPtr));
    };
}

Trigger init(MethodHandler&& handler)
{
    return [handler = std::move(handler)](
               control::Zone& zone, const std::string& /*name*/,
               const Group& group, const std::vector<Action>& actions) {
        // A handler function is optional
        if (handler)
        {
            handler(zone, group);
        }

        // Run action functions for initial event state
        std::for_each(actions.begin(), actions.end(),
                      [&zone, &group](const auto& action) {
                          action(zone, group);
                      });
    };
}

} // namespace trigger
} // namespace control
} // namespace fan
} // namespace phosphor
