114 lines
3.2 KiB
C++
114 lines
3.2 KiB
C++
#include "library.h"
|
|
|
|
namespace domain {
|
|
|
|
Library::Library(string name, string libraryInfo, string header, string componentDirectory,
|
|
vector<AddressSpace> addressSpaces, vector<Component> components, vector<Bus> buses, vector<Connection> connections, map<string, string> messages)
|
|
: name(name), libraryInfo(libraryInfo), header(header), componentDirectory(componentDirectory), addressSpaces(addressSpaces),
|
|
components(components), buses(buses), connections(connections), messages(messages)
|
|
{}
|
|
|
|
std::string Library::getName() {
|
|
return name;
|
|
}
|
|
std::string Library::getLibraryInfo() {
|
|
return libraryInfo;
|
|
}
|
|
std::string Library::getHeader() {
|
|
return header;
|
|
}
|
|
std::string Library::getComponentDirectory() {
|
|
return componentDirectory;
|
|
}
|
|
|
|
std::vector<AddressSpace> Library::getAddressSpaces() {
|
|
return addressSpaces;
|
|
}
|
|
std::vector<Component> Library::getComponents() {
|
|
return components;
|
|
}
|
|
std::vector<Bus> Library::getBuses() {
|
|
return buses;
|
|
}
|
|
std::vector<Connection> Library::getConnections() {
|
|
return connections;
|
|
}
|
|
|
|
std::map<std::string, std::string> Library::getMessages() {
|
|
return messages;
|
|
}
|
|
|
|
bool Library::hasComponent(std::string name) {
|
|
for(uint i=0; i<components.size(); i++) {
|
|
if(components[i].getName() == name) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
bool Library::hasBus(std::string name) {
|
|
for(uint i=0; i<buses.size(); i++) {
|
|
if(buses[i].getName() == name) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
AddressSpace &Library::getAddressSpace(std::string addressSpace) {
|
|
for(uint i=0; i<addressSpaces.size(); i++) {
|
|
if(addressSpaces[i].getName() == addressSpace) {
|
|
return addressSpaces[i];
|
|
}
|
|
}
|
|
throw std::exception();
|
|
}
|
|
Component &Library::getComponent(std::string component) {
|
|
for(uint i=0; i<components.size(); i++) {
|
|
if(components[i].getName() == component) {
|
|
return components[i];
|
|
}
|
|
}
|
|
throw std::exception();
|
|
}
|
|
Bus &Library::getBus(std::string bus) {
|
|
for(uint i=0; i<buses.size(); i++) {
|
|
if(buses[i].getName() == bus) {
|
|
return buses[i];
|
|
}
|
|
}
|
|
throw std::exception();
|
|
|
|
}
|
|
|
|
bool Library::hasConnection(ConnectionComponent component, std::string bus) {
|
|
return getConnection(component, bus).has_value();
|
|
}
|
|
std::optional<Connection> Library::getConnection(ConnectionComponent component, std::string bus) {
|
|
for(uint i=0; i<connections.size(); i++) {
|
|
if(connections[i].isConnecting(component, bus)) {
|
|
return connections[i];
|
|
}
|
|
}
|
|
return nullopt;
|
|
}
|
|
|
|
bool Library::hasConnection(ConnectionComponent component, std::string bus, ConnectionComponent secondComponent) {
|
|
return getConnection(component, bus, secondComponent).has_value();
|
|
}
|
|
std::optional<Connection> Library::getConnection(ConnectionComponent component, std::string bus, ConnectionComponent secondComponent) {
|
|
for(uint i=0; i<connections.size(); i++) {
|
|
if(connections[i].isConnecting(component, bus, secondComponent)) {
|
|
return connections[i];
|
|
}
|
|
}
|
|
return nullopt;
|
|
}
|
|
|
|
std::string Library::getMessage(std::string key) {
|
|
return messages[key];
|
|
}
|
|
|
|
} // namespace domain
|