00001 00012 /* 00013 00014 Copyright (c) 2007, Tim Burrell 00015 Licensed under the Apache License, Version 2.0 (the "License"); 00016 you may not use this file except in compliance with the License. 00017 You may obtain a copy of the License at 00018 00019 http://www.apache.org/licenses/LICENSE-2.0 00020 00021 Unless required by applicable law or agreed to in writing, software 00022 distributed under the License is distributed on an "AS IS" BASIS, 00023 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00024 See the License for the specific language governing permissions and 00025 limitations under the License. 00026 00027 */ 00028 00029 #ifndef __Gizmo_h 00030 #define __Gizmo_h 00031 00032 #if HAVE_CONFIG_H 00033 #include "config.h" 00034 #endif 00035 00036 #include "GizmoEvent.hpp" 00037 #include "GizmoKeyDefs.hpp" 00038 #include "../libH/FileEventWatcher.hpp" 00039 #include <string> 00040 #include <boost/archive/text_oarchive.hpp> 00041 #include <boost/archive/text_iarchive.hpp> 00042 #include <boost/serialization/base_object.hpp> 00043 00045 // Namespace 00047 00048 namespace Gizmod { 00049 00051 // Typedef, enum's 00053 00067 typedef enum { 00068 GIZMO_CLASS_ATIX10, 00069 GIZMO_CLASS_LIRC, 00070 GIZMO_CLASS_POWERMATE, 00071 GIZMO_CLASS_STANDARD 00072 } GizmoClass; 00073 00075 // Class Definition 00077 00085 class Gizmo : public H::DeviceInfo { 00086 public: 00087 // public functions 00088 virtual GizmoClass getClass(); 00089 int getDeviceID(); 00090 int getDeviceClassID(); 00091 virtual int getKeyState(GizmoKey Key); 00092 virtual std::string getType(); 00093 virtual bool processEvent(GizmoEvent * pEvent); 00094 void setKeyState(GizmoKey Key, int State); 00095 00096 // construction / deconstruction 00097 Gizmo(); 00098 Gizmo(GizmoClass Class, const H::DeviceInfo & deviceInfo, int DeviceID, int DeviceClassID); 00099 virtual ~Gizmo(); 00100 00101 protected: 00102 // protected functions 00103 00104 // protected member variables 00105 GizmoClass mClass; 00106 int mDeviceID; 00107 int mDeviceClassID; 00108 int mKeyState[GIZMO_KEY_MAX]; 00109 00110 private: 00111 // private functions 00112 00113 // private member variables 00114 00115 private: 00116 // serialization 00117 friend class boost::serialization::access; 00118 template<class Archive> 00119 void serialize(Archive & ar, const unsigned int version) { 00120 ar & boost::serialization::base_object<H::DeviceInfo>(*this); 00121 ar & mClass; 00122 ar & mDeviceID; 00123 ar & mDeviceClassID; 00124 ar & mKeyState; 00125 } 00126 }; 00127 00129 00130 } // Gizmod namespace 00131 00132 #endif // __Gizmo_h