Access to the CANBus parameters only through setters/getters

Also removed explicit copy constructor, in such trivial cases
compiler can create all needed copy/move stubs automatically
This commit is contained in:
Alexey Esaulenko
2024-01-19 14:58:30 +04:00
parent 43ea48575f
commit 3dc426a5b8
3 changed files with 34 additions and 41 deletions
+17 -16
View File
@@ -5,13 +5,6 @@
class CANBus
{
public:
CANBus();
CANBus(const CANBus&);
bool operator==(const CANBus&) const;
CANBus& operator=(const CANBus& other) = default;
//virtual ~CANBus(){}
int speed;
bool listenOnly;
bool singleWire;
@@ -19,28 +12,36 @@ public:
bool canFD;
int dataRate;
friend QDataStream& operator<<(QDataStream & pStream, const CANBus& pCanBus);
friend QDataStream& operator>>(QDataStream & pStream, CANBus& pCanBus);
public:
CANBus();
bool operator==(const CANBus&) const;
void setSpeed(int); // new speed
void setListenOnly(bool); //bool for whether to only listen
void setSingleWire(bool); //bool for whether to use single wire mode
void setActive(bool); //whether this bus should be enabled or not.
void setCanFD(bool); // enable or disable CANFD support
int getSpeed();
int getDataRate();
void setDataRate(int newSpeed);
bool isListenOnly();
bool isSingleWire();
bool isActive();
bool isCanFD();
int getSpeed() const;
int getDataRate() const;
bool isListenOnly() const;
bool isSingleWire() const;
bool isActive() const;
bool isCanFD() const;
};
QDataStream& operator<<( QDataStream & pStream, const CANBus& pCanBus );
QDataStream & operator>>(QDataStream & pStream, CANBus& pCanBus);
QDataStream& operator<<(QDataStream & pStream, const CANBus& pCanBus);
QDataStream& operator>>(QDataStream & pStream, CANBus& pCanBus);
Q_DECLARE_METATYPE(CANBus);
struct BusData {
CANBus mBus;
bool mConfigured;
bool mConfigured = {};
QVector<CANFltObserver> mTargettedFrames;
};