gtouchable
Loading...
Searching...
No Matches
gelectronic.cc
Go to the documentation of this file.
1// gtouchable
2#include "gelectronic.h"
3
4// for UNINITIALIZEDNUMBERQUANTITY
5#include "gutsConventions.h"
6
7
8// Constructor initializing GElectronic with specified address and mode.
9GElectronic::GElectronic(int c, int s, int ch, int m) : crate(c), slot(s), channel(ch), mode(m) {}
10
11// Default constructor initializing GElectronic with uninitialized values.
12GElectronic::GElectronic() : crate(UNINITIALIZEDNUMBERQUANTITY), slot(UNINITIALIZEDNUMBERQUANTITY),
13 channel(UNINITIALIZEDNUMBERQUANTITY), mode(UNINITIALIZEDNUMBERQUANTITY) {}
14
15
16// Sets the hardware address.
17void GElectronic::setHAddress(int c, int s, int ch) {
18 crate = c;
19 slot = s;
20 channel = ch;
21}
22
23// Returns the hardware address as a vector.
24std::vector<int> GElectronic::getHAddress() {
25 return {crate, slot, channel};
26}
27
28// Equality operator comparing based on the mode.
29bool GElectronic::operator==(const GElectronic &ge) const {
30 if (this->mode == 0) {
31 return this->crate == ge.crate;
32 } else if (this->mode == 1) {
33 return this->crate == ge.crate && this->slot == ge.slot;
34 } else if (this->mode == 2) {
35 return this->crate == ge.crate && this->slot == ge.slot && this->channel == ge.channel;
36 }
37 return false;
38}
39
40// Overloaded output stream operator for GElectronic.
41std::ostream &operator<<(std::ostream &stream, const GElectronic &ge) {
42 stream << " Crate: " << ge.crate;
43 stream << " Slot: " << ge.slot;
44 stream << " Channel: " << ge.channel;
45
46 return stream;
47}
std::ostream & operator<<(std::ostream &stream, const GElectronic &ge)
Represents an electronic module address.
Definition gelectronic.h:18
std::vector< int > getHAddress()
Gets the hardware address.
GElectronic()
Default constructor.
void setHAddress(int c, int s, int ch)
Sets the hardware address.