#include "connection_instance.h" namespace domain { ConnectionInstance::ConnectionInstance(ComponentInstance *instance, std::vector attributes, Connection connection) : instance(instance), attributes(attributes), connection(connection) {} InstanceAttribute ConnectionInstance::getAttribute(string attribute) { for (auto &attr: attributes) { if (attr.name == attribute) { return attr; } } throw std::exception(); } BusConnectionInstance::BusConnectionInstance(ComponentInstance *instance, std::vector attributes, BusInstance *bus, Connection connection) : ConnectionInstance(instance, attributes, connection), bus(bus) {} DirectConnectionInstance::DirectConnectionInstance(ComponentInstance *instance, ComponentInstance *secondInstance, std::vector attributes, BusInstance *bus, Connection connection) : ConnectionInstance(instance, attributes, connection), secondInstance(secondInstance), bus(bus) {} int DirectConnectionInstance::getSelected(ConnectionComponent conn) { if(this->instance->name == conn.component) { auto selected = attributes[0].value.asString(); for(int i=0; isize(); i++) { if(connection.getSecondWires().value()[i].isType(Value::STRING) && connection.getSecondWires().value()[i].asString() == selected) { return i; } } } return -1; } } // namespace domain