Added static function Device::methodId()

This commit is contained in:
Micke Prag 2009-02-05 16:13:03 +00:00
parent bb893d2119
commit c3a5bf2eb0
3 changed files with 24 additions and 6 deletions

View file

@ -51,3 +51,19 @@ int Device::bell(void){
int Device::dim(unsigned char level){
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
}
bool Device::methodId( const std::string &methodName ) {
if (methodName.compare("turnon") == 0) {
return TELLSTICK_TURNON;
}
if (methodName.compare("turnoff") == 0) {
return TELLSTICK_TURNOFF;
}
if (methodName.compare("bell") == 0) {
return TELLSTICK_BELL;
}
if (methodName.compare("dim") == 0) {
return TELLSTICK_DIM;
}
return 0;
}

View file

@ -6,6 +6,12 @@
namespace TelldusCore {
const int ALL_METHODS =
TELLSTICK_TURNON |
TELLSTICK_TURNOFF |
TELLSTICK_BELL |
TELLSTICK_DIM;
class Device
{
public:
@ -22,6 +28,8 @@ namespace TelldusCore {
int getModel() const;
void setModel( int intModel );
static bool methodId( const std::string &methodName );
#ifdef _LINUX
void setDevice(const std::string &device);
protected:

View file

@ -5,12 +5,6 @@
using namespace TelldusCore;
const int ALL_METHODS =
TELLSTICK_TURNON |
TELLSTICK_TURNOFF |
TELLSTICK_BELL |
TELLSTICK_DIM;
/*
* Constructor
*/