+- bluetooth adapter setting in obd2source
- test for memory leaks in websocket sink plugin
- per-source property filtering in routing engine
- historic data "get" interface in routing engine
public:
virtual std::string toString() = 0;
+ virtual void fromString(std::string)= 0;
+
void setValue(boost::any val)
{
mValue = val;
else throw std::runtime_error("value cannot be empty");
}
+ void fromString(std::string val)
+ {
+ if(!val.empty() && val != "")
+ {
+ serialize<T>(val);
+ }
+ }
+
std::string toString()
{
std::stringstream stream;
return *this;
}
+ void fromString(std::string val)
+ {
+ setValue(val);
+ }
+
std::string toString()
{
using namespace std;
+std::map<VehicleProperty::Property, VehicleProperty::PropertyTypeFactoryCallback> VehicleProperty::registeredPropertyFactoryMap;
+
const VehicleProperty::Property VehicleProperty::NoValue = "NoValue";
const VehicleProperty::Property VehicleProperty::VehicleSpeed = "VehicleSpeed";
const VehicleProperty::Property VehicleProperty::EngineSpeed = "EngineSpeed";
mProperties.push_back(SteeringWheelAngle);
mProperties.push_back(TurnSignal);
mProperties.push_back(ClutchStatus);
- mProperties.push_back((EngineOilPressure));
+ mProperties.push_back(EngineOilPressure);
mProperties.push_back(EngineCoolantTemperature);
mProperties.push_back(AccelerationX);
mProperties.push_back(AccelerationY);
else if(name == TirePressureLeftRear) return new TirePressureType(value);
else if(name == TirePressureRightRear) return new TirePressureType(value);
+ else
+ {
+ if(registeredPropertyFactoryMap.count(name) > 0)
+ {
+ VehicleProperty::PropertyTypeFactoryCallback cb = registeredPropertyFactoryMap[name];
+ if ( cb != NULL )
+ {
+ AbstractPropertyType* type = cb();
+ if(type == NULL)
+ throw std::runtime_error("Cannot return NULL in a PropertyTypeFactory");
+
+ type->fromString(value);
+
+ return type;
+ }
+
+ }
+ }
return nullptr;
}
+
+void VehicleProperty::registerProperty(VehicleProperty::Property name, VehicleProperty::PropertyTypeFactoryCallback factory)
+{
+ registeredPropertyFactoryMap[name] = factory;
+}
#include <list>
#include <set>
#include <sstream>
+#include <map>
#include <abstractpropertytype.h>
VehicleProperty();
typedef std::string Property;
+ typedef std::function<AbstractPropertyType* (void)> PropertyTypeFactoryCallback;
/// Various property types:
* transfered to the caller.
*/
static AbstractPropertyType* getPropertyTypeForPropertyNameValue(Property name, std::string value);
+
+ static void registerProperty(Property name, PropertyTypeFactoryCallback factory);
+
+private:
+
+ static std::map<Property, PropertyTypeFactoryCallback> registeredPropertyFactoryMap;
};