[go: up one dir, main page]

Menu

[r112]: / gizmod3 / gizmod / Gizmo.hpp  Maximize  Restore  History

Download this file

123 lines (103 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
*********************************************************************
*************************************************************************
***
*** \file Gizmo.hpp
*** \brief Gizmo class header
***
*****************************************
*****************************************
**/
/*
Copyright (c) 2007, Tim Burrell
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __Gizmo_h
#define __Gizmo_h
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "GizmoEvent.hpp"
#include "GizmoKeyDefs.hpp"
#include "../libH/FileEventWatcher.hpp"
#include <string>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/base_object.hpp>
//////////////////////////////////////////////////////////////////////////////
// Typedef, enum's
///////////////////////////////////////
/**
* \enum GizmoClass
* \brief These values tell GizmoDaemon what classes to use to represent the devices
*
* These values are repsented in Python by the same extension, under the enum class GizmoClass
* For example: Gizmod.GizmoClass.Standard, and Gizmod.GizmoClass.Powermate
*
* GIZMO_CLASS_ATIX10 is used with ATI X10 RF Remotes
* GIZMO_CLASS_LIRC is used with LIRC (Infrared) devices (such as remote controls)
* GIZMO_CLASS_POWERMATE is the class used for Griffin PowerMate, and SoundKnob devices
* GIZMO_CLASS_STANDARD is the default class and is used for all devices except ones with
* special handlers
*/
typedef enum {
GIZMO_CLASS_ATIX10,
GIZMO_CLASS_LIRC,
GIZMO_CLASS_POWERMATE,
GIZMO_CLASS_STANDARD
} GizmoClass;
//////////////////////////////////////////////////////////////////////////////
// Class Definition
///////////////////////////////////////
/**
* \class Gizmo
* \brief Base class of all Gizmos
*
* This class is the base of all Gizmos attached to the system.
* Each Gizmo must inherit this class
*/
class Gizmo : public H::DeviceInfo {
public:
// public functions
virtual GizmoClass getClass(); ///< Get the class of the Gizmo
int getDeviceID(); ///< Get the Device ID
int getDeviceClassID(); ///< Get the Device Class ID
virtual int getKeyState(GizmoKey Key); ///< Get a key state
virtual std::string getType(); ///< Get the type of the Gizmo
virtual bool processEvent(GizmoEvent * pEvent); ///< Process an event
void setKeyState(GizmoKey Key, int State); ///< Set a keystate of the Gizmo
// construction / deconstruction
Gizmo(); ///< Serialize Constructor
Gizmo(GizmoClass Class, const H::DeviceInfo & deviceInfo, int DeviceID, int DeviceClassID); ///< Default Constructor
virtual ~Gizmo(); ///< Destructor
protected:
// protected functions
// protected member variables
GizmoClass mClass; ///< Class of the Gizmo
int mDeviceID; ///< Unique ID of the device
int mDeviceClassID; ///< ID of the device in its class
int mKeyState[GIZMO_KEY_MAX]; ///< Gizmos's key states
private:
// private functions
// private member variables
private:
// serialization
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
ar & boost::serialization::base_object<H::DeviceInfo>(*this);
ar & mClass;
ar & mDeviceID;
ar & mDeviceClassID;
ar & mKeyState;
}
};
#endif // __Gizmo_h