Added namespace 'TelldusCore' to classes in library telldus-core

This commit is contained in:
Micke Prag 2009-01-07 21:14:59 +00:00
parent df4615f8f8
commit f1e9f2f9f2
14 changed files with 144 additions and 114 deletions

View file

@ -1,11 +1,12 @@
#include "Device.h" #include "Device.h"
#include <stdlib.h> #include <stdlib.h>
using namespace TelldusCore;
/* /*
* Constructor * Constructor
*/ */
Device::Device(int model) Device::Device(int m)
: model(model) : model(m)
{ {
} }

View file

@ -4,9 +4,11 @@
#include <string> #include <string>
//#include <QMutex> //#include <QMutex>
class Device namespace TelldusCore {
{
public: class Device
{
public:
Device(int model); Device(int model);
~Device(void); ~Device(void);
@ -18,16 +20,18 @@ public:
virtual std::string getProtocol() = 0; virtual std::string getProtocol() = 0;
int getModel(); int getModel();
#ifdef _LINUX #ifdef _LINUX
void setDevice(const std::string &device); void setDevice(const std::string &device);
protected: protected:
std::string strDevice; std::string strDevice;
#endif #endif
protected: protected:
int send(const std::string &strMessage); int send(const std::string &strMessage);
private: private:
int model; int model;
// static QMutex deviceMutex; // static QMutex deviceMutex;
}; };
}

View file

@ -10,6 +10,8 @@
#define strcasecmp(x, y) _strcmpi(x, y) #define strcasecmp(x, y) _strcmpi(x, y)
#endif #endif
using namespace TelldusCore;
/* /*
* Constructor * Constructor
*/ */

View file

@ -2,9 +2,11 @@
#include "Device.h" #include "Device.h"
#include <string> #include <string>
class DeviceIkea : public Device namespace TelldusCore {
{
public: class DeviceIkea : public Device
{
public:
DeviceIkea(int model, const std::string &strSystem, const std::string &strUnits, const std::string &strFadeStyle); DeviceIkea(int model, const std::string &strSystem, const std::string &strUnits, const std::string &strFadeStyle);
virtual int turnOn(void); virtual int turnOn(void);
virtual int turnOff(void); virtual int turnOff(void);
@ -12,13 +14,14 @@ public:
virtual int methods(int methodsSupported); virtual int methods(int methodsSupported);
virtual std::string getProtocol(); virtual std::string getProtocol();
public: public:
~DeviceIkea(void); ~DeviceIkea(void);
protected: protected:
int intSystem; int intSystem;
int intUnits; int intUnits;
int intFadeStyle; int intFadeStyle;
std::string getStringCode(unsigned char); std::string getStringCode(unsigned char);
}; };
}

View file

@ -6,6 +6,8 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
using namespace TelldusCore;
/* /*
* Constructor * Constructor
*/ */

View file

@ -2,9 +2,11 @@
#include "Device.h" #include "Device.h"
#include <string> #include <string>
class DeviceNexa : public Device namespace TelldusCore {
{
public: class DeviceNexa : public Device
{
public:
DeviceNexa(int model, const std::string &strHouse, const std::string &strCode); DeviceNexa(int model, const std::string &strHouse, const std::string &strCode);
virtual int turnOn(void); virtual int turnOn(void);
virtual int turnOff(void); virtual int turnOff(void);
@ -12,12 +14,13 @@ public:
virtual int methods(int methodsSupported); virtual int methods(int methodsSupported);
virtual std::string getProtocol(); virtual std::string getProtocol();
public: public:
~DeviceNexa(void); ~DeviceNexa(void);
protected: protected:
int intHouse; int intHouse;
int intCode; int intCode;
std::string getStringCode(int); std::string getStringCode(int);
}; };
}

View file

@ -5,7 +5,7 @@
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
using namespace std; using namespace TelldusCore;
/* /*
* Constructor * Constructor
@ -70,7 +70,7 @@ int DeviceSartano::methods(int){
/* /*
* Convert an integer to byte string where 0 is represented by $k and 1 by k$, reversed and padded with 0's as needed * Convert an integer to byte string where 0 is represented by $k and 1 by k$, reversed and padded with 0's as needed
*/ */
string DeviceSartano::getStringCode(void){ std::string DeviceSartano::getStringCode(void){
std::string strReturn = strCode; std::string strReturn = strCode;

View file

@ -2,10 +2,11 @@
#include "Device.h" #include "Device.h"
#include <string> #include <string>
namespace TelldusCore {
class DeviceSartano : public Device class DeviceSartano : public Device
{ {
public: public:
DeviceSartano(int model, const std::string &strCode); DeviceSartano(int model, const std::string &strCode);
virtual int turnOn(void); virtual int turnOn(void);
virtual int turnOff(void); virtual int turnOff(void);
@ -14,7 +15,9 @@ public:
~DeviceSartano(void); ~DeviceSartano(void);
protected: protected:
std::string getStringCode(void); std::string getStringCode(void);
std::string strCode; std::string strCode;
}; };
}

View file

@ -6,7 +6,7 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
using namespace std; using namespace TelldusCore;
/* /*
* Constructor * Constructor
@ -21,8 +21,8 @@ DeviceWaveman::DeviceWaveman(int model, const std::string &strHouse, const std::
int DeviceWaveman::turnOff(void){ int DeviceWaveman::turnOff(void){
try{ try{
string strCode = getStringCode(intHouse); std::string strCode = getStringCode(intHouse);
string strUnit = getStringCode(intCode); std::string strUnit = getStringCode(intCode);
strCode.append(strUnit); strCode.append(strUnit);
strCode.insert(0, "S"); strCode.insert(0, "S");

View file

@ -2,10 +2,14 @@
#include "DeviceNexa.h" #include "DeviceNexa.h"
#include <string> #include <string>
class DeviceWaveman : public DeviceNexa namespace TelldusCore {
{
public: class DeviceWaveman : public DeviceNexa
{
public:
DeviceWaveman(int model, const std::string &strHouse, const std::string &strCode); DeviceWaveman(int model, const std::string &strHouse, const std::string &strCode);
virtual int turnOff(void); virtual int turnOff(void);
virtual int methods(int methodsSupported); virtual int methods(int methodsSupported);
}; };
}

View file

@ -25,6 +25,8 @@
#define strcasecmp _stricmp #define strcasecmp _stricmp
#endif #endif
using namespace TelldusCore;
Manager *Manager::instance = 0; Manager *Manager::instance = 0;
Manager::Manager() { Manager::Manager() {

View file

@ -14,15 +14,17 @@
#include "Settings.h" #include "Settings.h"
#include <map> #include <map>
class Device;
typedef std::map<int, Device *> DeviceMap; namespace TelldusCore {
class Device;
/** typedef std::map<int, Device *> DeviceMap;
/**
@author Micke Prag <micke.prag@telldus.se> @author Micke Prag <micke.prag@telldus.se>
*/ */
class Manager { class Manager {
public: public:
~Manager(); ~Manager();
Device *getDevice(int deviceId); Device *getDevice(int deviceId);
@ -30,13 +32,14 @@ public:
static Manager *getInstance(); static Manager *getInstance();
static void close(); static void close();
private: private:
Manager(); Manager();
Settings settings; Settings settings;
DeviceMap devices; DeviceMap devices;
static Manager *instance; static Manager *instance;
}; };
}
#endif #endif

View file

@ -5,6 +5,8 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
using namespace TelldusCore;
/* /*
* Send message to the USB dongle * Send message to the USB dongle
*/ */

View file

@ -19,6 +19,7 @@
void handleException(std::exception e); void handleException(std::exception e);
using namespace std; using namespace std;
using namespace TelldusCore;
inline char *wrapStdString( const std::string &string); inline char *wrapStdString( const std::string &string);
@ -465,8 +466,8 @@ char * WINAPI tdGetErrorString(int intErrorNo) {
//* //*
void handleException(exception e){ void handleException(exception e){
std::string strLogName = "errorlog.txt"; // std::string strLogName = "errorlog.txt";
//char* strLogName = ""; std::string strLogName = "";
if(strLogName.length() > 0){ if(strLogName.length() > 0){
ofstream errorfile(strLogName.c_str(), ios::app); ofstream errorfile(strLogName.c_str(), ios::app);