Changeset e83416
- Timestamp:
- 02/03/12 17:09:38 (3 months ago)
- Branches:
- ('master', 'deebf2045e7119c339412580f37a1e653f7d5715')('controller-upgrade', '00f95d22e12d96ef089e0902ef62ae8ce841dc6f')
- Children:
- ba9c50f6251736f1ee21a6071cb6d80ed267029f
- Parents:
- 12506815144a25f959a1c78776ad82fa8970b5a3
- git-author:
- Micke Prag <micke.prag@telldus.se>2012-02-03 17:09:38+01:00
- git-committer:
- Micke Prag <micke.prag@telldus.se>2012-02-03 17:09:38+01:00
- Location:
- telldus-core
- Files:
-
- 23 edited
-
common/Event.cpp (modified) (2 diffs)
-
common/Event.h (modified) (1 diff)
-
common/EventHandler.h (modified) (1 diff)
-
common/EventHandler_unix.cpp (modified) (1 diff)
-
common/Event_unix.cpp (modified) (1 diff)
-
service/ClientCommunicationHandler.cpp (modified) (2 diffs)
-
service/ClientCommunicationHandler.h (modified) (1 diff)
-
service/ConnectionListener.h (modified) (2 diffs)
-
service/ConnectionListener_unix.cpp (modified) (3 diffs)
-
service/Controller.cpp (modified) (2 diffs)
-
service/Controller.h (modified) (3 diffs)
-
service/ControllerListener.h (modified) (2 diffs)
-
service/ControllerManager.cpp (modified) (1 diff)
-
service/ControllerManager.h (modified) (2 diffs)
-
service/DeviceManager.cpp (modified) (1 diff)
-
service/DeviceManager.h (modified) (1 diff)
-
service/EventUpdateManager.cpp (modified) (4 diffs)
-
service/EventUpdateManager.h (modified) (2 diffs)
-
service/TellStick.h (modified) (1 diff)
-
service/TellStick_libftdi.cpp (modified) (1 diff)
-
service/TelldusMain.cpp (modified) (7 diffs)
-
service/Timer.cpp (modified) (2 diffs)
-
service/Timer.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
telldus-core/common/Event.cpp
r938187 re83416 4 4 5 5 #include <list> 6 7 using namespace TelldusCore; 6 8 7 9 EventData::~EventData() { … … 23 25 }; 24 26 25 EventBase::EventBase( EventHandler *handler) {27 EventBase::EventBase(TelldusCore::EventHandler *handler) { 26 28 d = new PrivateData; 27 29 d->handler = handler; -
telldus-core/common/Event.h
r938187 re83416 2 2 #define EVENT_H 3 3 4 class EventHandler;5 4 #include "Thread.h" 6 5 7 6 #ifdef _WINDOWS 8 #include <windows.h>9 #include <memory>7 #include <windows.h> 8 #include <memory> 10 9 typedef HANDLE EVENT_T; 11 10 #else 12 #include <tr1/memory>11 #include <tr1/memory> 13 12 typedef void* EVENT_T; 14 13 #endif 15 14 16 class EventData { 17 public: 18 virtual ~EventData(); 19 virtual bool isValid() const; 20 }; 15 namespace TelldusCore { 16 class EventHandler; 21 17 22 class EventDataBase : public EventData { 23 public: 24 virtual bool isValid() const; 25 }; 18 class EventData { 19 public: 20 virtual ~EventData(); 21 virtual bool isValid() const; 22 }; 26 23 27 typedef std::tr1::shared_ptr<EventData> EventDataRef; 24 class EventDataBase : public EventData { 25 public: 26 virtual bool isValid() const; 27 }; 28 28 29 class EventBase { 30 public: 31 virtual ~EventBase(); 29 typedef std::tr1::shared_ptr<EventData> EventDataRef; 32 30 33 void popSignal(); 34 bool isSignaled(); 35 void signal(); 36 virtual void signal(EventData *); 37 EventDataRef takeSignal(); 31 class EventBase { 32 public: 33 virtual ~EventBase(); 38 34 39 protected: 40 EventBase(EventHandler *handler); 41 void clearHandler(); 42 virtual void clearSignal() = 0; 43 EventHandler *handler() const; 44 virtual void sendSignal() = 0; 35 void popSignal(); 36 bool isSignaled(); 37 void signal(); 38 virtual void signal(EventData *); 39 EventDataRef takeSignal(); 45 40 46 private: 47 class PrivateData; 48 PrivateData *d; 49 }; 41 protected: 42 EventBase(EventHandler *handler); 43 void clearHandler(); 44 virtual void clearSignal() = 0; 45 EventHandler *handler() const; 46 virtual void sendSignal() = 0; 50 47 51 class Event : public EventBase { 52 public: 53 virtual ~Event(); 48 private: 49 class PrivateData; 50 PrivateData *d; 51 }; 54 52 55 protected: 56 Event(EventHandler *handler); 57 EVENT_T retrieveNative(); 58 virtual void clearSignal(); 59 virtual void sendSignal(); 53 class Event : public EventBase { 54 public: 55 virtual ~Event(); 60 56 61 private: 62 class PrivateData; 63 PrivateData *d; 57 protected: 58 Event(EventHandler *handler); 59 EVENT_T retrieveNative(); 60 virtual void clearSignal(); 61 virtual void sendSignal(); 64 62 65 friend class EventHandler; 66 }; 63 private: 64 class PrivateData; 65 PrivateData *d; 67 66 68 typedef std::tr1::shared_ptr<Event> EventRef; 67 friend class EventHandler; 68 }; 69 70 typedef std::tr1::shared_ptr<Event> EventRef; 71 } 69 72 70 73 #endif //EVENT_H -
telldus-core/common/EventHandler.h
r938187 re83416 4 4 #include "Event.h" 5 5 6 class EventHandler { 7 public: 8 EventHandler(); 9 virtual ~EventHandler(void); 6 namespace TelldusCore { 10 7 11 EventRef addEvent(); 8 class EventHandler { 9 public: 10 EventHandler(); 11 virtual ~EventHandler(void); 12 12 13 bool waitForAny();13 EventRef addEvent(); 14 14 15 protected: 16 void signal(Event *event); 15 bool waitForAny(); 17 16 18 private: 19 class PrivateData; 20 PrivateData *d; 21 bool listIsSignalled(); 17 protected: 18 void signal(Event *event); 22 19 23 friend class Event; 24 }; 20 private: 21 class PrivateData; 22 PrivateData *d; 23 bool listIsSignalled(); 24 25 friend class Event; 26 }; 27 } 25 28 26 29 #endif //EVENTHANDLER_H -
telldus-core/common/EventHandler_unix.cpp
r938187 re83416 6 6 #include <pthread.h> 7 7 #include <stdio.h> 8 9 using namespace TelldusCore; 8 10 9 11 class EventHandler::PrivateData { -
telldus-core/common/Event_unix.cpp
r938187 re83416 2 2 #include "EventHandler.h" 3 3 #include "Thread.h" 4 5 using namespace TelldusCore; 4 6 5 7 class Event::PrivateData { -
telldus-core/service/ClientCommunicationHandler.cpp
rb84e8b re83416 8 8 public: 9 9 TelldusCore::Socket *clientSocket; 10 EventRef event, deviceUpdateEvent;10 TelldusCore::EventRef event, deviceUpdateEvent; 11 11 bool done; 12 12 DeviceManager *deviceManager; … … 17 17 } 18 18 19 ClientCommunicationHandler::ClientCommunicationHandler(TelldusCore::Socket *clientSocket, EventRef event, DeviceManager *deviceManager,EventRef deviceUpdateEvent)19 ClientCommunicationHandler::ClientCommunicationHandler(TelldusCore::Socket *clientSocket, TelldusCore::EventRef event, DeviceManager *deviceManager, TelldusCore::EventRef deviceUpdateEvent) 20 20 :Thread() 21 21 { -
telldus-core/service/ClientCommunicationHandler.h
r41c763 re83416 13 13 public: 14 14 ClientCommunicationHandler(); 15 ClientCommunicationHandler(TelldusCore::Socket *clientSocket, EventRef event, DeviceManager *deviceManager,EventRef deviceUpdateEvent);15 ClientCommunicationHandler(TelldusCore::Socket *clientSocket, TelldusCore::EventRef event, DeviceManager *deviceManager, TelldusCore::EventRef deviceUpdateEvent); 16 16 ~ClientCommunicationHandler(void); 17 17 -
telldus-core/service/ConnectionListener.h
r41c763 re83416 11 11 }; 12 12 13 class ConnectionListenerEventData : public EventDataBase {13 class ConnectionListenerEventData : public TelldusCore::EventDataBase { 14 14 public: 15 15 TelldusCore::Socket *socket; … … 18 18 class ConnectionListener : public TelldusCore::Thread { 19 19 public: 20 ConnectionListener(const std::wstring &name, EventRef waitEvent);20 ConnectionListener(const std::wstring &name, TelldusCore::EventRef waitEvent); 21 21 virtual ~ConnectionListener(void); 22 22 -
telldus-core/service/ConnectionListener_unix.cpp
rbf4589 re83416 15 15 class ConnectionListener::PrivateData { 16 16 public: 17 EventRef waitEvent;17 TelldusCore::EventRef waitEvent; 18 18 std::string name; 19 19 bool running; 20 20 }; 21 21 22 ConnectionListener::ConnectionListener(const std::wstring &name, EventRef waitEvent)22 ConnectionListener::ConnectionListener(const std::wstring &name, TelldusCore::EventRef waitEvent) 23 23 { 24 24 d = new PrivateData; … … 57 57 bind(serverSocket, (struct sockaddr *)&name, size); 58 58 listen(serverSocket, 5); 59 59 60 60 //Change permissions to allow everyone 61 61 chmod(d->name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); … … 81 81 } 82 82 SOCKET_T clientSocket = accept(serverSocket, NULL, NULL); 83 83 84 84 ConnectionListenerEventData *data = new ConnectionListenerEventData(); 85 85 data->socket = new TelldusCore::Socket(clientSocket); -
telldus-core/service/Controller.cpp
r0b12c5 re83416 5 5 class Controller::PrivateData { 6 6 public: 7 Event *event;7 TelldusCore::Event *event; 8 8 int id; 9 9 }; 10 10 11 Controller::Controller(int id, Event *event){11 Controller::Controller(int id, TelldusCore::Event *event){ 12 12 d = new PrivateData; 13 13 d->event = event; … … 29 29 30 30 std::list<std::string> msgList = Protocol::decodeData(data); 31 31 32 32 for (std::list<std::string>::iterator msgIt = msgList.begin(); msgIt != msgList.end(); ++msgIt){ 33 33 this->publishData(*msgIt); -
telldus-core/service/Controller.h
r06ac02 re83416 5 5 #include <string> 6 6 7 class ControllerEventData : public EventDataBase {7 class ControllerEventData : public TelldusCore::EventDataBase { 8 8 public: 9 9 std::string msg; … … 12 12 13 13 class Controller { 14 public: 14 public: 15 15 virtual ~Controller(); 16 16 … … 20 20 21 21 protected: 22 Controller(int id, Event *event);22 Controller(int id, TelldusCore::Event *event); 23 23 void publishData(const std::string &data) const; 24 24 void decodePublishData(const std::string &data) const; -
telldus-core/service/ControllerListener.h
r46bc83 re83416 5 5 #include "Event.h" 6 6 7 class ControllerChangeEventData : public EventDataBase {7 class ControllerChangeEventData : public TelldusCore::EventDataBase { 8 8 public: 9 9 int vid, pid; … … 13 13 class ControllerListener : public TelldusCore::Thread { 14 14 public: 15 ControllerListener( EventRef event);15 ControllerListener(TelldusCore::EventRef event); 16 16 virtual ~ControllerListener(); 17 17 18 18 protected: 19 19 void run(); 20 21 private: 20 21 private: 22 22 class PrivateData; 23 23 PrivateData *d; -
telldus-core/service/ControllerManager.cpp
rc35be6 re83416 15 15 int lastControllerId; 16 16 ControllerMap controllers; 17 Event *event;17 TelldusCore::Event *event; 18 18 TelldusCore::Mutex mutex; 19 19 }; 20 20 21 ControllerManager::ControllerManager( Event *event){21 ControllerManager::ControllerManager(TelldusCore::Event *event){ 22 22 d = new PrivateData; 23 23 d->lastControllerId = 0; -
telldus-core/service/ControllerManager.h
r673daf re83416 3 3 4 4 class Controller; 5 class Event; 5 namespace TelldusCore { 6 class Event; 7 } 6 8 7 9 #include <string> … … 9 11 class ControllerManager { 10 12 public: 11 ControllerManager( Event *event);13 ControllerManager(TelldusCore::Event *event); 12 14 ~ControllerManager(void); 13 15 -
telldus-core/service/DeviceManager.cpp
rb84e8b re83416 22 22 TelldusCore::Mutex lock; 23 23 ControllerManager *controllerManager; 24 EventRef deviceUpdateEvent;24 TelldusCore::EventRef deviceUpdateEvent; 25 25 }; 26 26 27 DeviceManager::DeviceManager(ControllerManager *controllerManager, EventRef deviceUpdateEvent){27 DeviceManager::DeviceManager(ControllerManager *controllerManager, TelldusCore::EventRef deviceUpdateEvent){ 28 28 d = new PrivateData; 29 29 d->controllerManager = controllerManager; -
telldus-core/service/DeviceManager.h
r856e23 re83416 13 13 { 14 14 public: 15 DeviceManager(ControllerManager *controllerManager, EventRef deviceUpdateEvent);15 DeviceManager(ControllerManager *controllerManager, TelldusCore::EventRef deviceUpdateEvent); 16 16 ~DeviceManager(void); 17 17 int getNumberOfDevices(void); -
telldus-core/service/EventUpdateManager.cpp
r86554b re83416 13 13 class EventUpdateManager::PrivateData { 14 14 public: 15 EventHandler eventHandler;16 EventRef stopEvent, updateEvent, clientConnectEvent;15 TelldusCore::EventHandler eventHandler; 16 TelldusCore::EventRef stopEvent, updateEvent, clientConnectEvent; 17 17 SocketList clients; 18 18 ConnectionListener *eventUpdateClientListener; … … 41 41 } 42 42 43 EventRef EventUpdateManager::retrieveUpdateEvent(){43 TelldusCore::EventRef EventUpdateManager::retrieveUpdateEvent(){ 44 44 45 45 return d->updateEvent; … … 55 55 if(d->clientConnectEvent->isSignaled()){ 56 56 //new client added 57 EventDataRef eventData = d->clientConnectEvent->takeSignal();57 TelldusCore::EventDataRef eventData = d->clientConnectEvent->takeSignal(); 58 58 ConnectionListenerEventData *data = reinterpret_cast<ConnectionListenerEventData*>(eventData.get()); 59 59 if(data){ … … 63 63 else if(d->updateEvent->isSignaled()){ 64 64 //device event, signal all clients 65 EventDataRef eventData = d->updateEvent->takeSignal();65 TelldusCore::EventDataRef eventData = d->updateEvent->takeSignal(); 66 66 EventUpdateData *data = reinterpret_cast<EventUpdateData*>(eventData.get()); 67 67 if(data){ -
telldus-core/service/EventUpdateManager.h
r8f2413 re83416 5 5 #include "Event.h" 6 6 7 class EventUpdateData : public EventDataBase {7 class EventUpdateData : public TelldusCore::EventDataBase { 8 8 public: 9 9 std::wstring messageType; … … 30 30 ~EventUpdateManager(void); 31 31 32 EventRef retrieveUpdateEvent();33 EventRef retrieveClientConnectEvent();32 TelldusCore::EventRef retrieveUpdateEvent(); 33 TelldusCore::EventRef retrieveClientConnectEvent(); 34 34 35 35 protected: -
telldus-core/service/TellStick.h
r06ac02 re83416 25 25 class TellStick : public Controller, public TelldusCore::Thread { 26 26 public: 27 TellStick(int controllerId, Event *event, const TellStickDescriptor &d);27 TellStick(int controllerId, TelldusCore::Event *event, const TellStickDescriptor &d); 28 28 virtual ~TellStick(); 29 29 -
telldus-core/service/TellStick_libftdi.cpp
rd32633 re83416 43 43 }; 44 44 45 TellStick::TellStick(int controllerId, Event *event, const TellStickDescriptor &td )45 TellStick::TellStick(int controllerId, TelldusCore::Event *event, const TellStickDescriptor &td ) 46 46 :Controller(controllerId, event) 47 47 { -
telldus-core/service/TelldusMain.cpp
r5f1d6e re83416 16 16 class TelldusMain::PrivateData { 17 17 public: 18 EventHandler eventHandler;19 EventRef stopEvent, controllerChangeEvent;18 TelldusCore::EventHandler eventHandler; 19 TelldusCore::EventRef stopEvent, controllerChangeEvent; 20 20 }; 21 21 … … 58 58 59 59 void TelldusMain::start(void) { 60 EventRef clientEvent = d->eventHandler.addEvent();61 EventRef dataEvent = d->eventHandler.addEvent();62 EventRef janitor = d->eventHandler.addEvent(); //Used for regular cleanups60 TelldusCore::EventRef clientEvent = d->eventHandler.addEvent(); 61 TelldusCore::EventRef dataEvent = d->eventHandler.addEvent(); 62 TelldusCore::EventRef janitor = d->eventHandler.addEvent(); //Used for regular cleanups 63 63 Timer supervisor(janitor); //Tells the janitor to go back to work 64 64 supervisor.setInterval(60); //Once every minute … … 67 67 ControllerManager controllerManager(dataEvent.get()); 68 68 EventUpdateManager eventUpdateManager; 69 EventRef deviceUpdateEvent = eventUpdateManager.retrieveUpdateEvent();69 TelldusCore::EventRef deviceUpdateEvent = eventUpdateManager.retrieveUpdateEvent(); 70 70 eventUpdateManager.start(); 71 71 DeviceManager deviceManager(&controllerManager, deviceUpdateEvent); … … 75 75 std::list<ClientCommunicationHandler *> clientCommunicationHandlerList; 76 76 77 EventRef handlerEvent = d->eventHandler.addEvent();77 TelldusCore::EventRef handlerEvent = d->eventHandler.addEvent(); 78 78 79 79 #ifdef _MACOSX … … 89 89 if (clientEvent->isSignaled()) { 90 90 //New client connection 91 EventDataRef eventDataRef = clientEvent->takeSignal();91 TelldusCore::EventDataRef eventDataRef = clientEvent->takeSignal(); 92 92 ConnectionListenerEventData *data = reinterpret_cast<ConnectionListenerEventData*>(eventDataRef.get()); 93 93 if (data) { … … 99 99 100 100 if (d->controllerChangeEvent->isSignaled()) { 101 EventDataRef eventDataRef = d->controllerChangeEvent->takeSignal();101 TelldusCore::EventDataRef eventDataRef = d->controllerChangeEvent->takeSignal(); 102 102 ControllerChangeEventData *data = reinterpret_cast<ControllerChangeEventData*>(eventDataRef.get()); 103 103 if (data) { … … 107 107 108 108 if (dataEvent->isSignaled()) { 109 EventDataRef eventData = dataEvent->takeSignal();109 TelldusCore::EventDataRef eventData = dataEvent->takeSignal(); 110 110 ControllerEventData *data = reinterpret_cast<ControllerEventData*>(eventData.get()); 111 111 if (data) { -
telldus-core/service/Timer.cpp
rfb8e97 re83416 10 10 public: 11 11 PrivateData() : interval(0), running(false) {} 12 EventRef event;12 TelldusCore::EventRef event; 13 13 int interval; 14 14 bool running; … … 22 22 }; 23 23 24 Timer::Timer( EventRef event)24 Timer::Timer(TelldusCore::EventRef event) 25 25 :TelldusCore::Thread(), d(new PrivateData) 26 26 { -
telldus-core/service/Timer.h
r988b44 re83416 7 7 class Timer : public TelldusCore::Thread { 8 8 public: 9 Timer( EventRef event);9 Timer(TelldusCore::EventRef event); 10 10 virtual ~Timer(); 11 11
Note: See TracChangeset
for help on using the changeset viewer.
