80 lines
1.9 KiB
C++
80 lines
1.9 KiB
C++
#include "component.h"
|
|
|
|
namespace domain {
|
|
|
|
Component::Component(string name, string tooltip, string source, ComponentType type,
|
|
vector<Rule> rules, string instanceName, pair<int, int> count, Display display,
|
|
vector<Pin> pins, vector<Attribute> 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<Rule> Component::getRules() {
|
|
return rules;
|
|
}
|
|
std::string Component::getInstanceName() {
|
|
return instanceName;
|
|
}
|
|
std::pair<int, int> Component::getCount() {
|
|
return count;
|
|
}
|
|
Display Component::getDisplay() {
|
|
return display;
|
|
}
|
|
|
|
std::vector<Pin> Component::getPins() {
|
|
return pins;
|
|
}
|
|
Pin Component::getPin(std::string pin) {
|
|
for(uint i=0; i<pins.size(); i++) {
|
|
if(pins[i].getName() == pin) {
|
|
return pins[i];
|
|
}
|
|
}
|
|
throw std::exception();
|
|
}
|
|
|
|
bool Component::hasPin(std::string name) {
|
|
for(auto pin: pins) {
|
|
if(pin.getName() == name) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
std::vector<Attribute> Component::getAttributes() {
|
|
return attributes;
|
|
}
|
|
Attribute Component::getAttribute(std::string attribute) {
|
|
for(uint i=0; i<attributes.size(); i++) {
|
|
if(attributes[i].getName() == attribute) {
|
|
return attributes[i];
|
|
}
|
|
}
|
|
throw std::exception();
|
|
}
|
|
bool Component::hasAttribute(std::string name, Value::ValueType type) {
|
|
for(uint i=0; i<attributes.size(); i++) {
|
|
if(attributes[i].getName() == name && attributes[i].getDefault().getType() == type) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
} // namespace domain
|