37enum class State :
unsigned char {
54using Component_set = std::set<Component_ptr, std::owner_less<Component_ptr>>;
58 static inline std::atomic<uint64_t>
nextId{0};
90 [[nodiscard]] uint64_t
getId()
const {
return id; }
134[[nodiscard]] std::pair<BusValue, BusValue>
144 explicit Bus(
unsigned short size);
146 Bus(std::initializer_list<Wire> initList);
147 Bus(std::initializer_list<Wire_ptr> initList);
170 {
return this->busData.at(index); }
174 explicit operator std::vector<Wire_ptr>()
const {
return this->busData; }
175 explicit operator std::vector<Wire_ptr>() {
return this->busData; }
177 auto begin() {
return this->busData.begin(); }
178 auto end() {
return this->busData.end(); }
180 [[nodiscard]]
auto begin()
const {
return this->busData.begin(); }
181 [[nodiscard]]
auto end()
const {
return this->busData.end(); }
183 [[nodiscard]]
auto size() {
return this->busData.size(); }
184 [[nodiscard]]
auto size()
const {
return this->busData.size(); }
bool setCurrentValue(const BusValue &value, const Component_weakPtr &requestedBy)
const Wire_ptr & operator[](const unsigned short index) const
bool forceSetCurrentValue(const BusValue &value)
bool operator==(const Bus &other) const
Wire_ptr & operator[](const unsigned short index)
std::vector< Wire_ptr > busData
bool isInErrorState() const
bool sharesWireWith(const Bus &other) const
void setSize(unsigned short size)
std::strong_ordering operator<=>(const Bus &other) const
BusValue getCurrentValue() const
State getCurrentState() const
Reads the current state safely while simulation may update it.
static State safeGetCurrentState(const std::weak_ptr< Wire > &w)
void clearAuthorizedComponent()
Clears the component currently authorized to drive this wire.
static std::atomic< uint64_t > nextId
Component_weakPtr authorizedComponent
void setCurrentState(State newState, const Component_weakPtr &requestedBy)
static void safeSetCurrentState(const std::weak_ptr< Wire > &w, State newState, const Component_weakPtr &requestedBy)
std::atomic< State > currentState
State shared between the simulation worker and UI readers.
Wire & operator=(const Wire &other)
Assigns state, authorization, and identifier from another wire.
void forceSetCurrentState(State newState)
std::shared_ptr< Component > Component_ptr
std::shared_ptr< Wire > Wire_ptr
BusValue shift(const BusValue &v, const ptrdiff_t amount, const Signedness signedness)
State operator!(const State &a)
BusValue operator+(const BusValue &a, const BusValue &b)
std::partial_ordering compare(const BusValue &lhs, const BusValue &rhs, const Signedness signedness)
State operator||(const State &a, const State &b)
std::pair< BusValue, BusValue > divide(const BusValue &a, const BusValue &b, Signedness signedness)
std::set< Component_ptr, std::owner_less< Component_ptr > > Component_set
State operator&&(const State &a, const State &b)
State operator^(const State &a, const State &b)
BusValue twosComplement(const BusValue &n)
std::weak_ptr< Component > Component_weakPtr
std::string to_str(State s)
BusValue multiply(const BusValue &a, const BusValue &b, const Signedness signedness)
std::vector< State > BusValue