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 {
|
class Controller::PrivateData {
|
||||||
public:
|
public:
|
||||||
TelldusCore::Event *event;
|
TelldusCore::EventRef event;
|
||||||
int id;
|
int id;
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller::Controller(int id, TelldusCore::Event *event){
|
Controller::Controller(int id, TelldusCore::EventRef event){
|
||||||
d = new PrivateData;
|
d = new PrivateData;
|
||||||
d->event = event;
|
d->event = event;
|
||||||
d->id = id;
|
d->id = id;
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
virtual int reset() = 0;
|
virtual int reset() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Controller(int id, TelldusCore::Event *event);
|
Controller(int id, TelldusCore::EventRef event);
|
||||||
void publishData(const std::string &data) const;
|
void publishData(const std::string &data) const;
|
||||||
void decodePublishData(const std::string &data) const;
|
void decodePublishData(const std::string &data) const;
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,11 @@ public:
|
||||||
int lastControllerId;
|
int lastControllerId;
|
||||||
Settings settings;
|
Settings settings;
|
||||||
ControllerMap controllers;
|
ControllerMap controllers;
|
||||||
TelldusCore::Event *event;
|
TelldusCore::EventRef event;
|
||||||
TelldusCore::Mutex mutex;
|
TelldusCore::Mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
ControllerManager::ControllerManager(TelldusCore::Event *event){
|
ControllerManager::ControllerManager(TelldusCore::EventRef event){
|
||||||
d = new PrivateData;
|
d = new PrivateData;
|
||||||
d->lastControllerId = 0;
|
d->lastControllerId = 0;
|
||||||
d->event = event;
|
d->event = event;
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
#ifndef CONTROLLERMANAGER_H
|
#ifndef CONTROLLERMANAGER_H
|
||||||
#define CONTROLLERMANAGER_H
|
#define CONTROLLERMANAGER_H
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
class Controller;
|
class Controller;
|
||||||
namespace TelldusCore {
|
|
||||||
class Event;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class ControllerManager {
|
class ControllerManager {
|
||||||
public:
|
public:
|
||||||
ControllerManager(TelldusCore::Event *event);
|
ControllerManager(TelldusCore::EventRef event);
|
||||||
~ControllerManager(void);
|
~ControllerManager(void);
|
||||||
|
|
||||||
void deviceInsertedOrRemoved(int vid, int pid, const std::string &serial, bool inserted);
|
void deviceInsertedOrRemoved(int vid, int pid, const std::string &serial, bool inserted);
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
|
|
||||||
class TellStick : public Controller, public TelldusCore::Thread {
|
class TellStick : public Controller, public TelldusCore::Thread {
|
||||||
public:
|
public:
|
||||||
TellStick(int controllerId, TelldusCore::Event *event, const TellStickDescriptor &d);
|
TellStick(int controllerId, TelldusCore::EventRef event, const TellStickDescriptor &d);
|
||||||
virtual ~TellStick();
|
virtual ~TellStick();
|
||||||
|
|
||||||
virtual int firmwareVersion();
|
virtual int firmwareVersion();
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
TellStick::TellStick(int controllerId, TelldusCore::Event *event, const TellStickDescriptor &td )
|
TellStick::TellStick(int controllerId, TelldusCore::EventRef event, const TellStickDescriptor &td )
|
||||||
:Controller(controllerId, event)
|
:Controller(controllerId, event)
|
||||||
{
|
{
|
||||||
d = new PrivateData;
|
d = new PrivateData;
|
||||||
|
|
|
@ -64,7 +64,7 @@ void TelldusMain::start(void) {
|
||||||
supervisor.setInterval(60); //Once every minute
|
supervisor.setInterval(60); //Once every minute
|
||||||
supervisor.start();
|
supervisor.start();
|
||||||
|
|
||||||
ControllerManager controllerManager(dataEvent.get());
|
ControllerManager controllerManager(dataEvent);
|
||||||
EventUpdateManager eventUpdateManager;
|
EventUpdateManager eventUpdateManager;
|
||||||
TelldusCore::EventRef deviceUpdateEvent = eventUpdateManager.retrieveUpdateEvent();
|
TelldusCore::EventRef deviceUpdateEvent = eventUpdateManager.retrieveUpdateEvent();
|
||||||
eventUpdateManager.start();
|
eventUpdateManager.start();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue