fixed unsubscribe
authorKevron Rees <tripzero.kev@gmail.com>
Thu, 23 Aug 2012 22:34:25 +0000 (15:34 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Thu, 23 Aug 2012 22:34:25 +0000 (15:34 -0700)
ambd/core.cpp
lib/vehicleproperty.cpp
lib/vehicleproperty.h
plugins/examplesink.cpp

index ada8123..d30f6f4 100644 (file)
@@ -43,7 +43,7 @@ void Core::setSupported(PropertyList supported, AbstractSource* source)
        {
                if(!ListPlusPlus<VehicleProperty::Property>(&mMasterPropertyList).contains((*itr)))
                {
-                       DebugOut()<<__FUNCTION__<<"() adding suport for property "<<VehicleProperty::name((*itr))<<endl;
+                       DebugOut()<<__FUNCTION__<<"() adding suport for property "<<(*itr)<<endl;
                        mMasterPropertyList.push_back((*itr));
                }
        }
@@ -154,7 +154,7 @@ void Core::subscribeToProperty(VehicleProperty::Property property, AbstractSink*
 {
        if(!ListPlusPlus<VehicleProperty::Property>(&mMasterPropertyList).contains((property)))
        {
-               DebugOut()<<__FUNCTION__<<"(): property not supported: "<<VehicleProperty::name(property)<<endl;
+               DebugOut()<<__FUNCTION__<<"(): property not supported: "<<property<<endl;
                return; 
        }
        
@@ -176,13 +176,11 @@ void Core::unsubscribeToProperty(VehicleProperty::Property property, AbstractSin
 {
        if(propertySinkMap.find(property) == propertySinkMap.end())
        {
-               DebugOut()<<__FUNCTION__<<"property not supported: "<<VehicleProperty::name(property);
+               DebugOut()<<__FUNCTION__<<"property not supported: "<<property;
                return; 
        }
-       
-       SinkList list = propertySinkMap[property];
-       
-       ListPlusPlus<AbstractSink*>(&list).removeOne(self);
+               
+       ListPlusPlus<AbstractSink*>(&propertySinkMap[property]).removeOne(self);
        
        for(SourceList::iterator itr = mSources.begin(); itr != mSources.end(); itr++)
        {
index bd21c52..c764d9b 100644 (file)
@@ -42,12 +42,3 @@ VehicleProperty::VehicleProperty()
 
 }
 
-string VehicleProperty::name(VehicleProperty::Property prop)
-{
-       return "";
-}
-
-VehicleProperty::Property VehicleProperty::value(string name)
-{
-       return VehicleProperty::NoValue;
-}
index 1449091..f5c920d 100644 (file)
@@ -35,36 +35,59 @@ public:
 
        typedef std::string Property;
 
-       //enum Property
-       //{
+       /// Various property types:
+
        static const Property NoValue;
-       static const Property VehicleSpeed; /**< Vehicle Velocity in km/h */
-       static const Property EngineSpeed;/**< Engine Speed in rotations per minute */
-       static const Property TransmissionShiftPosition; /**< Transmission Shift Position
-                                                                       * 0 = Neutral
-                                                                       * 1 = 1st
-                                                                       * 2 = 2nd
-                                                                       * ...
-                                                                       * 64 = Drive
-                                                                       * 128 = Reverse
-                                                                       * 255 = Park
-                                                                       */
-
-               static const Property ThrottlePosition; /**< Throttle position 0-100% */
-               static const Property WheelBrake; /**< Wheel brake position.  Engaged = true, Idle = false */
-               static const Property SteeringWheelAngle; /**< Steering wheel angle (0-359) */
-               static const Property TurnSignal; /**< 0=off, 1=right, 2=left, 3=hazard */
-               static const Property ClutchStatus; /**< Clutch pedal status 0=off, 1=on */
-               static const Property EngineOilPressure; /**< Oil pressure TODO: units */
-               static const Property EngineCoolantTemperature; /**< Engine coolant temperature in degrees celcius **/
-               static const Property MachineGunTurretStatus; /**< 0=off, 1=on */
-               static const Property AccelerationX; /**< Acceleration on the 'x' axis in 1/1000 gravitational acceleration "g-force" */
-               static const Property AccelerationY; /**< Acceleration on the 'y' axis in 1/1000 gravitational acceleration "g-force" */
-               static const Property AccelerationZ; /**< Acceleration on the 'z' axis in 1/1000 gravitational acceleration "g-force" */
-       //};
-
-       static std::string name(Property prop);
-       static Property value(std::string name);
+
+       /**< Vehicle Velocity in km/h */
+       static const Property VehicleSpeed;
+
+       /**< Engine Speed in rotations per minute */
+       static const Property EngineSpeed;
+
+        /**< Transmission Shift Position
+        * 0 = Neutral
+        * 1 = 1st
+        * 2 = 2nd
+        * ...
+        * 64 = Drive
+        * 128 = Reverse
+        * 255 = Park
+        */
+       static const Property TransmissionShiftPosition;
+
+       /**< Throttle position 0-100% */
+       static const Property ThrottlePosition;
+
+       /**< Wheel brake position.  Engaged = true, Idle = false */
+       static const Property WheelBrake;
+
+       /**< Steering wheel angle (0-359) */
+       static const Property SteeringWheelAngle;
+
+       /**< 0=off, 1=right, 2=left, 3=hazard */
+       static const Property TurnSignal;
+
+       /**< Clutch pedal status 0=off, 1=on */
+       static const Property ClutchStatus;
+
+        /**< Oil pressure TODO: units */
+       static const Property EngineOilPressure;
+
+       /**< Engine coolant temperature in degrees celcius **/
+       static const Property EngineCoolantTemperature;
+
+       /**< 0=off, 1=on */
+       static const Property MachineGunTurretStatus;
+
+       /**< Acceleration on the 'x' axis in 1/1000 gravitational acceleration "g-force" */
+       static const Property AccelerationX;
+
+       /**< Acceleration on the 'y' axis in 1/1000 gravitational acceleration "g-force" */
+       static const Property AccelerationY;
+
+       /**< Acceleration on the 'z' axis in 1/1000 gravitational acceleration "g-force" */
+       static const Property AccelerationZ;
     
 };
 
index e72ba5d..f152e0d 100644 (file)
@@ -51,7 +51,7 @@ void ExampleSink::supportedChanged(PropertyList supportedProperties)
 
 void ExampleSink::propertyChanged(VehicleProperty::Property property, boost::any value, std::string uuid)
 {
-       DebugOut()<<VehicleProperty::name(property)<<" value: "<<boost::any_cast<uint16_t>(value)<<endl;
+       DebugOut()<<property<<" value: "<<boost::any_cast<uint16_t>(value)<<endl;
 }
 
 std::string ExampleSink::uuid()