sensorfw: qt-api/sensormanagerinterface.h Source File

sensorfw

sensormanagerinterface.h
Go to the documentation of this file.
1
28#ifndef SENSORMANAGERINTERFACE_H
29#define SENSORMANAGERINTERFACE_H
30
31#include <QMutexLocker>
32
33#include "sensormanager_i.h"
34#include "abstractsensor_i.h"
35
36 typedef AbstractSensorChannelInterface* (*SensorInterfaceFactoryMethod)(const QString& id, int sessionId);
37
38 struct SensorInterfaceEntry {
39 SensorInterfaceFactoryMethod sensorInterfaceFactory;
40 QString type; // could be an integer to safe memory
41};
42
43 class SensorManagerInterface : public LocalSensorManagerInterface
44{
45 Q_OBJECT
46
47public:
48 static SensorManagerInterface& instance();
49
50 template<class SensorInterfaceType>
51 void registerSensorInterface(const QString& sensorName);
52
53 AbstractSensorChannelInterface* interface(const QString& id);
54 bool releaseInterface(const QString& id, int sessionId);
55
56 bool registeredAndCorrectClassName(const QString& id, const QString& className ) const;
57
58protected:
59 SensorManagerInterface();
60 virtual ~SensorManagerInterface() {}
61
62 QMap<QString, SensorInterfaceEntry> sensorInterfaceMap_;
63
64 static SensorManagerInterface* ifc_;
65 static QMutex mutex_;
66};
67
68template<class SensorInterfaceType>
69 void SensorManagerInterface::registerSensorInterface(const QString& sensorName)
70{
71 QMutexLocker locker(&mutex_);
72 sensorInterfaceMap_[sensorName].sensorInterfaceFactory = SensorInterfaceType::factoryMethod;
73 sensorInterfaceMap_[sensorName].type = SensorInterfaceType::staticMetaObject.className();
74}
75
76#endif // SENSORMANAGERINTERFACE_H
abstractsensor_i.h
Base class for sensor interface.
AbstractSensorChannelInterface
Base-class for client facades of different sensor types.
Definition abstractsensor_i.h:46
LocalSensorManagerInterface
DBus interface to SensorManager instance.
Definition sensormanager_i.h:41
SensorManagerInterface
Definition sensormanagerinterface.h:44
SensorManagerInterface::instance
static SensorManagerInterface & instance()
SensorManagerInterface::~SensorManagerInterface
virtual ~SensorManagerInterface()
Definition sensormanagerinterface.h:60
SensorManagerInterface::registerSensorInterface
void registerSensorInterface(const QString &sensorName)
Definition sensormanagerinterface.h:69
SensorManagerInterface::interface
AbstractSensorChannelInterface * interface(const QString &id)
SensorManagerInterface::sensorInterfaceMap_
QMap< QString, SensorInterfaceEntry > sensorInterfaceMap_
Definition sensormanagerinterface.h:62
SensorManagerInterface::ifc_
static SensorManagerInterface * ifc_
Definition sensormanagerinterface.h:64
SensorManagerInterface::mutex_
static QMutex mutex_
Definition sensormanagerinterface.h:65
SensorManagerInterface::registeredAndCorrectClassName
bool registeredAndCorrectClassName(const QString &id, const QString &className) const
SensorManagerInterface::SensorManagerInterface
SensorManagerInterface()
SensorManagerInterface::releaseInterface
bool releaseInterface(const QString &id, int sessionId)
sensormanager_i.h
Proxy class for interface for SensorManager.
SensorInterfaceFactoryMethod
AbstractSensorChannelInterface *(* SensorInterfaceFactoryMethod)(const QString &id, int sessionId)
Definition sensormanagerinterface.h:36
SensorInterfaceEntry
Definition sensormanagerinterface.h:38
SensorInterfaceEntry::sensorInterfaceFactory
SensorInterfaceFactoryMethod sensorInterfaceFactory
Definition sensormanagerinterface.h:39
SensorInterfaceEntry::type
QString type
Definition sensormanagerinterface.h:40