add << and >> for serialization

This commit is contained in:
canpadawan
2016-06-29 11:54:36 +02:00
parent 830ca75fba
commit db7ad42199
4 changed files with 55 additions and 23 deletions
+30 -21
View File
@@ -3,10 +3,10 @@
CANBus::CANBus()
{
speed = 250000;
listenOnly = false;
singleWire = false;
active = false;
speed = 250000;
listenOnly = false;
singleWire = false;
active = false;
}
@@ -24,44 +24,53 @@ bool CANBus::operator==(const CANBus& bus) const{
active == bus.active;
}
void CANBus::setSpeed(int newSpeed)
{
void CANBus::setSpeed(int newSpeed){
speed = newSpeed;
}
void CANBus::setListenOnly(bool mode)
{
void CANBus::setListenOnly(bool mode){
listenOnly = mode;
}
void CANBus::setSingleWire(bool mode)
{
void CANBus::setSingleWire(bool mode){
singleWire = mode;
}
void CANBus::setEnabled(bool mode)
{
void CANBus::setEnabled(bool mode){
active = mode;
}
int CANBus::getSpeed()
{
int CANBus::getSpeed(){
return speed;
}
bool CANBus::isListenOnly()
{
bool CANBus::isListenOnly(){
return listenOnly;
}
bool CANBus::isSingleWire()
{
bool CANBus::isSingleWire(){
return singleWire;
}
bool CANBus::isActive()
{
bool CANBus::isActive(){
return active;
}
QDataStream& operator<<( QDataStream & pStream, const CANBus& pCanBus )
{
pStream << pCanBus.speed;
pStream << pCanBus.listenOnly;
pStream << pCanBus.singleWire;
pStream << pCanBus.active;
return pStream;
}
QDataStream & operator>>(QDataStream & pStream, CANBus& pCanBus)
{
pStream >> pCanBus.speed;
pStream >> pCanBus.listenOnly;
pStream >> pCanBus.singleWire;
pStream >> pCanBus.active;
return pStream;
}
+8 -2
View File
@@ -1,6 +1,6 @@
#ifndef CANBus_H
#define CANBus_H
#include <QDataStream>
class CANBus
{
@@ -8,7 +8,8 @@ public:
CANBus();
CANBus(const CANBus&);
bool operator==(const CANBus&) const;
virtual ~CANBus(){}; /*TODO: remove connection from CANBus and add CANBus as an element of CANConnection */
virtual ~CANBus(){};
int speed;
bool listenOnly;
bool singleWire;
@@ -25,4 +26,9 @@ public:
bool isActive();
};
QDataStream& operator<<( QDataStream & pStream, const CANBus& pCanBus );
QDataStream & operator>>(QDataStream & pStream, CANBus& pCanBus);
Q_DECLARE_METATYPE(CANBus);
#endif // CANBus_H
+6
View File
@@ -0,0 +1,6 @@
#include "canconmanager.h"
CANConManager::CANConManager()
{
}
+11
View File
@@ -0,0 +1,11 @@
#ifndef CANCONMANAGER_H
#define CANCONMANAGER_H
class CANConManager
{
public:
CANConManager();
};
#endif // CANCONMANAGER_H