#include "component.h" namespace domain { Component::Component(string name, string tooltip, string source, ComponentType type, vector rules, string instanceName, pair count, Display display, vector pins, vector attributes) : name(name), tooltip(tooltip), source(source), type(type), rules(rules), instanceName(instanceName), count(count), display(display), pins(pins), attributes(attributes) {} std::string Component::getName() { return name; } std::string Component::getTooltip() { return tooltip; } std::string Component::getSource() { return source; } Component::ComponentType Component::getType() { return type; } std::vector Component::getRules() { return rules; } std::string Component::getInstanceName() { return instanceName; } std::pair Component::getCount() { return count; } Display Component::getDisplay() { return display; } std::vector Component::getPins() { return pins; } Pin Component::getPin(std::string pin) { for (auto & p: pins) { if (p.getName() == pin) { return p; } } throw std::exception(); } bool Component::hasPin(std::string name) { for (auto pin: pins) { if (pin.getName() == name) { return true; } } return false; } std::vector& Component::getAttributes() { return attributes; } Attribute Component::getAttribute(std::string attribute) { for (auto & attr : attributes) { if (attr.getName() == attribute) { return attr; } } throw std::exception(); } bool Component::hasAttribute(std::string name, Value::ValueType type) { for (auto & attribute : attributes) { if (attribute.getName() == name && attribute.getDefault().getType() == type) { return true; } if (attribute.getName() == name && (type == Value::NIL && (attribute.getDefault().getType() == Value::MEMORY_REFERENCE || attribute.getDefault().getType() == Value::WIRE_REFERENCE))) { return true; } if (attribute.getName() == name && (type == Value::UNDEFINED && (attribute.getDefault().getType() == Value::MEMORY_REFERENCE || attribute.getDefault().getType() == Value::WIRE_REFERENCE))) { return true; } } return false; } } // namespace domain