use pointer to avoid implicit casting fail
authorKevron Rees <tripzero.kev@gmail.com>
Wed, 29 Aug 2012 01:32:22 +0000 (18:32 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Wed, 29 Aug 2012 01:32:22 +0000 (18:32 -0700)
24 files changed:
CMakeLists.txt
ambd/core.cpp
ambd/core.h
lib/CMakeLists.txt
lib/abstractpropertytype.h
lib/abstractroutingengine.h
lib/abstractsink.h
lib/abstractsource.h
lib/vehicleproperty.cpp
lib/vehicleproperty.h
plugins/dbus/abstractproperty.h
plugins/dbus/dbusplugin.cpp
plugins/dbus/dbusplugin.h
plugins/exampleplugin.cpp
plugins/exampleplugin.h
plugins/examplesink.cpp
plugins/examplesink.h
plugins/websocketsink/websocketsink.cpp
plugins/websocketsink/websocketsink.h
plugins/websocketsink/websocketsinkmanager.cpp
plugins/websocketsourceplugin/websocketsource.cpp
plugins/websocketsourceplugin/websocketsource.h
plugins/wheel/wheelplugin.cpp
plugins/wheel/wheelplugin.h

index 118f4cd..e29bedc 100644 (file)
@@ -1,6 +1,8 @@
 project(automotive-message-broker)
 cmake_minimum_required(VERSION 2.8)
 
+set(CMAKE_BUILD_TYPE, Debug)
+
 include(FindPkgConfig)
 
 set(PROJECT_NAME "automotive-message-broker")
index 3fc39f9..aed5c57 100644 (file)
@@ -121,7 +121,7 @@ void Core::updateSupported(PropertyList added, PropertyList removed)
        }
 }
 
-void Core::updateProperty(VehicleProperty::Property property, AbstractPropertyType value)
+void Core::updateProperty(VehicleProperty::Property property, AbstractPropertyType *value)
 {
        SinkList list = propertySinkMap[property];
        
@@ -167,7 +167,7 @@ AsyncPropertyReply *Core::getPropertyAsync(AsyncPropertyRequest request)
        return reply;
 }
 
-void Core::setProperty(VehicleProperty::Property property, AbstractPropertyType value)
+void Core::setProperty(VehicleProperty::Property property, AbstractPropertyType *value)
 {
        for(SourceList::iterator itr = mSources.begin(); itr != mSources.end(); itr++)
        {
index 222c094..477da54 100644 (file)
@@ -36,14 +36,14 @@ public:
 
        void setSupported(PropertyList supported, AbstractSource* source);
        void updateSupported(PropertyList added, PropertyList removed);
-       void updateProperty(VehicleProperty::Property property, AbstractPropertyType value);
+       void updateProperty(VehicleProperty::Property property, AbstractPropertyType* value);
        
        /// sinks:
        
        void registerSink(AbstractSink *self);
        void unregisterSink(AbstractSink *self);
        AsyncPropertyReply* getPropertyAsync(AsyncPropertyRequest request);
-       void setProperty(VehicleProperty::Property,AbstractPropertyType);
+       void setProperty(VehicleProperty::Property,AbstractPropertyType*);
        void subscribeToProperty(VehicleProperty::Property, AbstractSink* self);
        void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self);
        PropertyList supported() { return mMasterPropertyList; }
index 5a5bcb1..32058dd 100644 (file)
@@ -1,4 +1,3 @@
-
 set(amb_sources abstractpropertytype.cpp abstractroutingengine.cpp listplusplus.cpp abstractsink.cpp vehicleproperty.cpp abstractsource.cpp debugout.cpp)
 set(amb_headers_install abstractpropertytype.h abstractroutingengine.h listplusplus.h abstractsink.h vehicleproperty.h debugout.h abstractsource.h)
 include_directories( ${include_dirs} )
index 86448c4..99e4f81 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <string>
 #include <sstream>
+#include <stdexcept>
 #include <boost/any.hpp>
 #include <boost/lexical_cast.hpp>
 
@@ -72,7 +73,9 @@ public:
 
        BasicPropertyType(std::string val)
        {
-               setValue(boost::lexical_cast<T,std::string>(val));
+               if(!val.empty() && val != "")
+                       setValue(boost::lexical_cast<T,std::string>(val));
+               else throw std::runtime_error("value cannot be empty");
        }
 
        std::string toString()
index 94fa9c8..1d90a96 100644 (file)
@@ -48,7 +48,7 @@ public:
                this->completed = request.completed;
        }
 
-       AbstractPropertyType value;
+       AbstractPropertyType* value;
 };
 
 class AbstractRoutingEngine
@@ -56,13 +56,13 @@ class AbstractRoutingEngine
 public:
        virtual void setSupported(PropertyList supported, AbstractSource* source) = 0;
        virtual void updateSupported(PropertyList added, PropertyList removed) = 0;
-       virtual void updateProperty(VehicleProperty::Property property, AbstractPropertyType value) = 0;
-       
+       virtual void updateProperty(VehicleProperty::Property property, AbstractPropertyType* value) = 0;
+
        /// sinks:
        virtual void registerSink(AbstractSink* self) = 0;
        virtual void  unregisterSink(AbstractSink* self) = 0;
        virtual AsyncPropertyReply *getPropertyAsync(AsyncPropertyRequest request) = 0;
-       virtual void setProperty(VehicleProperty::Property, AbstractPropertyType) = 0;
+       virtual void setProperty(VehicleProperty::Property, AbstractPropertyType*) = 0;
        virtual void subscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
        virtual void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
        virtual PropertyList supported() = 0;
index 400487a..b2a84ab 100644 (file)
@@ -45,7 +45,7 @@ public:
        ///Pure virtual methods:
        
        virtual string uuid() = 0;
-       virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string  uuid) = 0;
+       virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string  uuid) = 0;
        virtual void supportedChanged(PropertyList supportedProperties) = 0;
        
 protected:
index 3ec399a..6db0e51 100644 (file)
@@ -45,7 +45,7 @@ public:
        ///pure virtual methods:
 
        virtual void getPropertyAsync(AsyncPropertyReply *reply) = 0;
-       virtual void setProperty(VehicleProperty::Property property, AbstractPropertyType value) = 0;
+       virtual void setProperty(VehicleProperty::Property property, AbstractPropertyType* value) = 0;
        virtual void subscribeToPropertyChanges(VehicleProperty::Property property) = 0;
        virtual void unsubscribeToPropertyChanges(VehicleProperty::Property property) = 0;
        virtual PropertyList supported() = 0;
index 7cebf2e..0f3b6a5 100644 (file)
@@ -68,25 +68,24 @@ std::list<VehicleProperty::Property> VehicleProperty::capabilities()
        return mProperties;
 }
 
-AbstractPropertyType VehicleProperty::getPropertyTypeForPropertyNameValue(VehicleProperty::Property name, std::string value)
+AbstractPropertyType* VehicleProperty::getPropertyTypeForPropertyNameValue(VehicleProperty::Property name, std::string value)
 {
-       std::map<VehicleProperty::Property, AbstractPropertyType> theMap;
 
-       theMap[VehicleSpeed] = VehicleSpeedType(value);
-       theMap[EngineSpeed] = EngineSpeedType(value);
-       theMap[TransmissionShiftPosition] = TransmissionShiftPositionType(value);
-       theMap[TransmissionGearPosition] = TransmissionGearPositionType(value);
-       theMap[ThrottlePosition] = ThrottlePositionType(value);
-       theMap[WheelBrake] = WheelBrakeType(value);
-       theMap[SteeringWheelAngle] = SteeringWheelAngleType(value);
-       theMap[TurnSignal] = TurnSignalType(value);
-       theMap[ClutchStatus] = ClutchStatusType(value);
-       theMap[EngineOilPressure] = EngineOilPressureType(value);
-       theMap[EngineCoolantTemperature] = EngineCoolantTemperatureType(value);
-       theMap[AccelerationX] = AccelerationType(value);
-       theMap[AccelerationY] = AccelerationType(value);
-       theMap[AccelerationZ] = AccelerationType(value);
-       theMap[MassAirFlow] = MassAirFlowType(value);
+       if(name == VehicleSpeed ) return new VehicleSpeedType(value);
+       else if(name == EngineSpeed) return new EngineSpeedType(value);
+       else if(name == TransmissionShiftPosition) return new TransmissionShiftPositionType(value);
+       else if(name == TransmissionGearPosition) return new TransmissionGearPositionType(value);
+       else if(name == ThrottlePosition) return new ThrottlePositionType(value);
+       else if(name == WheelBrake) return new WheelBrakeType(value);
+       else if(name == SteeringWheelAngle) return new SteeringWheelAngleType(value);
+       else if(name == TurnSignal) return new TurnSignalType(value);
+       else if(name == ClutchStatus) return new ClutchStatusType(value);
+       else if(name == EngineOilPressure) return new EngineOilPressureType(value);
+       else if(name == EngineCoolantTemperature) return new EngineCoolantTemperatureType(value);
+       else if(name == AccelerationX) return new AccelerationType(value);
+       else if(name == AccelerationY) return new AccelerationType(value);
+       else if(name == AccelerationZ) return new AccelerationType(value);
+       else if(name == MassAirFlow) return new MassAirFlowType(value);
 
-       return theMap[name];
+       return nullptr;
 }
index 20ecaa9..ad249d9 100644 (file)
@@ -118,7 +118,7 @@ public:
 
        static std::list<VehicleProperty::Property> capabilities();
 
-       static AbstractPropertyType getPropertyTypeForPropertyNameValue(Property name, std::string value);
+       static AbstractPropertyType* getPropertyTypeForPropertyNameValue(Property name, std::string value);
     
 };
 
index 94b65e8..65834b0 100644 (file)
@@ -69,7 +69,7 @@ public:
        virtual GVariant* toGVariant() = 0;
        virtual void fromGVariant(GVariant *value) = 0;
 
-       void setValue(AbstractPropertyType val)
+       void setValue(AbstractPropertyType* val)
        {
                mValue = val;
                updateValue();
@@ -85,7 +85,7 @@ public:
        template<typename T>
        T value()
        {
-               return mValue.value<T>();
+               return mValue->value<T>();
        }
        
 protected: ///methods:
@@ -94,7 +94,7 @@ protected: ///methods:
        
 protected:
        
-       AbstractPropertyType mValue;
+       AbstractPropertyType mValue;
        string mPropertyName;
        string mSignature;
        SetterFunc mSetterFunc;
index f21f3d1..3625340 100644 (file)
@@ -52,7 +52,7 @@ void DBusSink::supportedChanged(PropertyList supportedProperties)
                registerObject();
 }
 
-void DBusSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid)
+void DBusSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid)
 {
        if(!propertyDBusMap.count(property))
                return;
index abd55ac..1cf6c5a 100644 (file)
@@ -33,7 +33,7 @@ class DBusSink : public AbstractSink, public AbstractDBusInterface
 public:
        DBusSink(std::string interface, std::string path, AbstractRoutingEngine* engine, GDBusConnection* connection);
        virtual void supportedChanged(PropertyList supportedProperties);
-       virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, std::string uuid);
+       virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, std::string uuid);
        virtual std::string uuid();
 
 protected:
index b11bf14..e16aa98 100644 (file)
@@ -68,32 +68,37 @@ void ExampleSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply)
 {
        if(reply->property == VehicleProperty::VehicleSpeed)
        {
-               reply->value = BasicPropertyType<uint16_t>(velocity);
+               VehicleProperty::VehicleSpeedType temp(velocity);
+               reply->value = &temp;
                reply->completed(reply);
        }
        else if(reply->property == VehicleProperty::EngineSpeed)
        {
-               reply->value = BasicPropertyType<uint16_t>(engineSpeed);
+               VehicleProperty::EngineSpeedType temp(engineSpeed);
+               reply->value = &temp;
                reply->completed(reply);
        }
        else if(reply->property == VehicleProperty::AccelerationX)
        {
-               reply->value = BasicPropertyType<uint16_t>(accelerationX);
+               VehicleProperty::AccelerationType temp(accelerationX);
+               reply->value = &temp;
                reply->completed(reply);
        }
        else if(reply->property == VehicleProperty::TransmissionShiftPosition)
        {
-               reply->value = BasicPropertyType<uint16_t>(transmissionShiftPostion);
+               VehicleProperty::TransmissionShiftPositionType temp(transmissionShiftPostion);
+               reply->value = &temp;
                reply->completed(reply);
        }
        else if(reply->property == VehicleProperty::SteeringWheelAngle)
        {
-               reply->value = BasicPropertyType<uint16_t>(steeringWheelAngle);
+               VehicleProperty::SteeringWheelAngleType temp(steeringWheelAngle);
+               reply->value = &temp;
                reply->completed(reply);
        }
 }
 
-void ExampleSourcePlugin::setProperty(VehicleProperty::Property , AbstractPropertyType )
+void ExampleSourcePlugin::setProperty(VehicleProperty::Property , AbstractPropertyType *)
 {
 
 }
@@ -135,11 +140,19 @@ void ExampleSourcePlugin::randomizeProperties()
        DebugOut()<<"setting velocity to: "<<velocity<<endl;
        DebugOut()<<"setting enginespeed to: "<<engineSpeed<<endl;
        
-       routingEngine->updateProperty(VehicleProperty::VehicleSpeed, BasicPropertyType<uint16_t>(velocity));
-       routingEngine->updateProperty(VehicleProperty::EngineSpeed, BasicPropertyType<uint16_t>(engineSpeed));
-       routingEngine->updateProperty(VehicleProperty::AccelerationX, BasicPropertyType<uint16_t>(accelerationX));
-       routingEngine->updateProperty(VehicleProperty::SteeringWheelAngle, BasicPropertyType<uint16_t>(steeringWheelAngle));
-       routingEngine->updateProperty(VehicleProperty::TransmissionShiftPosition, BasicPropertyType<uint16_t>(transmissionShiftPostion));
-       routingEngine->updateProperty(VehicleProperty::ThrottlePosition, BasicPropertyType<uint16_t>(throttlePos));
-       routingEngine->updateProperty(VehicleProperty::EngineCoolantTemperature, BasicPropertyType<uint16_t>(engineCoolant));
+       VehicleProperty::VehicleSpeedType vel(velocity);
+       VehicleProperty::EngineSpeedType es(engineSpeed);
+       VehicleProperty::AccelerationType ac(accelerationX);
+       VehicleProperty::SteeringWheelAngleType swa(steeringWheelAngle);
+       VehicleProperty::TransmissionShiftPositionType tsp(transmissionShiftPostion);
+       VehicleProperty::ThrottlePositionType tp(throttlePos);
+       VehicleProperty::EngineCoolantTemperatureType ec(engineCoolant);
+
+       routingEngine->updateProperty(VehicleProperty::VehicleSpeed, &vel);
+       routingEngine->updateProperty(VehicleProperty::EngineSpeed, &es);
+       routingEngine->updateProperty(VehicleProperty::AccelerationX, &ac);
+       routingEngine->updateProperty(VehicleProperty::SteeringWheelAngle, &swa);
+       routingEngine->updateProperty(VehicleProperty::TransmissionShiftPosition,&tsp);
+       routingEngine->updateProperty(VehicleProperty::ThrottlePosition, &tp);
+       routingEngine->updateProperty(VehicleProperty::EngineCoolantTemperature, &ec);
 }
index 5463816..a52008d 100644 (file)
@@ -32,12 +32,12 @@ public:
        
        string uuid();
        void getPropertyAsync(AsyncPropertyReply *reply);
-       void setProperty(VehicleProperty::Property, AbstractPropertyType);
+       void setProperty(VehicleProperty::Property, AbstractPropertyType*);
        void subscribeToPropertyChanges(VehicleProperty::Property property);
        void unsubscribeToPropertyChanges(VehicleProperty::Property property);
        PropertyList supported();
        
-       void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid) {}
+       void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {}
        void supportedChanged(PropertyList) {}
        
        void randomizeProperties();
index 3fe0bdb..bb379b2 100644 (file)
@@ -33,7 +33,7 @@ ExampleSink::ExampleSink(AbstractRoutingEngine* engine): AbstractSink(engine)
 
        AsyncPropertyRequest velocityRequest;
        velocityRequest.property = VehicleProperty::VehicleSpeed;
-       velocityRequest.completed = [](AsyncPropertyReply* reply) { DebugOut()<<"Velocity Async request completed: "<<reply->value.toString()<<endl; };
+       velocityRequest.completed = [](AsyncPropertyReply* reply) { DebugOut()<<"Velocity Async request completed: "<<reply->value->toString()<<endl; };
 
        AsyncPropertyReply* reply = routingEngine->getPropertyAsync(velocityRequest);
        routingEngine->registerSink(this);
@@ -52,9 +52,9 @@ void ExampleSink::supportedChanged(PropertyList supportedProperties)
        routingEngine->subscribeToProperty(VehicleProperty::VehicleSpeed, this);
 }
 
-void ExampleSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, std::string uuid)
+void ExampleSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid)
 {
-       DebugOut()<<property<<" value: "<<value.toString()<<endl;
+       DebugOut()<<property<<" value: "<<value->toString()<<endl;
 }
 
 std::string ExampleSink::uuid()
index f672168..717ffec 100644 (file)
@@ -30,7 +30,7 @@ public:
        ExampleSink(AbstractRoutingEngine* engine);
        virtual PropertyList subscriptions();
        virtual void supportedChanged(PropertyList supportedProperties);
-       virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, std::string uuid);
+       virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid);
        virtual std::string uuid();
 };
 
index 8e0ce41..a8cdfe1 100644 (file)
@@ -45,7 +45,7 @@ string WebSocketSink::uuid()
 {
        return m_uuid;
 }
-void WebSocketSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string  uuid)
+void WebSocketSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string  uuid)
 {
   //printf("Got property:%i\n",boost::any_cast<uint16_t>(reply->value));
        //uint16_t velocity = boost::any_cast<uint16_t>(value);
@@ -65,7 +65,7 @@ void WebSocketSink::propertyChanged(VehicleProperty::Property property, Abstract
        }
        
        
-       s << "{\"type\":\"valuechanged\",\"name\":\"" << tmpstr << "\",\"data\":\"" << value.toString() << "\",\"transactionid\":\"" << m_uuid << "\"}";
+       s << "{\"type\":\"valuechanged\",\"name\":\"" << tmpstr << "\",\"data\":\"" << value->toString() << "\",\"transactionid\":\"" << m_uuid << "\"}";
        
        string replystr = s.str();
        printf("Reply: %s\n",replystr.c_str());
index 57c0b1a..752a3d6 100644 (file)
@@ -30,7 +30,7 @@ public:
        WebSocketSink(AbstractRoutingEngine* re,libwebsocket *wsi,string uuid,VehicleProperty::Property property,std::string ambdproperty);
        ~WebSocketSink();
        string uuid() ;
-       void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string  uuid);
+       void propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string  uuid);
        void supportedChanged(PropertyList supportedProperties);
        PropertyList subscriptions();
 private:
index e69e5b9..acd768b 100644 (file)
@@ -86,7 +86,7 @@ void WebSocketSinkManager::addSingleShotSink(libwebsocket* socket, VehicleProper
        }
        velocityRequest.completed = [socket,id,property](AsyncPropertyReply* reply)
        {
-               printf("Got property:%s\n",reply->value.toString().c_str());
+               printf("Got property:%s\n",reply->value->toString().c_str());
                //uint16_t velocity = boost::any_cast<uint16_t>(reply->value);
                stringstream s;
                
@@ -121,7 +121,7 @@ void WebSocketSinkManager::addSingleShotSink(libwebsocket* socket, VehicleProper
                        //}
                }*/
                tmpstr = property;
-               s << "{\"type\":\"methodReply\",\"name\":\"get\",\"data\":[{\"name\":\"" << tmpstr << "\",\"value\":\"" << reply->value.toString() << "\"}],\"transactionid\":\"" << id << "\"}";
+               s << "{\"type\":\"methodReply\",\"name\":\"get\",\"data\":[{\"name\":\"" << tmpstr << "\",\"value\":\"" << reply->value->toString() << "\"}],\"transactionid\":\"" << id << "\"}";
                
                string replystr = s.str();
                printf("Reply: %s\n",replystr.c_str());
index 827bc2d..5ea1602 100644 (file)
@@ -212,7 +212,9 @@ static int callback_http_only(libwebsocket_context *context,struct libwebsocket
                        //data.front()
                        try
                        {
-                               m_re->updateProperty(name,VehicleProperty::getPropertyTypeForPropertyNameValue(name,data.front()));
+                               AbstractPropertyType* type = VehicleProperty::getPropertyTypeForPropertyNameValue(name,data.front());
+                               m_re->updateProperty(name, type);
+                               delete type;
                        }
                        catch (exception ex)
                        {
@@ -425,7 +427,7 @@ void WebSocketSource::getPropertyAsync(AsyncPropertyReply *reply)
        }*/
 }
 
-void WebSocketSource::setProperty(VehicleProperty::Property , AbstractPropertyType )
+void WebSocketSource::setProperty(VehicleProperty::Property , AbstractPropertyType )
 {
 
 }
index 10b926a..5c4e9e0 100644 (file)
@@ -36,7 +36,7 @@ public:
     string uuid();
        boost::any getProperty(VehicleProperty::Property property);
        void getPropertyAsync(AsyncPropertyReply *reply);
-       void setProperty(VehicleProperty::Property, AbstractPropertyType);
+       void setProperty(VehicleProperty::Property, AbstractPropertyType*);
        void subscribeToPropertyChanges(VehicleProperty::Property property);
        void unsubscribeToPropertyChanges(VehicleProperty::Property property);
        PropertyList supported();
@@ -47,7 +47,7 @@ public:
        PropertyList activeRequests;
        PropertyList removeRequests;
        void setSupported(PropertyList list);
-       void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid) {}
+       void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {}
        void supportedChanged(PropertyList) {}
        
        //void randomizeProperties();
index db5a335..db31f77 100644 (file)
@@ -62,7 +62,7 @@ public:
        WheelPrivate(WheelSourcePlugin *parent, AbstractRoutingEngine *route);
        ~WheelPrivate();
 
-       AbstractPropertyType getProperty(VehicleProperty::Property propType);
+       AbstractPropertyType *getProperty(VehicleProperty::Property propType);
 
        friend void readCallback(GObject *srcObj, GAsyncResult *res, gpointer userData);
 
@@ -137,9 +137,11 @@ void WheelSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply)
 
        reply->value = this->mWheel->getProperty(reply->property);
        reply->completed(reply);
+
+       delete reply->value;
 }
 
-void WheelSourcePlugin::setProperty(VehicleProperty::Property , AbstractPropertyType )
+void WheelSourcePlugin::setProperty(VehicleProperty::Property , AbstractPropertyType )
 {
 
 }
@@ -229,34 +231,34 @@ WheelPrivate::~WheelPrivate()
 }
 
 
-AbstractPropertyType WheelPrivate::getProperty(VehicleProperty::Property propType)
+AbstractPropertyType *WheelPrivate::getProperty(VehicleProperty::Property propType)
 {
        if (propType == VehicleProperty::VehicleSpeed)
-               return VehicleProperty::VehicleSpeedType(this->calcCarSpeed());
+               return new VehicleProperty::VehicleSpeedType(this->calcCarSpeed());
        else if (propType == VehicleProperty::EngineSpeed)
-               return VehicleProperty::EngineSpeedType(this->calcRPM());
+               return new VehicleProperty::EngineSpeedType(this->calcRPM());
        else if (propType == VehicleProperty::TransmissionShiftPosition)
-               return VehicleProperty::TransmissionShiftPositionType(this->currentGear);
+               return new VehicleProperty::TransmissionShiftPositionType(this->currentGear);
        else if (propType == VehicleProperty::ThrottlePosition)
-               return VehicleProperty::ThrottlePositionType(this->throttle);
+               return new VehicleProperty::ThrottlePositionType(this->throttle);
        else if (propType == VehicleProperty::WheelBrake)
-               return VehicleProperty::WheelBrakeType(this->brake);
+               return new VehicleProperty::WheelBrakeType(this->brake);
        else if (propType == VehicleProperty::SteeringWheelAngle)
-               return VehicleProperty::SteeringWheelAngleType(this->steeringAngle);
+               return new VehicleProperty::SteeringWheelAngleType(this->steeringAngle);
        else if (propType == VehicleProperty::TurnSignal)
-               return VehicleProperty::TurnSignalType(this->turnSignal);
+               return new VehicleProperty::TurnSignalType(this->turnSignal);
        else if (propType == VehicleProperty::ClutchStatus)
-               return VehicleProperty::ClutchStatusType(this->clutch);
+               return new VehicleProperty::ClutchStatusType(this->clutch);
        else if (propType == VehicleProperty::EngineOilPressure)
-               return VehicleProperty::EngineOilPressureType(this->oilPSI);
+               return new VehicleProperty::EngineOilPressureType(this->oilPSI);
        else if (propType == VehicleProperty::EngineCoolantTemperature)
-               return VehicleProperty::EngineCoolantTemperatureType(this->coolantTemp);
+               return new VehicleProperty::EngineCoolantTemperatureType(this->coolantTemp);
        else if (propType == VehicleProperty::MachineGunTurretStatus)
-               return VehicleProperty::MachineGunTurretStatusType(this->machineGuns);
+               return new VehicleProperty::MachineGunTurretStatusType(this->machineGuns);
        else
                cout << "Unhandled getProperty type: " << propType << endl;
 
-       return AbstractPropertyType();
+       return nullptr;
 }
 
 void WheelPrivate::newButtonValue(char number, bool val)
@@ -407,7 +409,8 @@ void WheelPrivate::gotData(GAsyncResult *res)
 void WheelPrivate::changeMachineGuns(bool val)
 {
        this->machineGuns = val;
-       this->re->updateProperty(VehicleProperty::MachineGunTurretStatus, VehicleProperty::MachineGunTurretStatusType(this->machineGuns));
+       VehicleProperty::MachineGunTurretStatusType temp(this->machineGuns);
+       this->re->updateProperty(VehicleProperty::MachineGunTurretStatus, &temp);
 }
 
 void WheelPrivate::changeTurnSignal(TurnSignal dir, bool val)
@@ -420,31 +423,37 @@ void WheelPrivate::changeTurnSignal(TurnSignal dir, bool val)
                        tsVal = 1;
        }
        this->turnSignal = tsVal;
-       this->re->updateProperty(VehicleProperty::TurnSignal, VehicleProperty::TurnSignalType(this->turnSignal));
+       VehicleProperty::TurnSignalType temp(this->turnSignal);
+       this->re->updateProperty(VehicleProperty::TurnSignal, &temp);
 }
 
 void WheelPrivate::changeGear(int gear)
 {
        this->currentGear = gear;
-       this->re->updateProperty(VehicleProperty::TransmissionShiftPosition, VehicleProperty::TransmissionShiftPositionType(this->currentGear));
-       this->re->updateProperty(VehicleProperty::VehicleSpeed, VehicleProperty::VehicleSpeedType(this->calcCarSpeed()));
+       VehicleProperty::TransmissionShiftPositionType tempTrans(this->currentGear);
+       VehicleProperty::VehicleSpeedType tempSpeed(this->calcCarSpeed());
+       this->re->updateProperty(VehicleProperty::TransmissionShiftPosition, &tempTrans);
+       this->re->updateProperty(VehicleProperty::VehicleSpeed, &tempSpeed);
 }
 
 void WheelPrivate::changeOilPressure(bool increase)
 {
-       this->re->updateProperty(VehicleProperty::EngineOilPressure, VehicleProperty::EngineOilPressureType(increase ? ++this->oilPSI : --this->oilPSI));
+       VehicleProperty::EngineOilPressureType temp(increase ? ++this->oilPSI : --this->oilPSI);
+       this->re->updateProperty(VehicleProperty::EngineOilPressure, &temp);
 }
 
 void WheelPrivate::changeCoolantTemp(bool increase)
 {
-       this->re->updateProperty(VehicleProperty::EngineCoolantTemperature, VehicleProperty::EngineCoolantTemperatureType(increase ? ++this->coolantTemp : --this->coolantTemp));
+        VehicleProperty::EngineCoolantTemperatureType temp(increase ? ++this->coolantTemp : --this->coolantTemp);
+       this->re->updateProperty(VehicleProperty::EngineCoolantTemperature, &temp);
 }
 
 
 void WheelPrivate::changeSteeringAngle(int val)
 {
        this->steeringAngle = (((double)val/(double)32767.0) + (double)1.0) * (double)180.0;
-       this->re->updateProperty(VehicleProperty::SteeringWheelAngle, VehicleProperty::SteeringWheelAngleType(this->steeringAngle));
+       VehicleProperty::SteeringWheelAngleType temp(this->steeringAngle);
+       this->re->updateProperty(VehicleProperty::SteeringWheelAngle, &temp);
 }
 
 void WheelPrivate::changeClutch(int val)
@@ -452,16 +461,23 @@ void WheelPrivate::changeClutch(int val)
        this->oldClutch = this->clutch;
        this->clutch = (val < 20000);
        if (this->oldClutch != this->clutch)
-               this->re->updateProperty(VehicleProperty::ClutchStatus, VehicleProperty::ClutchStatusType(this->clutch));
+       {
+               VehicleProperty::ClutchStatusType temp(this->clutch);
+               this->re->updateProperty(VehicleProperty::ClutchStatus, &temp);
+       }
 }
 
 void WheelPrivate::changeThrottle(int val)
 {
        this->throttle = ((double)(val - 32767)/(double)-65534.0)*(double)100.0;
 
-       this->re->updateProperty(VehicleProperty::ThrottlePosition, VehicleProperty::ThrottlePositionType(this->throttle));
-       this->re->updateProperty(VehicleProperty::EngineSpeed, VehicleProperty::EngineSpeedType(this->calcRPM()));
-       this->re->updateProperty(VehicleProperty::VehicleSpeed, VehicleProperty::VehicleSpeedType(this->calcCarSpeed()));
+       VehicleProperty::ThrottlePositionType tempThrottle(this->throttle);
+       VehicleProperty::EngineSpeedType tempRpm(this->calcRPM());
+       VehicleProperty::VehicleSpeedType tempSpeed(this->calcCarSpeed());
+
+       this->re->updateProperty(VehicleProperty::ThrottlePosition, &tempThrottle);
+       this->re->updateProperty(VehicleProperty::EngineSpeed, &tempRpm);
+       this->re->updateProperty(VehicleProperty::VehicleSpeed, &tempSpeed);
 }
 
 void WheelPrivate::changeBrake(int val)
@@ -469,7 +485,10 @@ void WheelPrivate::changeBrake(int val)
        this->oldBrake = this->brake;
        this->brake = (val < 20000);
        if (this->oldBrake != this->brake)
-               this->re->updateProperty(VehicleProperty::WheelBrake, VehicleProperty::WheelBrakeType(this->brake));
+       {
+               VehicleProperty::WheelBrakeType temp(this->brake);
+               this->re->updateProperty(VehicleProperty::WheelBrake, &temp);
+       }
 }
 
 
index 1c44890..c499965 100644 (file)
@@ -36,12 +36,12 @@ public:
        string uuid();
        AbstractPropertyType getProperty(VehicleProperty::Property property);
        void getPropertyAsync(AsyncPropertyReply *reply);
-       void setProperty(VehicleProperty::Property, AbstractPropertyType);
+       void setProperty(VehicleProperty::Property, AbstractPropertyType*);
        void subscribeToPropertyChanges(VehicleProperty::Property property);
        void unsubscribeToPropertyChanges(VehicleProperty::Property property);
        PropertyList supported();
        
-       void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid) {}
+       void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {}
        void supportedChanged(PropertyList) {}
 
        friend class WheelPrivate;