schema_editor/comdel/domain/library.cpp

79 lines
2.2 KiB
C++
Raw Normal View History

2022-03-31 21:20:41 +00:00
#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;
}
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();
}
std::optional<Connection> Library::getConnection(std::string component, std::string pin, std::string bus) {
for(uint i=0; i<connections.size(); i++) {
if(connections[i].isConnecting(component, pin, bus)) {
return connections[i];
}
}
return nullopt;
}
std::string Library::getMessage(std::string key) {
return messages[key];
}
} // namespace domain