// Copyright (c) 2021, 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 <OgnTutorialTokensDatabase.h>


class OgnTutorialTokens
{
public:
    static bool compute(OgnTutorialTokensDatabase& db)
    {
        const auto& valuesToCheck = db.inputs.valuesToCheck();
        auto& isColor = db.outputs.isColor();
        isColor.resize( valuesToCheck.size() );
        if (valuesToCheck.size() == 0)
        {
            return true;
        }

        // Walk the list of inputs, setting the corresponding output to true if and only if the input is in
        // the list of allowable tokens.
        size_t index{ 0 };
        for (const auto& inputValue : valuesToCheck)
        {
            // When the database is available you can use it to access the token values directly. When it is not
            // you can access them statically (e.g. OgnTutorialTokensDatabase.token.red)
            if ((inputValue == db.tokens.red) || (inputValue == db.tokens.green) || (inputValue == db.tokens.blue))
            {
                isColor[index] = true;
            }
            else
            {
                isColor[index] = false;
            }
            index++;            
        }

        return true;
    }
};

REGISTER_OGN_NODE()
