#include "ProcessorManual.h"
#include <iostream>

namespace mdd {
    ProcessorManual::ProcessorManual()
    {
        addProcessorOutput("Iterator", "{ \"value\": 0 }"_json);
    }

    bool ProcessorManual::update() {
        bool ret = false;
        bool group_state = true;
        while(group_state){
            getProcessorOutput(0)->getValueInternal()["value"]= getProcessorOutput(0)->getValue()["value"].get<int>()+1;
            group_state = false;
            for (int i = 0; i < getModules().size(); ++i) {
                bool module_state = getModule(i)->update();
                if(module_state){
                    group_state=true;
                    ret = true;
                }
            }
        }
        return ret;
    }

    std::shared_ptr<IOutput> ProcessorManual::getIteration(){
        return getProcessorOutput(0);
    }
}