summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <kevron_m_rees@linux.intel.com>2012-08-23 13:43:01 -0700
committerKevron Rees <kevron_m_rees@linux.intel.com>2012-08-23 13:43:01 -0700
commit86c0565ede957c2389db1bb1d77957ab673f6860 (patch)
treed13194e72cbd4500da20f5a52922e4f6fefa2e43
parent67200af744a5964cb541dab25f345acf90804ce0 (diff)
downloadautomotive-message-broker-86c0565ede957c2389db1bb1d77957ab673f6860.tar.gz
added vehiclespeed property
-rw-r--r--plugins/dbus/accelerationproperty.cpp2
-rw-r--r--plugins/dbus/accelerationproperty.h2
-rw-r--r--plugins/dbus/dbusinterfacemanager.cpp2
-rw-r--r--plugins/dbus/dbusplugin.cpp23
-rw-r--r--plugins/dbus/dbusplugin.h15
-rw-r--r--plugins/dbus/properties.h21
6 files changed, 41 insertions, 24 deletions
diff --git a/plugins/dbus/accelerationproperty.cpp b/plugins/dbus/accelerationproperty.cpp
index 9d49e3fe..dae6d68c 100644
--- a/plugins/dbus/accelerationproperty.cpp
+++ b/plugins/dbus/accelerationproperty.cpp
@@ -20,7 +20,7 @@
#include "listplusplus.h"
AccelerationPropertyInterface::AccelerationPropertyInterface(AbstractRoutingEngine *re, GDBusConnection* connection)
- :AbstractDBusInterface("org.automotive.acceleration","/org/automotive/acceleration", connection), DBusSink(re),
+ :DBusSink("org.automotive.acceleration","/org/automotive/acceleration", re, connection),
accelerationX(nullptr), accelerationY(nullptr), accelerationZ(nullptr)
{
supportedChanged(re->supported());
diff --git a/plugins/dbus/accelerationproperty.h b/plugins/dbus/accelerationproperty.h
index 371cdb3f..e07e59d2 100644
--- a/plugins/dbus/accelerationproperty.h
+++ b/plugins/dbus/accelerationproperty.h
@@ -23,7 +23,7 @@
#include "dbusplugin.h"
#include "basicproperty.h"
-class AccelerationPropertyInterface: public AbstractDBusInterface, public DBusSink
+class AccelerationPropertyInterface: public DBusSink
{
public:
AccelerationPropertyInterface(AbstractRoutingEngine* re, GDBusConnection* connection);
diff --git a/plugins/dbus/dbusinterfacemanager.cpp b/plugins/dbus/dbusinterfacemanager.cpp
index 84e2f064..163cefb9 100644
--- a/plugins/dbus/dbusinterfacemanager.cpp
+++ b/plugins/dbus/dbusinterfacemanager.cpp
@@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
///properties:
#include "accelerationproperty.h"
+#include "properties.h"
using namespace std;
@@ -32,6 +33,7 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d
{
DBusInterfaceManager* iface = static_cast<DBusInterfaceManager*>(user_data);
AbstractDBusInterface* acceleration = new AccelerationPropertyInterface(iface->re, connection);
+ VehicleSpeedProperty* vehicleSpeed = new VehicleSpeedProperty(iface->re, connection);
}
diff --git a/plugins/dbus/dbusplugin.cpp b/plugins/dbus/dbusplugin.cpp
index 36120c55..ebc92d24 100644
--- a/plugins/dbus/dbusplugin.cpp
+++ b/plugins/dbus/dbusplugin.cpp
@@ -21,18 +21,37 @@
#include "abstractroutingengine.h"
#include "dbusinterfacemanager.h"
#include "debugout.h"
+#include "listplusplus.h"
extern "C" AbstractSinkManager * create(AbstractRoutingEngine* routingengine)
{
return new DBusSinkManager(routingengine);
}
-DBusSink::DBusSink(AbstractRoutingEngine* engine)
- : AbstractSink(engine)
+DBusSink::DBusSink(string interface, string path, AbstractRoutingEngine* engine, GDBusConnection* connection)
+ :AbstractDBusInterface(interface, path, connection),
+ AbstractSink(engine), supported(false)
{
}
+void DBusSink::supportedChanged(PropertyList supportedProperties)
+{
+
+ for(PropertyDBusMap::iterator itr = propertyDBusMap.begin(); itr != propertyDBusMap.end(); itr++)
+ {
+ if(ListPlusPlus<VehicleProperty::Property>(&supportedProperties).contains((*itr).first))
+ {
+ routingEngine->subscribeToProperty((*itr).first, this);
+ supported = true;
+ }
+ }
+
+
+ if(supported)
+ registerObject();
+}
+
void DBusSink::propertyChanged(VehicleProperty::Property property, boost::any value, string uuid)
{
if(!propertyDBusMap.count(property))
diff --git a/plugins/dbus/dbusplugin.h b/plugins/dbus/dbusplugin.h
index 8007ec4c..2fd26f25 100644
--- a/plugins/dbus/dbusplugin.h
+++ b/plugins/dbus/dbusplugin.h
@@ -21,27 +21,32 @@
#include "abstractsink.h"
#include "abstractproperty.h"
+#include "abstractdbusinterface.h"
+#include "basicproperty.h"
#include <map>
typedef std::map<VehicleProperty::Property, AbstractProperty*> PropertyDBusMap;
-class DBusSink : public AbstractSink
+class DBusSink : public AbstractSink, public AbstractDBusInterface
{
public:
- DBusSink(AbstractRoutingEngine* engine);
- virtual void supportedChanged(PropertyList supportedProperties) = 0;
+ DBusSink(std::string interface, std::string path, AbstractRoutingEngine* engine, GDBusConnection* connection);
+ virtual void supportedChanged(PropertyList supportedProperties);
virtual void propertyChanged(VehicleProperty::Property property, boost::any value, std::string uuid);
virtual std::string uuid();
protected:
template <typename T>
- void wantProperty(VehicleProperty::Property)
+ void wantProperty(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access)
{
-
+ propertyDBusMap[property] = new BasicProperty<T>(propertyName, signature, access, this);
}
PropertyDBusMap propertyDBusMap;
+private:
+
+ bool supported;
};
class DBusSinkManager: public AbstractSinkManager
diff --git a/plugins/dbus/properties.h b/plugins/dbus/properties.h
index de7efed7..84fc15eb 100644
--- a/plugins/dbus/properties.h
+++ b/plugins/dbus/properties.h
@@ -21,28 +21,19 @@
#include "dbusplugin.h"
#include "abstractdbusinterface.h"
+#include "abstractroutingengine.h"
-class VehicleSpeedProperty: public AbstractDBusInterface, public DBusSink
+class VehicleSpeedProperty: public DBusSink
{
public:
- AccelerationPropertyInterface(AbstractRoutingEngine* re, GDBusConnection* connection)
- :AbstractDBusInterface("org.automotive.acceleration","/org/automotive/acceleration", connection),
- DBusSink(re)
+ VehicleSpeedProperty(AbstractRoutingEngine* re, GDBusConnection* connection)
+ :DBusSink("org.automotive.vehicleSpeed","/org/automotive/vehiclespeed", re, connection)
{
+ wantProperty<uint16_t>(VehicleProperty::VehicleSpeed,"VehicleSpeed", "i", AbstractProperty::Read);
supportedChanged(re->supported());
}
- void supportedChanged(PropertyList supportedProperties)
- {
- for(PropertyDBusMap itr = propertyDBusMap.begin(); itr != propertyDBusMap.end(); itr++)
- {
- if(ListPlusPlus<VehicleProperty::Property>(&supportedProperties).contains((*itr)))
- {
- routingEngine->subscribeToProperty((*itr), this);
-
- }
- }
- }
+
};
#endif