From 6c48005af2cb0e98d83f1de6441c99da538f74e5 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Thu, 12 May 2011 14:45:23 +0000 Subject: [PATCH] Added class Sensor --- telldus-core/service/CMakeLists.txt | 2 ++ telldus-core/service/Sensor.cpp | 39 +++++++++++++++++++++++++++++ telldus-core/service/Sensor.h | 24 ++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 telldus-core/service/Sensor.cpp create mode 100644 telldus-core/service/Sensor.h diff --git a/telldus-core/service/CMakeLists.txt b/telldus-core/service/CMakeLists.txt index 5ad4f31d..61037f88 100644 --- a/telldus-core/service/CMakeLists.txt +++ b/telldus-core/service/CMakeLists.txt @@ -17,6 +17,7 @@ SET( telldus-service_SRCS Device.cpp DeviceManager.cpp Event.cpp + Sensor.cpp Settings.cpp TelldusMain.cpp TellStick.cpp @@ -67,6 +68,7 @@ SET( telldus-service_HDRS DeviceManager.h Event.h EventHandler.h + Sensor.h Settings.h TelldusMain.h TellStick.h diff --git a/telldus-core/service/Sensor.cpp b/telldus-core/service/Sensor.cpp new file mode 100644 index 00000000..d9781868 --- /dev/null +++ b/telldus-core/service/Sensor.cpp @@ -0,0 +1,39 @@ +#include "Sensor.h" +#include "common.h" + +class Sensor::PrivateData { +public: + std::wstring protocol, model; + int id; + time_t timestamp; +}; + +Sensor::Sensor(const std::wstring &protocol, const std::wstring &model, int id) + :Mutex() +{ + d = new PrivateData; + d->protocol = protocol; + d->model = model; + d->id = id; +} + +Sensor::~Sensor() { + delete d; +} + +std::wstring Sensor::protocol() const { + return d->protocol; +} + +std::wstring Sensor::model() const { + return d->model; +} + +int Sensor::id() const { + return d->id; +} + +void Sensor::setValue(const std::string &name, const std::string &value, time_t timestamp) { + //TODO: Do acctual storing of values + d->timestamp = timestamp; +} diff --git a/telldus-core/service/Sensor.h b/telldus-core/service/Sensor.h new file mode 100644 index 00000000..3b06e052 --- /dev/null +++ b/telldus-core/service/Sensor.h @@ -0,0 +1,24 @@ +#ifndef SENSOR_H +#define SENSOR_H + +#include "Mutex.h" +#include + +class Sensor : public TelldusCore::Mutex +{ +public: + Sensor(const std::wstring &protocol, const std::wstring &model, int id); + ~Sensor(); + + std::wstring protocol() const; + std::wstring model() const; + int id() const; + + void setValue(const std::string &name, const std::string &value, time_t timestamp); + +private: + class PrivateData; + PrivateData *d; +}; + +#endif // SENSOR_H