#include <string>
#include <sstream>
#include <boost/any.hpp>
+#include <boost/lexical_cast.hpp>
class AbstractPropertyType
{
setValue(val);
}
+ BasicPropertyType(std::string val)
+ {
+ setValue(boost::lexical_cast<T,std::string>(val));
+ }
+
std::string toString()
{
std::stringstream stream;
#include "vehicleproperty.h"
+#include <map>
using namespace std;
return mProperties;
}
+
+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);
+
+ return theMap[name];
+}
/**< Acceleration on the 'x' axis in 1/1000 gravitational acceleration "g-force" */
static const Property AccelerationX;
- typedef BasicPropertyType<uint16_t> AcclerationType;
+ typedef BasicPropertyType<uint16_t> AccelerationType;
/**< Acceleration on the 'y' axis in 1/1000 gravitational acceleration "g-force" */
static const Property AccelerationY;
typedef BasicPropertyType<uint16_t> MassAirFlowType;
static std::list<VehicleProperty::Property> capabilities();
+
+ static AbstractPropertyType getPropertyTypeForPropertyNameValue(Property name, std::string value);
};
//data.front()
try
{
- uint16_t val = boost::lexical_cast<uint16_t,string>(data.front());
- m_re->updateProperty(name,boost::any(val));
+ m_re->updateProperty(name,VehicleProperty::getPropertyTypeForPropertyNameValue(name,data.front()));
}
catch (exception ex)
{
}*/
}
-void WebSocketSource::setProperty(VehicleProperty::Property , boost::any )
+void WebSocketSource::setProperty(VehicleProperty::Property , AbstractPropertyType )
{
}
string uuid();
boost::any getProperty(VehicleProperty::Property property);
void getPropertyAsync(AsyncPropertyReply *reply);
- void setProperty(VehicleProperty::Property, boost::any);
+ void setProperty(VehicleProperty::Property, AbstractPropertyType);
void subscribeToPropertyChanges(VehicleProperty::Property property);
void unsubscribeToPropertyChanges(VehicleProperty::Property property);
PropertyList supported();
PropertyList activeRequests;
PropertyList removeRequests;
void setSupported(PropertyList list);
- void propertyChanged(VehicleProperty::Property property, boost::any value, string uuid) {}
+ void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid) {}
void supportedChanged(PropertyList) {}
//void randomizeProperties();