2 Copyright (C) 2012 Intel Corporation
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "vehicleproperty.h"
21 #include "listplusplus.h"
23 #include "mappropertytype.hpp"
27 #define REGISTERPROPERTY(property, defaultValue) \
28 registerPropertyPriv(property, []() { return new property ## Type(defaultValue); });
30 #define REGISTERPROPERTYWITHTYPE(property, type, defaultValue) \
31 registerPropertyPriv(property, []() { return new type(property, defaultValue); });
35 std::map<VehicleProperty::Property, VehicleProperty::PropertyTypeFactoryCallback> VehicleProperty::registeredPropertyFactoryMap;
37 VehicleProperty* VehicleProperty::thereCanOnlyBeOne = nullptr;
39 const char* Transmission::W3C::Park = "park";
40 const char* Transmission::W3C::Reverse = "reverse";
41 const char* Transmission::W3C::Neutral = "neutral";
42 const char* Transmission::W3C::Low = "low";
43 const char* Transmission::W3C::Drive = "drive";
44 const char* Transmission::W3C::Overdrive = "overdrive";
46 const char* Door::W3C::Closed = "closed";
47 const char* Door::W3C::Open = "open";
48 const char* Door::W3C::Ajar = "ajar";
50 const char* HVAC::W3C::FloorPanel = "floorpanel";
51 const char* HVAC::W3C::FloorDuct = "floorduct";
52 const char* HVAC::W3C::Bilevel = "bilevel";
53 const char* HVAC::W3C::DefrostFloor = "defrostfloor";
55 const VehicleProperty::Property VehicleProperty::NoValue = "NoValue";
56 const VehicleProperty::Property VehicleProperty::VehicleSpeed = "VehicleSpeed";
57 const VehicleProperty::Property VehicleProperty::EngineSpeed = "EngineSpeed";
58 const VehicleProperty::Property VehicleProperty::TransmissionShiftPosition = "TransmissionShiftPosition";
59 const VehicleProperty::Property VehicleProperty::TransmissionGearPosition = "TransmissionGearPostion";
60 const VehicleProperty::Property VehicleProperty::TransmissionMode = "TransmissionMode";
61 const VehicleProperty::Property VehicleProperty::TransmissionModeW3C = "TransmissionModeW3C";
62 const VehicleProperty::Property VehicleProperty::ThrottlePosition = "ThrottlePosition";
63 const VehicleProperty::Property VehicleProperty::WheelBrake = "WheelBrake";
64 const VehicleProperty::Property VehicleProperty::WheelBrakePressure = "WheelBrakePressure";
65 const VehicleProperty::Property VehicleProperty::SteeringWheelAngle = "SteeringWheelAngle";
66 const VehicleProperty::Property VehicleProperty::SteeringWheelAngleW3C = "SteeringWheelAngleW3C";
67 const VehicleProperty::Property VehicleProperty::TurnSignal = "TurnSignal";
68 const VehicleProperty::Property VehicleProperty::ClutchStatus = "ClutchStatus";
69 const VehicleProperty::Property VehicleProperty::EngineOilPressure = "EngineOilPressure";
70 const VehicleProperty::Property VehicleProperty::EngineCoolantTemperature = "EngineCoolantTemperature";
71 const VehicleProperty::Property VehicleProperty::EngineCoolantLevel = "EngineCoolantLevel";
72 const VehicleProperty::Property VehicleProperty::MachineGunTurretStatus = "MachineGunTurretStatus";
73 const VehicleProperty::Property VehicleProperty::AccelerationX = "AccelerationX";
74 const VehicleProperty::Property VehicleProperty::AccelerationY = "AccelerationY";
75 const VehicleProperty::Property VehicleProperty::AccelerationZ = "AccelerationZ";
76 const VehicleProperty::Property VehicleProperty::MassAirFlow = "MassAirFlow";
77 const VehicleProperty::Property VehicleProperty::ButtonEvent = "ButtonEvent";
78 const VehicleProperty::Property VehicleProperty::AirIntakeTemperature = "AirIntakeTemperature";
79 const VehicleProperty::Property VehicleProperty::BatteryVoltage = "BatteryVoltage";
80 const VehicleProperty::Property VehicleProperty::BatteryCurrent = "BatteryCurrent";
81 const VehicleProperty::Property VehicleProperty::BatteryChargeLevel = "BatteryChargeLevel";
82 const VehicleProperty::Property VehicleProperty::InteriorTemperature = "InteriorTemperature";
83 const VehicleProperty::Property VehicleProperty::ExteriorTemperature = "ExteriorTemperature";
84 const VehicleProperty::Property VehicleProperty::EngineOilTemperature = "EngineOilTemperature";
85 const VehicleProperty::Property VehicleProperty::VIN = "VIN";
86 const VehicleProperty::Property VehicleProperty::WMI = "WMI";
87 const VehicleProperty::Property VehicleProperty::TirePressure = "TirePressure";
88 const VehicleProperty::Property VehicleProperty::TirePressureLow = "TirePressureLow";
89 const VehicleProperty::Property VehicleProperty::TireTemperature = "TireTemperature";
90 const VehicleProperty::Property VehicleProperty::VehiclePowerMode = "VehiclePowerMode";
91 const VehicleProperty::Property VehicleProperty::TripMeters = "TripMeters";
92 const VehicleProperty::Property VehicleProperty::CruiseControlActive = "CruiseControlActive";
93 const VehicleProperty::Property VehicleProperty::CruiseControlSpeed = "CruiseControlSpeed";
94 const VehicleProperty::Property VehicleProperty::LightHead = "LightHead";
95 const VehicleProperty::Property VehicleProperty::LightLeftTurn = "LightLeftTurn";
96 const VehicleProperty::Property VehicleProperty::LightRightTurn = "LightRightTurn";
97 const VehicleProperty::Property VehicleProperty::LightParking = "LightParking";
98 const VehicleProperty::Property VehicleProperty::LightFog = "LightFog";
99 const VehicleProperty::Property VehicleProperty::LightHazard= "LightHazard";
100 const VehicleProperty::Property VehicleProperty::LightHighBeam = "LightHighBeam";
101 const VehicleProperty::Property VehicleProperty::LightBrake= "LightBrake";
102 const VehicleProperty::Property VehicleProperty::LightAutomatic= "LightAutomatic";
103 const VehicleProperty::Property VehicleProperty::LightDynamicHighBeam= "LightDynamicHighBeam";
104 const VehicleProperty::Property VehicleProperty::InteriorLightDriver = "InteriorLightDriver";
105 const VehicleProperty::Property VehicleProperty::InteriorLightCenter = "InteriorLightCenter";
106 const VehicleProperty::Property VehicleProperty::InteriorLightPassenger = "InteriorLightPassenger";
107 const VehicleProperty::Property VehicleProperty::EngineLoad = "EngineLoad";
108 const VehicleProperty::Property VehicleProperty::Horn = "Horn";
109 const VehicleProperty::Property VehicleProperty::FuelLevel = "FuelLevel";
110 const VehicleProperty::Property VehicleProperty::FuelConsumption = "FuelConsumption";
111 const VehicleProperty::Property VehicleProperty::FuelRange = "FuelRange";
112 const VehicleProperty::Property VehicleProperty::FuelEconomy = "FuelEconomy";
113 const VehicleProperty::Property VehicleProperty::FuelAverageEconomy = "FuelAverageEconomy";
114 const VehicleProperty::Property VehicleProperty::FuelAverageConsumption = "FuelAverageConsumption";
115 const VehicleProperty::Property VehicleProperty::FuelConsumptionSinceRestart = "FuelConsumptionSinceRestart";
116 const VehicleProperty::Property VehicleProperty::FuelTimeSinceRestart = "FuelTimeSinceRestart";
117 const VehicleProperty::Property VehicleProperty::FuelType = "FuelType";
118 const VehicleProperty::Property VehicleProperty::FuelPositionSide = "FuelPositionSide";
119 const VehicleProperty::Property VehicleProperty::EngineOilRemaining = "EngineOilRemaining";
120 const VehicleProperty::Property VehicleProperty::ExteriorBrightness = "ExteriorBrightness";
121 const VehicleProperty::Property VehicleProperty::Latitude = "Latitude";
122 const VehicleProperty::Property VehicleProperty::Longitude = "Longitude";
123 const VehicleProperty::Property VehicleProperty::Direction = "Direction";
124 const VehicleProperty::Property VehicleProperty::Altitude = "Altitude";
125 const VehicleProperty::Property VehicleProperty::VehicleWidth = "VehicleWidth";
126 const VehicleProperty::Property VehicleProperty::VehicleHeight = "VehicleHeight";
127 const VehicleProperty::Property VehicleProperty::VehicleLength = "VehicleLength";
128 const VehicleProperty::Property VehicleProperty::VehicleType = "VehicleType";
129 const VehicleProperty::Property VehicleProperty::DoorsPerRow = "DoorsPerRow";
130 const VehicleProperty::Property VehicleProperty::TransmissionGearType = "TransmissionGearType";
131 const VehicleProperty::Property VehicleProperty::FrontWheelRadius = "FrontWheelRadius";
132 const VehicleProperty::Property VehicleProperty::RearWheelRadius = "RearWheelRadius";
133 const VehicleProperty::Property VehicleProperty::WheelTrack = "WheelTrack";
134 const VehicleProperty::Property VehicleProperty::BrakePressure = "BrakePressure";
135 const VehicleProperty::Property VehicleProperty::Odometer = "Odometer";
136 const VehicleProperty::Property VehicleProperty::DistanceTotal = "DistanceTotal";
137 const VehicleProperty::Property VehicleProperty::DistanceSinceStart = "DistanceSinceStart";
138 const VehicleProperty::Property VehicleProperty::TransmissionFluidLevel = "TransmissionFluidLevel";
139 const VehicleProperty::Property VehicleProperty::BrakeFluidLevel = "BrakeFluidLevel";
140 const VehicleProperty::Property VehicleProperty::WasherFluidLevel = "WasherFluidLevel";
141 const VehicleProperty::Property VehicleProperty::SecurityAlertStatus = "SecurityAlertStatus";
142 const VehicleProperty::Property VehicleProperty::ParkingBrakeStatus = "ParkingBrakeStatus";
143 const VehicleProperty::Property VehicleProperty::ParkingLightStatus = "ParkingLightStatus";
144 const VehicleProperty::Property VehicleProperty::HazardLightStatus = "HazardLightStatus";
145 const VehicleProperty::Property VehicleProperty::AirbagStatus = "AirbagStatus";
146 const VehicleProperty::Property VehicleProperty::AntilockBrakingSystem = "AntilockBrakingSystem";
147 const VehicleProperty::Property VehicleProperty::TractionControlSystem = "TractionControlSystem";
148 const VehicleProperty::Property VehicleProperty::VehicleTopSpeedLimit = "VehicleTopSpeedLimit";
149 const VehicleProperty::Property VehicleProperty::DoorStatus = "DoorStatus";
150 const VehicleProperty::Property VehicleProperty::DoorStatusW3C = "DoorStatusW3C";
151 const VehicleProperty::Property VehicleProperty::DoorLockStatus = "DoorLockStatus";
152 const VehicleProperty::Property VehicleProperty::ChildLockStatus = "ChildLockStatus";
153 const VehicleProperty::Property VehicleProperty::SeatBeltStatus = "SeatBeltStatus";
154 const VehicleProperty::Property VehicleProperty::WindowLockStatus = "WindowLockStatus";
155 const VehicleProperty::Property VehicleProperty::OccupantStatus = "OccupantStatus";
156 const VehicleProperty::Property VehicleProperty::ObstacleDistance = "ObstacleDistance";
157 const VehicleProperty::Property VehicleProperty::RainSensor = "RainSensor";
158 const VehicleProperty::Property VehicleProperty::WindshieldWiper = "WindshieldWiper";
159 const VehicleProperty::Property VehicleProperty::AirflowDirection = "AirflowDirection";
160 const VehicleProperty::Property VehicleProperty::AirflowDirectionW3C = "AirflowDirectionW3C";
161 const VehicleProperty::Property VehicleProperty::FanSpeed = "FanSpeed";
162 const VehicleProperty::Property VehicleProperty::TargetTemperature = "TargetTemperature";
163 const VehicleProperty::Property VehicleProperty::AirConditioning = "AirConditioning";
164 const VehicleProperty::Property VehicleProperty::AirRecirculation = "AirRecirculation";
165 const VehicleProperty::Property VehicleProperty::Heater = "Heater";
166 const VehicleProperty::Property VehicleProperty::Defrost = "Defrost";
167 const VehicleProperty::Property VehicleProperty::DefrostWindow = "DefrostWindow";
168 const VehicleProperty::Property VehicleProperty::DefrostMirror = "DefrostMirror";
169 const VehicleProperty::Property VehicleProperty::SteeringWheelHeater = "SteeringWheelHeater";
170 const VehicleProperty::Property VehicleProperty::SeatHeater = "SeatHeater";
171 const VehicleProperty::Property VehicleProperty::SeatCooler = "SeatCooler";
172 const VehicleProperty::Property VehicleProperty::WindowStatus = "WindowStatus";
173 const VehicleProperty::Property VehicleProperty::Sunroof = "Sunroof";
174 const VehicleProperty::Property VehicleProperty::SunroofTilt = "SunroofTilt";
175 const VehicleProperty::Property VehicleProperty::ConvertibleRoof = "ConvertibleRoof";
176 const VehicleProperty::Property VehicleProperty::NightMode = "NightMode";
177 const VehicleProperty::Property VehicleProperty::DrivingMode = "DrivingMode";
178 const VehicleProperty::Property VehicleProperty::DrivingModeW3C = "DrivingModeW3C";
179 const VehicleProperty::Property VehicleProperty::KeyId = "KeyId";
180 const VehicleProperty::Property VehicleProperty::Language = "Language";
181 const VehicleProperty::Property VehicleProperty::MeasurementSystem = "MeasurementSystem";
182 const VehicleProperty::Property VehicleProperty::MirrorSettingPan = "MirrorPanSetting";
183 const VehicleProperty::Property VehicleProperty::MirrorSettingTilt= "MirrorTiltSetting";
184 const VehicleProperty::Property VehicleProperty::SteeringWheelPositionSlide = "SteeringWheelPositionSlide";
185 const VehicleProperty::Property VehicleProperty::SteeringWheelPositionTilt = "SteeringWheelPositionTilt";
186 const VehicleProperty::Property VehicleProperty::SeatPositionRecline = "SeatPositionRecline";
187 const VehicleProperty::Property VehicleProperty::SeatPositionSlide = "SeatPositionSlide";
188 const VehicleProperty::Property VehicleProperty::SeatPositionCushionHeight = "SeatPositionCushionHeight";
189 const VehicleProperty::Property VehicleProperty::SeatPositionHeadrest = "SeatPositionHeadrest";
190 const VehicleProperty::Property VehicleProperty::SeatPositionBackCushion = "SeatPositionBackCushion";
191 const VehicleProperty::Property VehicleProperty::SeatPositionSideCushion = "SeatPositionSideCushion";
192 const VehicleProperty::Property VehicleProperty::DashboardIllumination = "DashboardIllumination";
193 const VehicleProperty::Property VehicleProperty::GeneratedVehicleSoundMode = "GeneratedVehicleSoundMode";
194 const VehicleProperty::Property VehicleProperty::DriverId = "DriverId";
196 PropertyList VehicleProperty::mCapabilities;
197 PropertyList VehicleProperty::mCustomProperties;
199 VehicleProperty::VehicleProperty()
201 REGISTERPROPERTY( VehicleSpeed, 0);
202 REGISTERPROPERTY(EngineSpeed, 0);
203 REGISTERPROPERTY(TransmissionShiftPosition,Transmission::Neutral);
204 REGISTERPROPERTY(TransmissionGearPosition,Transmission::Neutral);
205 REGISTERPROPERTY(TransmissionMode,Transmission::Normal);
206 REGISTERPROPERTY(TransmissionModeW3C,"neutral");
207 REGISTERPROPERTY(ThrottlePosition, 0);
208 REGISTERPROPERTY(WheelBrake, false);
209 REGISTERPROPERTY(WheelBrakePressure,0);
210 REGISTERPROPERTY(SteeringWheelAngle,0);
211 REGISTERPROPERTY(SteeringWheelAngleW3C,0);
212 REGISTERPROPERTY(TurnSignal, TurnSignals::Off);
213 REGISTERPROPERTY(ClutchStatus, false);
214 REGISTERPROPERTY(EngineOilPressure, 0);
215 REGISTERPROPERTY(EngineOilTemperature, 0);
216 REGISTERPROPERTY(EngineOilRemaining,0);
217 REGISTERPROPERTY(EngineCoolantTemperature, 0);
218 REGISTERPROPERTY(EngineCoolantLevel, 0);
219 REGISTERPROPERTY(MachineGunTurretStatus, false);
220 REGISTERPROPERTY(AccelerationX,0);
221 REGISTERPROPERTY(AccelerationY,0);
222 REGISTERPROPERTY(AccelerationZ,0);
223 REGISTERPROPERTY(MassAirFlow,0);
224 REGISTERPROPERTY(ButtonEvent, ButtonEvents::NoButton);
225 REGISTERPROPERTY(AirIntakeTemperature,0)
226 REGISTERPROPERTY(BatteryVoltage, 0);
227 REGISTERPROPERTY(BatteryCurrent,0);
228 REGISTERPROPERTY(BatteryChargeLevel,0);
229 REGISTERPROPERTY(InteriorTemperature, 0);
230 REGISTERPROPERTY(ExteriorTemperature,0);
231 REGISTERPROPERTY(VIN, "");
232 REGISTERPROPERTY(WMI, "");
233 REGISTERPROPERTY(TirePressure, 0);
234 REGISTERPROPERTY(TirePressureLow, false);
235 REGISTERPROPERTY(TireTemperature,0);
236 REGISTERPROPERTY( VehiclePowerMode,Power::Off);
237 registerPropertyPriv(TripMeters,[](){
238 TripMetersType* t = new TripMetersType();
239 BasicPropertyType<uint16_t> v(0);
244 REGISTERPROPERTY(CruiseControlActive, false);
245 REGISTERPROPERTY(CruiseControlSpeed,0);
246 REGISTERPROPERTY(LightHead, false);
247 REGISTERPROPERTY(LightLeftTurn, false);
248 REGISTERPROPERTY(LightRightTurn, false);
249 REGISTERPROPERTY(LightParking, false);
250 REGISTERPROPERTY(LightFog, false);
251 REGISTERPROPERTY(LightHazard, false);
252 REGISTERPROPERTY(LightHighBeam, false);
253 REGISTERPROPERTY(LightBrake, false);
254 REGISTERPROPERTY(LightAutomatic, false);
255 REGISTERPROPERTY(LightDynamicHighBeam, false);
256 REGISTERPROPERTY(InteriorLightDriver, false);
257 REGISTERPROPERTY(InteriorLightPassenger, false);
258 REGISTERPROPERTY(InteriorLightCenter, false);
259 REGISTERPROPERTY(EngineLoad, 0);
260 REGISTERPROPERTY(Horn, false);
261 REGISTERPROPERTY(FuelLevel, 0);
262 REGISTERPROPERTY(FuelRange, 0);
263 REGISTERPROPERTY(FuelConsumption, 0);
264 REGISTERPROPERTY(FuelEconomy, 0);
265 REGISTERPROPERTY(FuelAverageEconomy, 0);
266 REGISTERPROPERTY(FuelAverageConsumption, 0);
267 REGISTERPROPERTY(FuelConsumptionSinceRestart, 0);
268 REGISTERPROPERTY(FuelTimeSinceRestart, 0);
269 REGISTERPROPERTY(FuelType, Fuel::Unknown);
270 REGISTERPROPERTY(FuelPositionSide, Fuel::UnknownPosition);
271 REGISTERPROPERTY(ExteriorBrightness, 0);
272 REGISTERPROPERTY(VehicleWidth, 0);
273 REGISTERPROPERTY(VehicleHeight, 0);
274 REGISTERPROPERTY(VehicleLength, 0);
275 REGISTERPROPERTY(Latitude, 0);
276 REGISTERPROPERTY(Longitude, 0);
277 REGISTERPROPERTY(Altitude,0);
278 REGISTERPROPERTY(Direction, 0);
279 REGISTERPROPERTY(VehicleType, Vehicle::Unknown);
280 registerPropertyPriv(DoorsPerRow, []() { BasicPropertyType<uint16_t> d(0); return new DoorsPerRowType(&d); });
281 REGISTERPROPERTY(TransmissionGearType, Transmission::Unknown);
282 REGISTERPROPERTY(FrontWheelRadius, 0);
283 REGISTERPROPERTY(RearWheelRadius, 0);
284 REGISTERPROPERTY(WheelTrack, 0);
285 REGISTERPROPERTY(BrakePressure, 0);
286 REGISTERPROPERTY(Odometer, 0);
287 REGISTERPROPERTY(DistanceTotal, 0);
288 REGISTERPROPERTY(DistanceSinceStart, 0);
289 REGISTERPROPERTY(TransmissionFluidLevel,0);
290 REGISTERPROPERTY(BrakeFluidLevel,0);
291 REGISTERPROPERTY(WasherFluidLevel,0);
292 REGISTERPROPERTY(SecurityAlertStatus,Security::Idle);
293 REGISTERPROPERTY(ParkingBrakeStatus, false);
294 REGISTERPROPERTY(ParkingLightStatus, false);
295 REGISTERPROPERTY(HazardLightStatus, false);
296 REGISTERPROPERTY(AirbagStatus, Airbag::Inactive);
298 REGISTERPROPERTY(AntilockBrakingSystem, false);
299 REGISTERPROPERTY(TractionControlSystem, false);
300 REGISTERPROPERTY(VehicleTopSpeedLimit, 0);
302 REGISTERPROPERTY(DoorStatus, Door::Closed);
303 REGISTERPROPERTY(DoorStatusW3C, Door::W3C::Closed);
304 REGISTERPROPERTY(DoorLockStatus, false);
305 REGISTERPROPERTY(ChildLockStatus, false);
306 REGISTERPROPERTY(SeatBeltStatus, false);
307 REGISTERPROPERTY(OccupantStatus, Seat::Vacant);
308 REGISTERPROPERTY(WindowLockStatus, false);
309 REGISTERPROPERTY(ObstacleDistance, 0);
311 REGISTERPROPERTY(RainSensor, 0);
312 REGISTERPROPERTY(WindshieldWiper, Window::Off);
313 REGISTERPROPERTY(AirflowDirection, HVAC::Front);
314 REGISTERPROPERTY(AirflowDirectionW3C, HVAC::W3C::FloorPanel);
315 REGISTERPROPERTY(FanSpeed, 0);
316 REGISTERPROPERTY(TargetTemperature, 0);
317 REGISTERPROPERTY(AirConditioning, false);
318 REGISTERPROPERTY(AirRecirculation, false);
319 REGISTERPROPERTY(Heater, false);
321 REGISTERPROPERTY(Defrost,false);
322 REGISTERPROPERTY(DefrostWindow,false);
323 REGISTERPROPERTY(DefrostMirror,false);
325 REGISTERPROPERTY(SteeringWheelHeater,false);
326 REGISTERPROPERTY(SeatHeater, 0);
327 REGISTERPROPERTY(SeatCooler, false);
328 REGISTERPROPERTY(WindowStatus, 100);
329 REGISTERPROPERTY(Sunroof, 0);
330 REGISTERPROPERTY(SunroofTilt, 0);
331 REGISTERPROPERTY(ConvertibleRoof, false);
332 REGISTERPROPERTY(NightMode, false);
333 REGISTERPROPERTY(DrivingMode, Driving::None);
334 REGISTERPROPERTY(DrivingModeW3C, false);
335 REGISTERPROPERTY(KeyId,"");
336 REGISTERPROPERTY(Language,"");
337 REGISTERPROPERTY(MeasurementSystem,Measurement::Metric);
338 REGISTERPROPERTY(MirrorSettingPan,0);
339 REGISTERPROPERTY(MirrorSettingTilt,0);
340 REGISTERPROPERTY(SteeringWheelPositionSlide,0);
341 REGISTERPROPERTY(SteeringWheelPositionTilt,0);
342 REGISTERPROPERTY(SeatPositionRecline,0);
343 REGISTERPROPERTY(SeatPositionSlide,0);
344 REGISTERPROPERTY(SeatPositionCushionHeight,0);
345 REGISTERPROPERTY(SeatPositionHeadrest,0);
346 REGISTERPROPERTY(SeatPositionBackCushion,0);
347 REGISTERPROPERTY(SeatPositionSideCushion,0);
348 REGISTERPROPERTY(DashboardIllumination,0);
349 REGISTERPROPERTY(GeneratedVehicleSoundMode, Vehicle::Normal);
350 REGISTERPROPERTY(DriverId, "");
354 void VehicleProperty::factory()
356 if(!thereCanOnlyBeOne)
357 thereCanOnlyBeOne = new VehicleProperty();
360 void VehicleProperty::shutdown()
362 if(thereCanOnlyBeOne){
363 delete thereCanOnlyBeOne;
364 thereCanOnlyBeOne = nullptr;
366 registeredPropertyFactoryMap.clear();
367 mCapabilities.clear();
368 mCustomProperties.clear();
371 PropertyList VehicleProperty::capabilities()
373 return mCapabilities;
376 PropertyList VehicleProperty::customProperties()
378 return mCustomProperties;
381 AbstractPropertyType* VehicleProperty::getPropertyTypeForPropertyNameValue(VehicleProperty::Property name, std::string value)
383 if(registeredPropertyFactoryMap.count(name) > 0)
385 VehicleProperty::PropertyTypeFactoryCallback cb = registeredPropertyFactoryMap[name];
388 AbstractPropertyType* type = cb();
390 throw std::runtime_error("Cannot return NULL in a PropertyTypeFactory");
393 type->fromString(value);
399 DebugOut(DebugOut::Error)<<"Property not found"<<endl;
404 bool VehicleProperty::registerProperty(VehicleProperty::Property name, VehicleProperty::PropertyTypeFactoryCallback factory)
406 if(!contains(mCustomProperties,name))
408 mCustomProperties.push_back(name);
410 return registerPropertyPriv(name, factory);
416 bool VehicleProperty::registerPropertyPriv(VehicleProperty::Property name, VehicleProperty::PropertyTypeFactoryCallback factory)
418 if(contains(mCapabilities,name))
420 DebugOut(0)<<__FUNCTION__<<" ERROR: property '"<<name<<"' already registered."<<endl;
424 registeredPropertyFactoryMap[name] = factory;
425 mCapabilities.push_back(name);