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 <stdlib.h>
using namespace TelldusCore;
/*
* Constructor
*/
Device::Device(int model)
: model(model)
Device::Device(int m)
: model(m)
{
}

View file

@ -4,30 +4,34 @@
#include <string>
//#include <QMutex>
class Device
{
public:
Device(int model);
~Device(void);
virtual int turnOn(void);
virtual int turnOff(void);
virtual int bell(void);
virtual int dim(unsigned char level);
virtual int methods(int methodsSupported) = 0;
virtual std::string getProtocol() = 0;
int getModel();
#ifdef _LINUX
void setDevice(const std::string &device);
protected:
std::string strDevice;
#endif
namespace TelldusCore {
protected:
int send(const std::string &strMessage);
class Device
{
public:
Device(int model);
~Device(void);
virtual int turnOn(void);
virtual int turnOff(void);
virtual int bell(void);
virtual int dim(unsigned char level);
virtual int methods(int methodsSupported) = 0;
virtual std::string getProtocol() = 0;
int getModel();
#ifdef _LINUX
void setDevice(const std::string &device);
protected:
std::string strDevice;
#endif
protected:
int send(const std::string &strMessage);
private:
int model;
// static QMutex deviceMutex;
};
private:
int model;
// static QMutex deviceMutex;
};
}

View file

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

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@
#include <algorithm>
#include <fstream>
using namespace std;
using namespace TelldusCore;
/*
* 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
*/
string DeviceSartano::getStringCode(void){
std::string DeviceSartano::getStringCode(void){
std::string strReturn = strCode;

View file

@ -2,19 +2,22 @@
#include "Device.h"
#include <string>
namespace TelldusCore {
class DeviceSartano : public Device
{
public:
DeviceSartano(int model, const std::string &strCode);
virtual int turnOn(void);
virtual int turnOff(void);
virtual int methods(int methodsSupported);
virtual std::string getProtocol();
class DeviceSartano : public Device
{
public:
DeviceSartano(int model, const std::string &strCode);
virtual int turnOn(void);
virtual int turnOff(void);
virtual int methods(int methodsSupported);
virtual std::string getProtocol();
~DeviceSartano(void);
protected:
std::string getStringCode(void);
std::string strCode;
};
~DeviceSartano(void);
protected:
std::string getStringCode(void);
std::string strCode;
};
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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