}
}
-void Core::updateProperty(VehicleProperty::Property property, boost::any value)
+void Core::updateProperty(VehicleProperty::Property property, AbstractPropertyType value)
{
SinkList list = propertySinkMap[property];
return reply;
}
-void Core::setProperty(VehicleProperty::Property property, boost::any value)
+void Core::setProperty(VehicleProperty::Property property, AbstractPropertyType value)
{
for(SourceList::iterator itr = mSources.begin(); itr != mSources.end(); itr++)
{
void setSupported(PropertyList supported, AbstractSource* source);
void updateSupported(PropertyList added, PropertyList removed);
- void updateProperty(VehicleProperty::Property property, boost::any 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, boost::any);
+ void setProperty(VehicleProperty::Property,AbstractPropertyType);
void subscribeToProperty(VehicleProperty::Property, AbstractSink* self);
void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self);
PropertyList supported() { return mMasterPropertyList; }
-set(amb_sources abstractroutingengine.cpp listplusplus.cpp abstractsink.cpp vehicleproperty.cpp abstractsource.cpp debugout.cpp)
-set(amb_headers_install vehicleproperty.h debugout.h abstractsource.h)
+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} )
add_library(amb SHARED ${amb_sources})
#include <boost/any.hpp>
#include <functional>
#include "vehicleproperty.h"
+#include "abstractpropertytype.h"
class AbstractSink;
class AbstractSource;
this->completed = request.completed;
}
- boost::any value;
+ AbstractPropertyType value;
};
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, boost::any 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, boost::any) = 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;
#include <boost/any.hpp>
#include "vehicleproperty.h"
+#include "abstractpropertytype.h"
using namespace std;
///Pure virtual methods:
virtual string uuid() = 0;
- virtual void propertyChanged(VehicleProperty::Property property, boost::any value, string uuid) = 0;
+ virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid) = 0;
virtual void supportedChanged(PropertyList supportedProperties) = 0;
protected:
#include "abstractsink.h"
#include "vehicleproperty.h"
#include "abstractroutingengine.h"
+#include "abstractpropertytype.h"
using namespace std;
///pure virtual methods:
- virtual boost::any getProperty(VehicleProperty::Property) = 0;
+ virtual AbstractPropertyType getProperty(VehicleProperty::Property) = 0;
virtual void getPropertyAsync(AsyncPropertyReply *reply) = 0;
- virtual void setProperty(VehicleProperty::Property property, boost::any 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;
#include <list>
#include <set>
+#include <abstractpropertytype.h>
class VehicleProperty
{
/**< Vehicle Velocity in km/h */
static const Property VehicleSpeed;
+ typedef BasicPropertyType<uint16_t> VehicleSpeedType;
/**< Engine Speed in rotations per minute */
static const Property EngineSpeed;
+ typedef BasicPropertyType<uint16_t> EngineSpeedType;
/**< Transmission Shift Position
* 0 = Neutral
* 255 = Park
*/
static const Property TransmissionShiftPosition;
+ typedef BasicPropertyType<unsigned char> TransmissionShiftPositionType;
/**< Transmission Gear Position
* 0 = Neutral
* 64 = CVT
*/
static const Property TransmissionGearPosition;
+ typedef BasicPropertyType<unsigned char> TransmissionGearPositionType;
/**< Throttle position 0-100% */
static const Property ThrottlePosition;
+ typedef BasicPropertyType<unsigned char> ThrottlePositionType;
/**< Wheel brake position. Engaged = true, Idle = false */
static const Property WheelBrake;
+ typedef BasicPropertyType<bool> WheelBrakeType;
/**< Steering wheel angle (0-359) */
static const Property SteeringWheelAngle;
+ typedef BasicPropertyType<uint16_t> SteeringWheelAngleType;
/**< 0=off, 1=right, 2=left, 3=hazard */
static const Property TurnSignal;
+ typedef BasicPropertyType<unsigned char> TurnSignalType;
/**< Clutch pedal status 0=off, 1=on */
static const Property ClutchStatus;
{
if(reply->property == VehicleProperty::VehicleSpeed)
{
- reply->value = velocity;
+ reply->value = BasicPropertyType<uint16_t>(velocity);
reply->completed(reply);
}
else if(reply->property == VehicleProperty::EngineSpeed)
{
- reply->value = engineSpeed;
+ reply->value = BasicPropertyType<uint16_t>(engineSpeed);
reply->completed(reply);
}
else if(reply->property == VehicleProperty::AccelerationX)
{
- reply->value = accelerationX;
+ reply->value = BasicPropertyType<uint16_t>(accelerationX);
reply->completed(reply);
}
else if(reply->property == VehicleProperty::TransmissionShiftPosition)
{
- reply->value = transmissionShiftPostion;
+ reply->value = BasicPropertyType<uint16_t>(transmissionShiftPostion);
reply->completed(reply);
}
else if(reply->property == VehicleProperty::SteeringWheelAngle)
{
- reply->value = steeringWheelAngle;
+ reply->value = BasicPropertyType<uint16_t>(steeringWheelAngle);
reply->completed(reply);
}
}
-void ExampleSourcePlugin::setProperty(VehicleProperty::Property , boost::any )
+void ExampleSourcePlugin::setProperty(VehicleProperty::Property , AbstractPropertyType )
{
}
DebugOut()<<"setting velocity to: "<<velocity<<endl;
DebugOut()<<"setting enginespeed to: "<<engineSpeed<<endl;
- routingEngine->updateProperty(VehicleProperty::VehicleSpeed, velocity);
- routingEngine->updateProperty(VehicleProperty::EngineSpeed, engineSpeed);
- routingEngine->updateProperty(VehicleProperty::AccelerationX, accelerationX);
- routingEngine->updateProperty(VehicleProperty::SteeringWheelAngle, steeringWheelAngle);
- routingEngine->updateProperty(VehicleProperty::TransmissionShiftPosition, transmissionShiftPostion);
- routingEngine->updateProperty(VehicleProperty::ThrottlePosition, throttlePos);
- routingEngine->updateProperty(VehicleProperty::EngineCoolantTemperature, engineCoolant);
+ 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));
}
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();
- void propertyChanged(VehicleProperty::Property property, boost::any value, string uuid) {}
+ void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid) {}
void supportedChanged(PropertyList) {}
void randomizeProperties();
AsyncPropertyRequest velocityRequest;
velocityRequest.property = VehicleProperty::VehicleSpeed;
- velocityRequest.completed = [](AsyncPropertyReply* reply) { DebugOut()<<"Velocity Async request completed: "<<boost::any_cast<uint16_t>(reply->value)<<endl; };
+ velocityRequest.completed = [](AsyncPropertyReply* reply) { DebugOut()<<"Velocity Async request completed: "<<reply->value.toString()<<endl; };
AsyncPropertyReply* reply = routingEngine->getPropertyAsync(velocityRequest);
routingEngine->registerSink(this);
routingEngine->subscribeToProperty(VehicleProperty::VehicleSpeed, this);
}
-void ExampleSink::propertyChanged(VehicleProperty::Property property, boost::any value, std::string uuid)
+void ExampleSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, std::string uuid)
{
- DebugOut()<<property<<" value: "<<boost::any_cast<uint16_t>(value)<<endl;
+ DebugOut()<<property<<" value: "<<value.toString()<<endl;
}
std::string ExampleSink::uuid()
ExampleSink(AbstractRoutingEngine* engine);
virtual PropertyList subscriptions();
virtual void supportedChanged(PropertyList supportedProperties);
- virtual void propertyChanged(VehicleProperty::Property property, boost::any value, std::string uuid);
+ virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, std::string uuid);
virtual std::string uuid();
};
WheelPrivate(WheelSourcePlugin *parent, AbstractRoutingEngine *route);
~WheelPrivate();
- boost::any getProperty(VehicleProperty::Property propType);
+ AbstractPropertyType getProperty(VehicleProperty::Property propType);
friend void readCallback(GObject *srcObj, GAsyncResult *res, gpointer userData);
return "c0ffee8a-c605-4a06-9034-59c1deadbeef";
}
-boost::any WheelSourcePlugin::getProperty(VehicleProperty::Property property)
+AbstractPropertyType WheelSourcePlugin::getProperty(VehicleProperty::Property property)
{
return this->mWheel->getProperty(property);
}
reply->completed(reply);
}
-void WheelSourcePlugin::setProperty(VehicleProperty::Property , boost::any )
+void WheelSourcePlugin::setProperty(VehicleProperty::Property , AbstractPropertyType )
{
}
boost::any WheelPrivate::getProperty(VehicleProperty::Property propType)
{
if (propType == VehicleProperty::VehicleSpeed)
- return this->calcCarSpeed();
+ return BasicPropertyType<uint16_t>(this->calcCarSpeed())
else if (propType == VehicleProperty::EngineSpeed)
return this->calcRPM();
else if (propType == VehicleProperty::TransmissionShiftPosition)
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();
- void propertyChanged(VehicleProperty::Property property, boost::any value, string uuid) {}
+ void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid) {}
void supportedChanged(PropertyList) {}
friend class WheelPrivate;