Newer
Older
Martin Christoph Hierholzer
committed
/*
* Module.cc
*
* Created on: Jun 27, 2016
* Author: Martin Hierholzer
*/
#include "Application.h"
#include "Module.h"
namespace ChimeraTK {
Module::Module(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy)
: EntityOwner(owner, name, description, eliminateHierarchy)
Martin Christoph Hierholzer
committed
{}
/*********************************************************************************************************************/
Module::~Module()
{}
Martin Christoph Hierholzer
committed
/*********************************************************************************************************************/
Martin Christoph Hierholzer
committed
void Module::connectTo(const Module &target, VariableNetworkNode trigger) const {
Martin Christoph Hierholzer
committed
// connect all direct variables of this module to their counter-parts in the right-hand-side module
for(auto variable : getAccessorList()) {
Martin Christoph Hierholzer
committed
if(variable.getDirection() == VariableDirection::feeding) {
Martin Christoph Hierholzer
committed
variable >> target(variable.getName());
Martin Christoph Hierholzer
committed
}
else {
Martin Christoph Hierholzer
committed
// use trigger?
if(trigger != VariableNetworkNode() && target(variable.getName()).getMode() == UpdateMode::poll
&& variable.getMode() == UpdateMode::push ) {
target(variable.getName()) [ trigger ] >> variable;
}
else {
target(variable.getName()) >> variable;
}
Martin Christoph Hierholzer
committed
}
}
// connect all sub-modules to their couter-parts in the right-hand-side module
for(auto submodule : getSubmoduleList()) {
Martin Christoph Hierholzer
committed
submodule->connectTo(target[submodule->getName()], trigger);
Martin Christoph Hierholzer
committed
}
}
Martin Christoph Hierholzer
committed
} /* namespace ChimeraTK */