2022-04-05 21:48:07 +00:00
|
|
|
#include "schema.h"
|
|
|
|
|
|
|
|
namespace domain {
|
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
bool Schema::hasConnection(string &component, string &pin) {
|
|
|
|
return getConnection(component, pin) != nullptr;
|
|
|
|
}
|
2022-04-05 21:48:07 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
ConnectionInstance *Schema::getConnection(string &component, string &pin) {
|
|
|
|
for (auto &conn: connections) {
|
|
|
|
if (conn->instance->name == component && conn->connection.getComponent().pin == pin) {
|
|
|
|
return conn.get();
|
|
|
|
}
|
|
|
|
auto dirConn = dynamic_cast<DirectConnectionInstance *>(conn.get());
|
|
|
|
if (dirConn != nullptr) {
|
|
|
|
if (dirConn->secondInstance->name == component && conn->connection.getSecondComponent()->pin == pin) {
|
|
|
|
return dirConn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
2022-05-08 22:51:47 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
BusInstance *Schema::getBusInstance(string &name) {
|
|
|
|
for (auto &instance: busInstances) {
|
|
|
|
if (instance->name == name) {
|
|
|
|
return instance.get();
|
|
|
|
}
|
2022-05-08 22:51:47 +00:00
|
|
|
}
|
2022-05-27 06:18:17 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ComponentInstance *Schema::getComponentInstance(string &name) {
|
|
|
|
for (auto &instance: componentInstances) {
|
|
|
|
if (instance->name == name) {
|
|
|
|
return instance.get();
|
2022-05-08 22:51:47 +00:00
|
|
|
}
|
|
|
|
}
|
2022-05-27 06:18:17 +00:00
|
|
|
return nullptr;
|
2022-05-08 22:51:47 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 21:48:07 +00:00
|
|
|
} // namespace domain
|