123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #include "ProcessorBase.h"
- namespace mdd{
- void ProcessorBase::setType(std:: string type){
- _type=type;
- }
- std::string ProcessorBase::getType(){
- return _type;
- }
- std::string ProcessorBase::addModule(std::shared_ptr<IModule> module){
- _modules.emplace_back(module);
- _modules[_modules.size()-1]->setPrefix(getID());
- return _modules[_modules.size()-1]->getID();
- }
- std::string ProcessorBase::addModuleInput(std::string moduleHandler, std::string inputHandler){
- _module_inputs.emplace_back(HandlerModule(moduleHandler, inputHandler));
- return _module_inputs[_module_inputs.size()-1].accessHandler;
- }
- json& ProcessorBase::setInputDefaultValue(int handle){
- return _modules[_module_inputs[handle].moduleHandler]->setInputDefaultValue(_module_inputs[handle].accessHandler);
- }
- const json& ProcessorBase::getInputValue(int handle){
- _modules[_module_inputs[handle].moduleHandler]->getInputValue(_module_inputs[handle].accessHandler);
- }
- bool ProcessorBase::connectInput(std::string input_id, std::shared_ptr<IOutput> output){
- auto module_handler = std::find(_module_inputs.begin(),_module_inputs.end(), input_id);
- if (module_handler != _module_inputs.end()){
- auto handler = std::find(_modules.begin(),_modules.end(), module_handler->moduleHandler);
- if(handler != _modules.end()){
- return (*handler)->connectInput(module_handler->accessHandler, output);
- }
- } else{
- auto procesor_handler = std::find(_processor_inputs.begin(),_processor_inputs.end(), input_id);
- if (procesor_handler != _processor_inputs.end()){
- if (procesor_handler->verification(output->getValue())) {
- procesor_handler->output = output;
- return true;
- }
- }
- }
- return false;
- }
- std::vector<std::string> ProcessorBase::getInputs(){
- std::vector<std::string> ret;
- for (auto &input : _module_inputs) {
- ret.push_back(_modules[input.moduleHandler]->getOutput(input.accessHandler)->getType());
- }
- return ret;
- }
- std::vector<std::string> ProcessorBase::getOutputs(){
- std::vector<std::string> ret;
- for (auto &output : _module_outputs) {
- ret.push_back(_modules[output.moduleHandler]->getOutput(output.accessHandler)->getType());
- }
- return ret;
- }
- std::shared_ptr<IOutput> ProcessorBase::getOutput(int handle){
- return _modules[_module_outputs[handle].moduleHandler]->getOutput(_module_outputs[handle].accessHandler);
- }
- std::vector<std::string> ProcessorBase::getModules(){
- std::vector<std::string> ret;
- for (auto &module : _modules) {
- ret.push_back(module->getType());
- }
- return ret;
- }
- std::shared_ptr<IModule> ProcessorBase::getModule(int handle){
- return _modules[handle];
- }
- int ProcessorBase::addOutput(int moduleHandler, int outputHandler){
- _module_outputs.emplace_back(HandlerModule(moduleHandler, outputHandler));
- return _module_outputs.size()-1;
- }
- }
|