Pass around an EventRef instead of a raw Event pointer. This is safer
This commit is contained in:
parent
148fd52c76
commit
42beb57169
7 changed files with 10 additions and 12 deletions
|
@ -4,11 +4,11 @@
|
|||
|
||||
class Controller::PrivateData {
|
||||
public:
|
||||
TelldusCore::Event *event;
|
||||
TelldusCore::EventRef event;
|
||||
int id;
|
||||
};
|
||||
|
||||
Controller::Controller(int id, TelldusCore::Event *event){
|
||||
Controller::Controller(int id, TelldusCore::EventRef event){
|
||||
d = new PrivateData;
|
||||
d->event = event;
|
||||
d->id = id;
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
virtual int reset() = 0;
|
||||
|
||||
protected:
|
||||
Controller(int id, TelldusCore::Event *event);
|
||||
Controller(int id, TelldusCore::EventRef event);
|
||||
void publishData(const std::string &data) const;
|
||||
void decodePublishData(const std::string &data) const;
|
||||
|
||||
|
|
|
@ -25,11 +25,11 @@ public:
|
|||
int lastControllerId;
|
||||
Settings settings;
|
||||
ControllerMap controllers;
|
||||
TelldusCore::Event *event;
|
||||
TelldusCore::EventRef event;
|
||||
TelldusCore::Mutex mutex;
|
||||
};
|
||||
|
||||
ControllerManager::ControllerManager(TelldusCore::Event *event){
|
||||
ControllerManager::ControllerManager(TelldusCore::EventRef event){
|
||||
d = new PrivateData;
|
||||
d->lastControllerId = 0;
|
||||
d->event = event;
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
#ifndef CONTROLLERMANAGER_H
|
||||
#define CONTROLLERMANAGER_H
|
||||
|
||||
#include "Event.h"
|
||||
class Controller;
|
||||
namespace TelldusCore {
|
||||
class Event;
|
||||
}
|
||||
|
||||
#include <string>
|
||||
|
||||
class ControllerManager {
|
||||
public:
|
||||
ControllerManager(TelldusCore::Event *event);
|
||||
ControllerManager(TelldusCore::EventRef event);
|
||||
~ControllerManager(void);
|
||||
|
||||
void deviceInsertedOrRemoved(int vid, int pid, const std::string &serial, bool inserted);
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
class TellStick : public Controller, public TelldusCore::Thread {
|
||||
public:
|
||||
TellStick(int controllerId, TelldusCore::Event *event, const TellStickDescriptor &d);
|
||||
TellStick(int controllerId, TelldusCore::EventRef event, const TellStickDescriptor &d);
|
||||
virtual ~TellStick();
|
||||
|
||||
virtual int firmwareVersion();
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
#endif
|
||||
};
|
||||
|
||||
TellStick::TellStick(int controllerId, TelldusCore::Event *event, const TellStickDescriptor &td )
|
||||
TellStick::TellStick(int controllerId, TelldusCore::EventRef event, const TellStickDescriptor &td )
|
||||
:Controller(controllerId, event)
|
||||
{
|
||||
d = new PrivateData;
|
||||
|
|
|
@ -64,7 +64,7 @@ void TelldusMain::start(void) {
|
|||
supervisor.setInterval(60); //Once every minute
|
||||
supervisor.start();
|
||||
|
||||
ControllerManager controllerManager(dataEvent.get());
|
||||
ControllerManager controllerManager(dataEvent);
|
||||
EventUpdateManager eventUpdateManager;
|
||||
TelldusCore::EventRef deviceUpdateEvent = eventUpdateManager.retrieveUpdateEvent();
|
||||
eventUpdateManager.start();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue