Compare commits
No commits in common. "6dfe86335d5713605df6f477a93d9318fd6345a9" and "f66fc1db26af4bcc670a27011245090efc7e1686" have entirely different histories.
6dfe86335d
...
f66fc1db26
|
@ -288,30 +288,6 @@ bool Application::removeComponent(std::string componentName) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Application::removeConnection(domain::ConnectionInstance *connectionInstance) {
|
||||
if(auto directConnection = dynamic_cast<domain::DirectConnectionInstance*>(connectionInstance)) {
|
||||
schema->busInstances.erase(
|
||||
std::remove_if(
|
||||
schema->busInstances.begin(),
|
||||
schema->busInstances.end(),
|
||||
[directConnection](const std::shared_ptr<domain::BusInstance> &bus) {
|
||||
return directConnection->bus == bus.get();
|
||||
}),
|
||||
schema->busInstances.end()
|
||||
);
|
||||
}
|
||||
schema->connections.erase(
|
||||
std::remove_if(
|
||||
schema->connections.begin(),
|
||||
schema->connections.end(),
|
||||
[connectionInstance](const std::shared_ptr<domain::ConnectionInstance> &conn) {
|
||||
return connectionInstance == conn.get();
|
||||
}),
|
||||
schema->connections.end()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
bool Application::removeBus(std::string busName) {
|
||||
auto bus = findBusByName(busName);
|
||||
if (bus == nullptr) {
|
||||
|
|
|
@ -52,8 +52,6 @@ public:
|
|||
void renameComponent(std::string currentName, std::string newName);
|
||||
|
||||
void renameBus(std::string currentName, std::string newName);
|
||||
|
||||
void removeConnection(domain::ConnectionInstance *pInstance);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -9,8 +9,59 @@
|
|||
|
||||
namespace display {
|
||||
|
||||
void AttributeDialog::onUpdate() {
|
||||
auto oldValue = attributeValue->value;
|
||||
|
||||
attributeValue->value = value;
|
||||
domain::ComdelValidator validator(domain::getSupportedValidators());
|
||||
|
||||
domain::ValidationContext context;
|
||||
|
||||
for (auto &addressSpace: Application::instance()->getLibrary()->getAddressSpaces()) {
|
||||
context.addressSpaces.insert(std::make_pair(addressSpace.getName(), addressSpace));
|
||||
}
|
||||
|
||||
auto validationErrors = validator.validateAttribute(attributeValue, context);
|
||||
if (validationErrors.empty()) {
|
||||
accept();
|
||||
} else {
|
||||
bool canAccept = true;
|
||||
|
||||
std::vector<domain::ValidationError> errors;
|
||||
std::vector<domain::ValidationError> warnings;
|
||||
for (auto &err: validationErrors) {
|
||||
if (err.type == domain::Action::ERROR) {
|
||||
errors.push_back(err);
|
||||
} else {
|
||||
warnings.push_back(err);
|
||||
}
|
||||
}
|
||||
if (!errors.empty()) {
|
||||
canAccept = false;
|
||||
auto errorDialog = new ErrorDialog(errors);
|
||||
errorDialog->exec();
|
||||
}
|
||||
|
||||
for (auto &warning: warnings) {
|
||||
auto warningDialog = new WarningDialog(warning);
|
||||
int response = warningDialog->exec();
|
||||
if (response == QDialog::Rejected) {
|
||||
canAccept = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canAccept) {
|
||||
accept();
|
||||
} else {
|
||||
attributeValue->value = oldValue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AttributeDialog::AttributeDialog(domain::InstanceAttribute *attribute, bool updating) {
|
||||
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
attributeValue = attribute;
|
||||
|
@ -91,68 +142,10 @@ namespace display {
|
|||
layout->addWidget(group);
|
||||
}
|
||||
|
||||
auto button = new QPushButton(updating ? "Ažuriraj" : "Postavi");
|
||||
connect(button, &QPushButton::clicked, this, &AttributeDialog::onUpdate);
|
||||
|
||||
auto buttonLayout = new QHBoxLayout(this);
|
||||
|
||||
auto okButton = new QPushButton(updating ? "Ažuriraj" : "Postavi", this);
|
||||
auto cancelButton = new QPushButton("Odustani", this);
|
||||
|
||||
connect(okButton, &QPushButton::clicked, this, &AttributeDialog::onUpdate);
|
||||
connect(cancelButton, &QPushButton::clicked, [this]() { reject(); });
|
||||
|
||||
buttonLayout->addWidget(okButton);
|
||||
buttonLayout->addWidget(cancelButton);
|
||||
|
||||
layout->addLayout(buttonLayout);
|
||||
}
|
||||
|
||||
void AttributeDialog::onUpdate() {
|
||||
auto oldValue = attributeValue->value;
|
||||
|
||||
attributeValue->value = value;
|
||||
domain::ComdelValidator validator(domain::getSupportedValidators());
|
||||
|
||||
domain::ValidationContext context;
|
||||
|
||||
for (auto &addressSpace: Application::instance()->getLibrary()->getAddressSpaces()) {
|
||||
context.addressSpaces.insert(std::make_pair(addressSpace.getName(), addressSpace));
|
||||
}
|
||||
|
||||
auto validationErrors = validator.validateAttribute(attributeValue, context);
|
||||
if (validationErrors.empty()) {
|
||||
accept();
|
||||
} else {
|
||||
bool canAccept = true;
|
||||
|
||||
std::vector<domain::ValidationError> errors;
|
||||
std::vector<domain::ValidationError> warnings;
|
||||
for (auto &err: validationErrors) {
|
||||
if (err.type == domain::Action::ERROR) {
|
||||
errors.push_back(err);
|
||||
} else {
|
||||
warnings.push_back(err);
|
||||
}
|
||||
}
|
||||
if (!errors.empty()) {
|
||||
canAccept = false;
|
||||
auto errorDialog = new ErrorDialog(errors);
|
||||
errorDialog->exec();
|
||||
}
|
||||
|
||||
for (auto &warning: warnings) {
|
||||
auto warningDialog = new WarningDialog(warning);
|
||||
int response = warningDialog->exec();
|
||||
if (response == QDialog::Rejected) {
|
||||
canAccept = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canAccept) {
|
||||
accept();
|
||||
} else {
|
||||
attributeValue->value = oldValue;
|
||||
}
|
||||
}
|
||||
layout->addWidget(button);
|
||||
}
|
||||
|
||||
void AttributeDialog::onTextChanged(const QString &string) {
|
||||
|
@ -172,6 +165,12 @@ namespace display {
|
|||
value = attributeValue->attribute.getPopup()->getEnumeration()[index].getValue();
|
||||
}
|
||||
|
||||
|
||||
void MemoryDialog::onUpdate() {
|
||||
attributeValue->value = value;
|
||||
accept();
|
||||
}
|
||||
|
||||
MemoryDialog::MemoryDialog(domain::InstanceAttribute *attribute,
|
||||
std::vector<std::shared_ptr<domain::ComponentInstance>> instances, bool updating) {
|
||||
memoryInstances = std::vector<std::string>();
|
||||
|
@ -217,23 +216,10 @@ namespace display {
|
|||
}
|
||||
}
|
||||
|
||||
auto buttonLayout = new QHBoxLayout(this);
|
||||
auto button = new QPushButton(updating ? "Ažuriraj" : "Postavi");
|
||||
connect(button, &QPushButton::clicked, this, &MemoryDialog::onUpdate);
|
||||
|
||||
auto okButton = new QPushButton(updating ? "Ažuriraj" : "Postavi");
|
||||
auto cancelButton = new QPushButton("Odustani", this);
|
||||
|
||||
connect(okButton, &QPushButton::clicked, this, &MemoryDialog::onUpdate);
|
||||
connect(cancelButton, &QPushButton::clicked, [this]() { reject(); });
|
||||
|
||||
buttonLayout->addWidget(okButton);
|
||||
buttonLayout->addWidget(cancelButton);
|
||||
|
||||
layout->addLayout(buttonLayout);
|
||||
}
|
||||
|
||||
void MemoryDialog::onUpdate() {
|
||||
attributeValue->value = value;
|
||||
accept();
|
||||
layout->addWidget(button);
|
||||
}
|
||||
|
||||
void MemoryDialog::onMemoryChanged(int index) {
|
||||
|
@ -278,6 +264,6 @@ namespace display {
|
|||
buttonLayout->addWidget(okButton);
|
||||
buttonLayout->addWidget(cancelButton);
|
||||
|
||||
layout->addLayout(buttonLayout);
|
||||
layout->addItem(buttonLayout);
|
||||
}
|
||||
}
|
|
@ -16,12 +16,6 @@ namespace display {
|
|||
|
||||
QPen connectionPen(QColor::fromRgb(150, 150, 250));
|
||||
|
||||
Component::Component(const std::shared_ptr<domain::ComponentInstance> &instance): instance(instance) {
|
||||
setFlag(ItemSendsGeometryChanges, true);
|
||||
setToolTip(QString::fromStdString(instance->name + "::" + instance->component.getName()));
|
||||
instance->component.getDisplay().render(this);
|
||||
}
|
||||
|
||||
void Component::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||
QMenu menu;
|
||||
menu.addAction("Izmjeni ime", [this]() {
|
||||
|
@ -36,7 +30,6 @@ namespace display {
|
|||
auto newName = dialog->getName();
|
||||
|
||||
Application::instance()->renameComponent(currentName, newName);
|
||||
setToolTip(QString::fromStdString(instance->name + "::" + instance->component.getName()));
|
||||
});
|
||||
menu.addSeparator();
|
||||
for (int i = 0; i < this->instance->attributes.size(); i++) {
|
||||
|
@ -68,57 +61,14 @@ namespace display {
|
|||
menu.exec(event->screenPos());
|
||||
}
|
||||
|
||||
Component::Component(const std::shared_ptr<domain::ComponentInstance> &instance): instance(instance) {
|
||||
setFlag(ItemSendsGeometryChanges, true);
|
||||
instance->component.getDisplay().render(this);
|
||||
}
|
||||
|
||||
void Pin::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||
QMenu menu;
|
||||
|
||||
auto pinConnections = Application::instance()->getSchema()->getConnections(componentInstance->name, pin.getName());
|
||||
|
||||
if(isSingleAutomatic(pinConnections)) {
|
||||
auto *update = menu.addMenu("Izmjeni");
|
||||
auto *remove = menu.addMenu("Ukloni");
|
||||
for (auto pinConnection: pinConnections) {
|
||||
// this always must be true as only directConnections can be connected multiple times
|
||||
if (auto directConnection = dynamic_cast<domain::DirectConnectionInstance *>(pinConnection)) {
|
||||
if (directConnection->bus->bus.getType() == domain::Bus::SINGLE_AUTOMATIC) {
|
||||
auto connectionName = directConnection->attributes[0].value.stringify() + "-" +
|
||||
directConnection->attributes[1].value.stringify();
|
||||
update->addAction(QString::fromStdString("Izmjeni " + connectionName), [directConnection]() {
|
||||
auto dialog = new SingleAutomaticDialog(directConnection->attributes);
|
||||
dialog->exec();
|
||||
});
|
||||
remove->addAction(QString::fromStdString("Ukloni " + connectionName),
|
||||
[this, directConnection]() {
|
||||
Application::instance()->removeConnection(directConnection);
|
||||
auto view = dynamic_cast<Schema *>(this->scene()->views()[0]);
|
||||
view->refreshContent();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto pinConnection = pinConnections[0];
|
||||
if(auto busConnection = dynamic_cast<domain::BusConnectionInstance*>(pinConnection)) {
|
||||
menu.addSection(QString::fromStdString(busConnection->bus->name));
|
||||
} else if(auto directConnection = dynamic_cast<domain::DirectConnectionInstance*>(pinConnection)) {
|
||||
if(directConnection->instance == componentInstance.get()) {
|
||||
menu.addSection(QString::fromStdString(directConnection->secondInstance->name + "." + directConnection->connection.getSecondComponent()->pin));
|
||||
} else {
|
||||
menu.addSection(QString::fromStdString(directConnection->instance->name + "." + directConnection->connection.getComponent().pin));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < pinConnection->attributes.size(); i++) {
|
||||
auto *attr = &pinConnection->attributes[i];
|
||||
menu.addAction(QString::fromStdString("Izmjeni '" + attr->name + "'"),[attr]() {
|
||||
auto dialog = new AttributeDialog(attr);
|
||||
dialog->exec();
|
||||
});
|
||||
}
|
||||
menu.addAction("Ukloni poveznicu", [this, pinConnection]() {
|
||||
Application::instance()->removeConnection(pinConnection);
|
||||
auto view = dynamic_cast<Schema *>(this->scene()->views()[0]);
|
||||
view->refreshContent();
|
||||
});
|
||||
}
|
||||
menu.addAction("Poveži pin", [&]() {});
|
||||
menu.exec(event->screenPos());
|
||||
}
|
||||
|
||||
|
@ -166,23 +116,6 @@ namespace display {
|
|||
return componentInstance.get();
|
||||
}
|
||||
|
||||
bool Pin::isSingleAutomatic(std::vector<domain::ConnectionInstance *> pinConnections) {
|
||||
if(pinConnections.empty()) {
|
||||
return false;
|
||||
}
|
||||
auto pinConnection = pinConnections[0];
|
||||
if(auto directConnection = dynamic_cast<domain::DirectConnectionInstance*>(pinConnection)) {
|
||||
return directConnection->bus->bus.getType() == domain::Bus::SINGLE_AUTOMATIC;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Bus::Bus(const std::shared_ptr<domain::BusInstance> &instance): busInstance(instance) {
|
||||
instance->bus.getDisplayBus()->render(this, instance->size);
|
||||
setToolTip(QString::fromStdString(busInstance->name + "::" + busInstance->bus.getName()));
|
||||
}
|
||||
|
||||
void Bus::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||
QMenu menu;
|
||||
menu.addAction("Izmjeni ime", [this]() {
|
||||
|
@ -197,7 +130,6 @@ namespace display {
|
|||
auto newName = dialog->getName();
|
||||
|
||||
Application::instance()->renameBus(currentName, newName);
|
||||
setToolTip(QString::fromStdString(busInstance->name + "::" + busInstance->bus.getName()));
|
||||
});
|
||||
menu.addSeparator();
|
||||
menu.addAction(QString::fromStdString("Ukloni " + this->busInstance->name), [this]() {
|
||||
|
@ -208,6 +140,14 @@ namespace display {
|
|||
menu.exec(event->screenPos());
|
||||
}
|
||||
|
||||
Bus::Bus(const std::shared_ptr<domain::BusInstance> &instance): busInstance(instance) {
|
||||
instance->bus.getDisplayBus()->render(this, instance->size);
|
||||
}
|
||||
|
||||
domain::BusInstance *Bus::getBusInstance() {
|
||||
{ return busInstance.get(); }
|
||||
}
|
||||
|
||||
QVariant BusGroup::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) {
|
||||
if (change == ItemPositionChange && scene()) {
|
||||
// value is the new position.
|
||||
|
@ -272,6 +212,24 @@ namespace display {
|
|||
setPos(instance->position.first, instance->position.second);
|
||||
}
|
||||
|
||||
void BusConnection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||
QMenu menu;
|
||||
menu.addAction("Ukloni poveznicu", [this]() {});
|
||||
menu.addSeparator();
|
||||
for (int i = 0; i < this->connection->attributes.size(); i++) {
|
||||
auto *attr = &this->connection->attributes[i];
|
||||
bool enabled = attr->attribute.getPopup().has_value();
|
||||
|
||||
auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name),
|
||||
[attr]() {
|
||||
auto dialog = new AttributeDialog(attr);
|
||||
dialog->exec();
|
||||
});
|
||||
action->setEnabled(enabled);
|
||||
}
|
||||
menu.exec(event->screenPos());
|
||||
}
|
||||
|
||||
BusConnection::BusConnection(domain::BusConnectionInstance *connection, ComponentGroup *component, BusGroup *bus): connection(
|
||||
connection), component(component), bus(bus) {
|
||||
updateConnection();
|
||||
|
@ -296,6 +254,36 @@ namespace display {
|
|||
connection->end.second = connection->bus->position.second + busPosition.height() / 2;
|
||||
}
|
||||
|
||||
|
||||
void DirectConnection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||
QMenu menu;
|
||||
menu.addAction("Ukloni poveznicu", [this]() {});
|
||||
menu.addSeparator();
|
||||
|
||||
if(connection->bus->bus.getType() == domain::Bus::SINGLE_AUTOMATIC) {
|
||||
auto &attributes = this->connection->attributes;
|
||||
menu.addAction(QString::fromStdString("Izmjeni poveznicu"),
|
||||
[&attributes]() {
|
||||
auto dialog = new display::SingleAutomaticDialog(attributes);
|
||||
dialog->exec();
|
||||
});
|
||||
} else {
|
||||
for (int i = 0; i < this->connection->attributes.size(); i++) {
|
||||
auto *attr = &this->connection->attributes[i];
|
||||
bool enabled = attr->attribute.getPopup().has_value();
|
||||
|
||||
auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name),
|
||||
[attr]() {
|
||||
auto dialog = new AttributeDialog(attr);
|
||||
dialog->exec();
|
||||
});
|
||||
action->setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
menu.exec(event->screenPos());
|
||||
}
|
||||
|
||||
DirectConnection::DirectConnection(domain::DirectConnectionInstance *connection, ComponentGroup *first,
|
||||
ComponentGroup *second): connection(connection), first(first), second(second) {
|
||||
updateConnection();
|
||||
|
|
|
@ -17,7 +17,9 @@ namespace display {
|
|||
std::shared_ptr<domain::ComponentInstance> componentInstance;
|
||||
|
||||
public:
|
||||
Pin(domain::Pin pin, std::shared_ptr<domain::ComponentInstance> componentInstance) : pin(pin), componentInstance(std::move(componentInstance)) {
|
||||
Pin(domain::Pin pin, std::shared_ptr<domain::ComponentInstance> componentInstance) : pin(pin),
|
||||
componentInstance(std::move(
|
||||
componentInstance)) {
|
||||
pin.getDisplayPin().render(this);
|
||||
this->setToolTip(QString::fromStdString(pin.getTooltip()));
|
||||
}
|
||||
|
@ -33,8 +35,6 @@ namespace display {
|
|||
domain::Pin &getPin();
|
||||
|
||||
domain::ComponentInstance *getComponentInstance();
|
||||
|
||||
bool isSingleAutomatic(std::vector<domain::ConnectionInstance *> pinConnections);
|
||||
};
|
||||
|
||||
class Component : public QGraphicsItemGroup {
|
||||
|
@ -52,6 +52,8 @@ namespace display {
|
|||
public:
|
||||
explicit Bus(const std::shared_ptr<domain::BusInstance> &instance);
|
||||
|
||||
domain::BusInstance *getBusInstance();
|
||||
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
||||
};
|
||||
|
||||
|
@ -95,6 +97,8 @@ namespace display {
|
|||
BusConnection(domain::BusConnectionInstance *connection, ComponentGroup *component, BusGroup *bus);
|
||||
|
||||
void updateConnection();
|
||||
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -108,6 +112,8 @@ namespace display {
|
|||
DirectConnection(domain::DirectConnectionInstance *connection, ComponentGroup *first, ComponentGroup *second);
|
||||
|
||||
void updateConnection();
|
||||
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -16,20 +16,10 @@ display::NameDialog::NameDialog(std::string currentName, std::set<std::string> &
|
|||
connect(edit, &QLineEdit::textChanged, this, &NameDialog::onNameUpdate);
|
||||
layout->addWidget(edit);
|
||||
setWindowTitle("Izmjeni ime");
|
||||
button = new QPushButton("Ažuriraj", this);
|
||||
connect(button, &QPushButton::clicked, this, &NameDialog::onNameChange);
|
||||
layout->addWidget(button);
|
||||
setLayout(layout);
|
||||
|
||||
auto buttonLayout = new QHBoxLayout(this);
|
||||
|
||||
auto okButton = new QPushButton("Ažuriraj");
|
||||
auto cancelButton = new QPushButton("Odustani", this);
|
||||
|
||||
connect(okButton, &QPushButton::clicked, this, &NameDialog::onNameChange);
|
||||
connect(cancelButton, &QPushButton::clicked, [this]() { reject(); });
|
||||
|
||||
buttonLayout->addWidget(okButton);
|
||||
buttonLayout->addWidget(cancelButton);
|
||||
|
||||
layout->addLayout(buttonLayout);
|
||||
}
|
||||
|
||||
void display::NameDialog::onNameUpdate(const QString &text) {
|
||||
|
|
|
@ -29,18 +29,9 @@ namespace display {
|
|||
setupValues(firstLayout, values[0], &SingleAutomaticDialog::onFirstEnumerationChanged);
|
||||
setupValues(secondLayout, values[1], &SingleAutomaticDialog::onSecondEnumerationChanged);
|
||||
|
||||
auto buttonLayout = new QHBoxLayout(this);
|
||||
|
||||
auto okButton = new QPushButton("U redu", this);
|
||||
auto cancelButton = new QPushButton("Odustani", this);
|
||||
|
||||
connect(okButton, &QPushButton::clicked, [this]() { accept(); });
|
||||
connect(cancelButton, &QPushButton::clicked, [this]() { reject(); });
|
||||
|
||||
buttonLayout->addWidget(okButton);
|
||||
buttonLayout->addWidget(cancelButton);
|
||||
|
||||
parentLayout->addLayout(buttonLayout);
|
||||
auto button = new QPushButton(updating ? "Ažuriraj" : "Postavi");
|
||||
connect(button, &QPushButton::clicked, this, &SingleAutomaticDialog::onUpdate);
|
||||
parentLayout->addWidget(button);
|
||||
}
|
||||
|
||||
void SingleAutomaticDialog::setupValues(QVBoxLayout *layout, domain::InstanceAttribute &attribute, void (display::SingleAutomaticDialog::* handler)(int)) {
|
||||
|
|
|
@ -37,12 +37,12 @@ namespace domain {
|
|||
|
||||
if (count < comp.getCount().first) {
|
||||
auto message = populateMessage(
|
||||
"Nedovoljno instanci komponente '{componentName}' potrebno barem {min}, pronađeno {count}",
|
||||
"Not enough instances of component '{componentName}' required at least {min}, found {count}",
|
||||
context);
|
||||
errors.emplace_back(Action::ERROR, message);
|
||||
} else if (count > comp.getCount().second) {
|
||||
auto message = populateMessage(
|
||||
"Previše insanci komponente '{componentName}' dozvoljeno najviše {max}, pronađeno {count}", context);
|
||||
"To many instances of component '{componentName}' allow at most {max}, found {count}", context);
|
||||
errors.emplace_back(Action::ERROR, message);
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +64,11 @@ namespace domain {
|
|||
|
||||
if (count < bus.getCount().first) {
|
||||
auto message = populateMessage(
|
||||
"Nedovoljno instanci sabirnice '{busName}' potrebna barem jedna {min}, pronađeno {count}", context);
|
||||
"Not enough instances of bus '{busName}' required at least {min}, found {count}", context);
|
||||
errors.emplace_back(Action::ERROR, message);
|
||||
} else if (count > bus.getCount().second) {
|
||||
auto message = populateMessage(
|
||||
"Previše instanci sabirnice '{busName}' dozvoljeno najviše {max}, pronašeno {count}", context);
|
||||
"To many instances of bus '{busName}' allow at most {max}, found {count}", context);
|
||||
errors.emplace_back(Action::ERROR, message);
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ namespace domain {
|
|||
if(names.find(component->name) != names.end()) {
|
||||
context.attributes["componentName"] = Value::fromString(component->name);
|
||||
auto message = populateMessage(
|
||||
"Pronađeno više instanci sa imenom '{componentName}'", context);
|
||||
"There are multiple component instances named '{componentName}'", context);
|
||||
errors.emplace_back(Action::ERROR, message);
|
||||
}
|
||||
names.insert(component->name);
|
||||
|
@ -234,11 +234,11 @@ namespace domain {
|
|||
auto directConnection = dynamic_cast<DirectConnectionInstance *>(conn.get());
|
||||
if (directConnection != nullptr) {
|
||||
if (directConnection->instance->name == component->name &&
|
||||
directConnection->connection.getComponent().pin == pin.getName()) {
|
||||
busConnection->connection.getComponent().pin == pin.getName()) {
|
||||
return true;
|
||||
}
|
||||
if (directConnection->secondInstance->name == component->name &&
|
||||
directConnection->connection.getSecondComponent()->pin == pin.getName()) {
|
||||
busConnection->connection.getSecondComponent()->pin == pin.getName()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,28 +7,18 @@ namespace domain {
|
|||
}
|
||||
|
||||
ConnectionInstance *Schema::getConnection(string &component, string &pin) {
|
||||
auto pinConnections = getConnections(component, pin);
|
||||
if(pinConnections.empty()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return pinConnections[0];
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ConnectionInstance*> Schema::getConnections(string &component, string &pin) {
|
||||
std::vector<ConnectionInstance*> pinConnections;
|
||||
for (auto &conn: connections) {
|
||||
if (conn->instance->name == component && conn->connection.getComponent().pin == pin) {
|
||||
pinConnections.push_back(conn.get());
|
||||
return conn.get();
|
||||
}
|
||||
auto dirConn = dynamic_cast<DirectConnectionInstance *>(conn.get());
|
||||
if (dirConn != nullptr) {
|
||||
if (dirConn->secondInstance->name == component && conn->connection.getSecondComponent()->pin == pin) {
|
||||
pinConnections.push_back(conn.get());
|
||||
return dirConn;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pinConnections;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BusInstance *Schema::getBusInstance(string &name) {
|
||||
|
|
|
@ -42,8 +42,6 @@ namespace domain {
|
|||
ConnectionInstance *getConnection(string &component, string &pin);
|
||||
|
||||
std::vector<ConnectionEntry> availableConnections(std::string instance, std::string pin, bool onlyConnectable);
|
||||
|
||||
vector<ConnectionInstance *> getConnections(string &component, string &pin);
|
||||
};
|
||||
|
||||
} // namespace domain
|
||||
|
|
Loading…
Reference in New Issue