43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
#include "schema.h"
|
|
|
|
namespace domain {
|
|
|
|
bool Schema::hasConnection(string &component, string &pin) {
|
|
return getConnection(component, pin) != nullptr;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
BusInstance *Schema::getBusInstance(string &name) {
|
|
for (auto &instance: busInstances) {
|
|
if (instance->name == name) {
|
|
return instance.get();
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
ComponentInstance *Schema::getComponentInstance(string &name) {
|
|
for (auto &instance: componentInstances) {
|
|
if (instance->name == name) {
|
|
return instance.get();
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
} // namespace domain
|