major breakage ahead...
authorKevron Rees <tripzero.kev@gmail.com>
Tue, 28 Aug 2012 05:24:08 +0000 (22:24 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Tue, 28 Aug 2012 22:16:25 +0000 (15:16 -0700)
13 files changed:
ambd/core.cpp
ambd/core.h
lib/CMakeLists.txt
lib/abstractroutingengine.h
lib/abstractsink.h
lib/abstractsource.h
lib/vehicleproperty.h
plugins/exampleplugin.cpp
plugins/exampleplugin.h
plugins/examplesink.cpp
plugins/examplesink.h
plugins/wheel/wheelplugin.cpp
plugins/wheel/wheelplugin.h

index 23131dc..3fc39f9 100644 (file)
@@ -121,7 +121,7 @@ void Core::updateSupported(PropertyList added, PropertyList removed)
        }
 }
 
-void Core::updateProperty(VehicleProperty::Property property, boost::any 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, boost::any value)
+void Core::setProperty(VehicleProperty::Property property, AbstractPropertyType value)
 {
        for(SourceList::iterator itr = mSources.begin(); itr != mSources.end(); itr++)
        {
index 6c8dff5..222c094 100644 (file)
@@ -36,14 +36,14 @@ public:
 
        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; }
index fc2af68..5a5bcb1 100644 (file)
@@ -1,6 +1,6 @@
 
-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})
 
index 424c4d8..94fa9c8 100644 (file)
@@ -23,6 +23,7 @@
 #include <boost/any.hpp>
 #include <functional>
 #include "vehicleproperty.h"
+#include "abstractpropertytype.h"
 
 class AbstractSink;
 class AbstractSource;
@@ -47,7 +48,7 @@ public:
                this->completed = request.completed;
        }
 
-       boost::any value;
+       AbstractPropertyType value;
 };
 
 class AbstractRoutingEngine
@@ -55,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, 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;
index af71dd3..400487a 100644 (file)
@@ -26,6 +26,7 @@
 #include <boost/any.hpp>
 
 #include "vehicleproperty.h"
+#include "abstractpropertytype.h"
 
 using namespace std;
 
@@ -44,7 +45,7 @@ public:
        ///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:
index 5516f22..34ff456 100644 (file)
@@ -27,6 +27,7 @@
 #include "abstractsink.h"
 #include "vehicleproperty.h"
 #include "abstractroutingengine.h"
+#include "abstractpropertytype.h"
 
 using namespace std;
 
@@ -43,9 +44,9 @@ public:
        
        ///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;
index 40914d3..826f66c 100644 (file)
@@ -24,6 +24,7 @@
 #include <list>
 #include <set>
 
+#include <abstractpropertytype.h>
 
 class VehicleProperty
 {
@@ -41,9 +42,11 @@ public:
 
        /**< 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
@@ -55,6 +58,7 @@ public:
         * 255 = Park
         */
        static const Property TransmissionShiftPosition;
+       typedef BasicPropertyType<unsigned char> TransmissionShiftPositionType;
 
        /**< Transmission Gear Position
        * 0 = Neutral
@@ -64,18 +68,23 @@ public:
        * 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;
index f5e815e..0b931f2 100644 (file)
@@ -79,32 +79,32 @@ void ExampleSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply)
 {
        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 )
 {
 
 }
@@ -146,11 +146,11 @@ void ExampleSourcePlugin::randomizeProperties()
        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));
 }
index f19c1a8..50a3b21 100644 (file)
@@ -33,12 +33,12 @@ public:
        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();
index 950c839..3fe0bdb 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: "<<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);
@@ -52,9 +52,9 @@ void ExampleSink::supportedChanged(PropertyList supportedProperties)
        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()
index e7f14b7..f672168 100644 (file)
@@ -30,7 +30,7 @@ public:
        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();
 };
 
index 9e73370..a326cab 100644 (file)
@@ -62,7 +62,7 @@ public:
        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);
 
@@ -132,7 +132,7 @@ string WheelSourcePlugin::uuid()
        return "c0ffee8a-c605-4a06-9034-59c1deadbeef";
 }
 
-boost::any WheelSourcePlugin::getProperty(VehicleProperty::Property property)
+AbstractPropertyType WheelSourcePlugin::getProperty(VehicleProperty::Property property)
 {
        return this->mWheel->getProperty(property);
 }
@@ -143,7 +143,7 @@ void WheelSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply)
        reply->completed(reply);
 }
 
-void WheelSourcePlugin::setProperty(VehicleProperty::Property , boost::any )
+void WheelSourcePlugin::setProperty(VehicleProperty::Property , AbstractPropertyType )
 {
 
 }
@@ -236,7 +236,7 @@ WheelPrivate::~WheelPrivate()
 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)
index 6745c32..cb4ca4c 100644 (file)
@@ -36,12 +36,12 @@ public:
        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;