/*
   HARK Library
   Copyright (C) 2021 Honda Research Institute Japan Inc.
 */

#include "hark-lib/node/InputStream.h"

#include <fstream>

namespace hark
{
namespace node
{
    InputStream::InputStream():
        NodeDef("InputStream")
    {
        *this
            << Terminal::in("INPUT")
            >> Terminal::out("OUTPUT");
    }

    void
    InputStream::reset()
    {
    }

    bool
    InputStream::operator () (size_t count, InputDataBundle &input, OutputDataBundle &output)
    {
        std::string path = input["INPUT"].last().as<std::string>();
        std::unique_ptr<std::istream>is(new std::ifstream(path));

        output["OUTPUT"].push(data(is.release()));
        return true;
    }
}
}

/* end of file */
