sensorfw
qt-api/sensormanagerinterface.h
Go to the documentation of this file.
00001 
00028 #ifndef SENSORMANAGERINTERFACE_H
00029 #define SENSORMANAGERINTERFACE_H
00030 
00031 #include "sensormanager_i.h"
00032 #include "abstractsensor_i.h"
00033 
00034 typedef AbstractSensorChannelInterface* (*SensorInterfaceFactoryMethod)(const QString& id, int sessionId);
00035 
00036 struct SensorInterfaceEntry {
00037     SensorInterfaceFactoryMethod sensorInterfaceFactory;
00038     QString                      type; // could be an integer to safe memory
00039 };
00040 
00041 class SensorManagerInterface : public LocalSensorManagerInterface
00042 {
00043     Q_OBJECT
00044 
00045 public:
00046     static SensorManagerInterface& instance();
00047 
00048     template<class SensorInterfaceType>
00049     void registerSensorInterface(const QString& sensorName);
00050 
00051     AbstractSensorChannelInterface* interface(const QString& id);
00052     bool releaseInterface(const QString& id, int sessionId);
00053 
00054     bool registeredAndCorrectClassName(const QString& id, const QString& className ) const;
00055 
00056 protected:
00057     SensorManagerInterface();
00058     virtual ~SensorManagerInterface() {}
00059 
00060     QMap<QString, SensorInterfaceEntry> sensorInterfaceMap_;
00061 
00062     static SensorManagerInterface* ifc_;
00063 };
00064 
00065 template<class SensorInterfaceType>
00066 void SensorManagerInterface::registerSensorInterface(const QString& sensorName)
00067 {
00068     sensorInterfaceMap_[sensorName].sensorInterfaceFactory = SensorInterfaceType::factoryMethod;
00069     sensorInterfaceMap_[sensorName].type = SensorInterfaceType::staticMetaObject.className();
00070 }
00071 
00072 #endif // SENSORMANAGERINTERFACE_H