// Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto.  Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//

#include <OgnSequenceDatabase.h>
#include <omni/graph/action/IActionGraph.h>

namespace omni
{
namespace graph
{
namespace action
{

class OgnSequence
{
public:

    // Which branch we should take next
    int m_nextOutput {0};

    static bool compute(OgnSequenceDatabase& db)
    {
        auto iActionGraph = getInterface();
        OgnSequence& state = db.internalState<OgnSequence>();

        if (state.m_nextOutput == 0)
        {
            iActionGraph->setExecutionEnabledAndPushed(outputs::a.token(), db.getInstanceIndex());
        }
        else
        {
            iActionGraph->setExecutionEnabled(outputs::b.token(), db.getInstanceIndex());
        }

        state.m_nextOutput = (state.m_nextOutput + 1) % 2;

        return true;
    }
};

REGISTER_OGN_NODE()
} // action
} // graph
} // omni
