schema_editor/comdel/domain/connection.h

62 lines
1.5 KiB
C
Raw Normal View History

2022-03-31 21:20:41 +00:00
#ifndef DOMAIN_CONNECTION_H
#define DOMAIN_CONNECTION_H
#include "attribute.h"
#include <string>
#include <vector>
namespace domain {
2022-04-09 17:44:02 +00:00
struct ConnectionComponent
2022-03-31 21:20:41 +00:00
{
std::string component;
std::string pin;
2022-04-09 17:44:02 +00:00
bool operator==(const ConnectionComponent& rhs) const
{
return (component == rhs.component) && (pin == rhs.pin);
}
bool operator!=(const ConnectionComponent& rhs) const
{
return !operator==(rhs);
}
};
class Connection
{
ConnectionComponent first;
std::optional<ConnectionComponent> second;
std::string bus;
2022-03-31 21:20:41 +00:00
std::vector<Attribute> attributes;
2022-04-09 17:44:02 +00:00
std::vector<Value> firstWires;
std::optional<std::vector<Value>> secondWires;
2022-03-31 21:20:41 +00:00
public:
2022-04-09 17:44:02 +00:00
Connection(ConnectionComponent first, std::optional<ConnectionComponent> second,
std::string bus, std::vector<Attribute> attributes,
std::vector<Value> firstWires, std::optional<std::vector<Value>> secondWires);
bool isConnecting(ConnectionComponent first);
bool isConnecting(ConnectionComponent first, std::string bus);
bool isConnecting(ConnectionComponent first, std::string bus, ConnectionComponent second);
2022-03-31 21:20:41 +00:00
2022-04-09 17:44:02 +00:00
ConnectionComponent getComponent();
std::optional<ConnectionComponent> getSecondComponent();
2022-03-31 21:20:41 +00:00
std::string getBus();
std::vector<Attribute> getAttributes();
2022-04-09 17:44:02 +00:00
2022-03-31 21:20:41 +00:00
std::vector<Value> getWires();
2022-04-09 17:44:02 +00:00
std::optional<std::vector<Value>> getSecondWires();
2022-03-31 21:20:41 +00:00
Attribute getAttribute(std::string name);
2022-04-05 21:48:07 +00:00
bool hasAttribute(std::string name);
2022-03-31 21:20:41 +00:00
};
} // namespace domain
#endif // DOMAIN_CONNECTION_H