Merge pull request #67 from tripzero/trip
[profile/ivi/automotive-message-broker.git] / lib / abstractroutingengine.h
index 7afae61..90c3810 100644 (file)
@@ -112,8 +112,8 @@ public:
 };
 
 /*!
- * \brief The AsyncPropertyReply class is used by sources to reply to Get and Set operations.  The source should
- * set success to true if the call is successful or 'false' if the request was not successful and set 'error'
+ * \brief The AsyncPropertyReply class is used by sources to reply to Get and Set operations.
+ * The source should set success to true if the call is successful or 'false' if the request was not successful and set 'error'
  * to the appropriate error.
  * \see AbstractRoutingEngine::getPropertyAsync
  * \see AsyncPropertyReply
@@ -143,6 +143,46 @@ public:
        };
 
        /*!
+        * \brief errorToStr returns string representing the Error
+        */
+       static std::string errorToStr(Error err)
+       {
+               if(err == NoError)
+                       return "NoError";
+               else if(err == Timeout)
+                       return "Timeout";
+               else if(err == InvalidOperation)
+                       return "InvalidOperation";
+               else if(err == PermissionDenied)
+                       return "PermissionDenied";
+               else if(err == ZoneNotSupported)
+                       return "ZoneNotSupported";
+
+               DebugOut(DebugOut::Warning) << "Could not translate error: " << err << endl;
+               return "";
+       }
+
+       /*!
+        * \brief strToError returns Error representing the string
+        */
+       static Error strToError(std::string err)
+       {
+               if(err == "NoError")
+                       return NoError;
+               else if(err == "Timeout")
+                       return Timeout;
+               else if(err == "InvalidOperation")
+                       return InvalidOperation;
+               else if(err == "PermissionDenied")
+                       return PermissionDenied;
+               else if(err == "ZoneNotSupported")
+                       return ZoneNotSupported;
+
+               DebugOut(DebugOut::Warning) << "Could not translate error string: " << err << endl;
+               return NoError;
+       }
+
+       /*!
         * \brief value of the reply.  This may be null if success = false.  This is owned by the source.
         */
        AbstractPropertyType* value;
@@ -245,19 +285,22 @@ public:
        Zone::Type zone;
 
        /*!
-        * \brief completed callback that is called when the ranged request is complete. The reply from this request is passed
+        * \brief completed callback
+        * 'completed' is called when the ranged request is complete. The reply from this request is passed
         * into the completed call.  The completed callback must free the reply before it returns or there will be a leak.
         */
        GetRangedPropertyCompletedSignal completed;
 
        /*!
-        * \brief timeBegin set this to request values for the specified property beggining at this time.  Time is seconds\
+        * \brief timeBegin
+        * Set this to request values for the specified property beggining at this time.  Time is seconds\
         * since the unix epoc.  Set this to '0' if you do not want values within a time range.
         */
        double timeBegin;
 
        /*!
-        * \brief timeEnd set this to request values for the specified property beggining at this time.  Time is seconds\
+        * \brief timeEnd
+        * Set this to request values for the specified property beggining at this time.  Time is seconds\
         * since the unix epoc.  Set this to '0' if you do not want values within a time range.
         */
        double timeEnd;
@@ -282,7 +325,7 @@ public:
 
 /*!
  * \brief The AsyncRangePropertyReply class is used by a source to reply to an AsyncRangePropertyRequest.
- * the source should set success to 'true' and populate the 'values' member if the request was successful.
+ * The source should set success to 'true' and populate the 'values' member if the request was successful.
  * If the request is not successful, 'success' should be set to 'false' and the 'error' member should be set.
  */
 class AsyncRangePropertyReply: public AsyncRangePropertyRequest
@@ -332,11 +375,10 @@ public:
        virtual void updateSupported(PropertyList added, PropertyList removed, AbstractSource* source) = 0;
 
 
-       /// Deprecated:
+       ///TODO: Deprecated, remove in 0.15:
        void updateProperty(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid)
        {
-               DebugOut(DebugOut::Warning)<<"updateProperty(VehicleProperty::Property,AbstractPropertyType*,std::string) is deprecated.  use new updateProperty(AbstractPropertyType*, const std::string &)"<<endl;
-               updateProperty(value,uuid);
+               throw std::runtime_error("updateProperty(VehicleProperty::Property,AbstractPropertyType*,std::string) is deprecated.  use new updateProperty(AbstractPropertyType*, const std::string &)");
        }
 
        virtual void updateProperty(AbstractPropertyType* value, const std::string &uuid) = 0;
@@ -347,9 +389,9 @@ public:
        virtual void  unregisterSink(AbstractSink* self) = 0;
 
        /**
-        * /brief sourcesForProperty
-        * /param property
-        * /return vector of source uuid's that support the "property"
+        * \brief sourcesForProperty
+        * \param property
+        * \return vector of source uuid's that support the "property"
         */
        virtual std::vector<std::string> sourcesForProperty(const VehicleProperty::Property & property) = 0;
 
@@ -359,7 +401,7 @@ public:
         * /see AsyncPropertyReply.
         * /param request requested property.
         * /return AsyncPropertyReply. The returned AsyncPropertyReply is owned by the caller of getPropertyAsync.
-        * /example AsyncPropertyRequest request;
+        * /code AsyncPropertyRequest request;
         * request.property = VehicleProperty::VehicleSpeed
         * request.completed = [](AsyncPropertyReply* reply)
         * {
@@ -367,14 +409,15 @@ public:
         *   delete reply;
         * };
         * routingEngine->getPropertyAsync(request);
+        * /endcode
         */
        virtual AsyncPropertyReply * getPropertyAsync(AsyncPropertyRequest request) = 0;
 
        /*!
         * \brief getRangePropertyAsync is used for getting a range of properties that are within the specified time or sequence parameters.
-        * \param request the request containing the property and other information required by the query
+        * \arg request the request containing the property and other information required by the query
         * \return a pointer to the reply.
-        * \example AsyncRangePropertyRequest vehicleSpeedFromLastWeek;
+        * \code AsyncRangePropertyRequest vehicleSpeedFromLastWeek;
         *
         *      vehicleSpeedFromLastWeek.timeBegin = amb::currentTime() - 10;
         *      vehicleSpeedFromLastWeek.timeEnd = amb::currentTime();
@@ -397,15 +440,15 @@ public:
         *      };
         *
         *      routingEngine->getRangePropertyAsync(vehicleSpeedFromLastWeek);
-        *
+        * \endcode
         */
-       virtual AsyncRangePropertyReply * getRangePropertyAsync(AsyncRangePropertyRequest request) = 0;
+       virtual void getRangePropertyAsync(AsyncRangePropertyRequest request) = 0;
 
        /*!
         * \brief setProperty sets a property to a value.
         * \see AsyncSetPropertyRequest
         * \see AsyncPropertyReply
-        * \param request the request containing the property and the value to set
+        * \arg request the request containing the property and the value to set
         * \return a pointer to the reply which is owned by the caller of this method
         * \example
         */
@@ -413,24 +456,31 @@ public:
 
        /*!
         * \brief subscribeToProperty subscribes to propertyName.  Value changes will be passed to callback.
-        * \param propertyName
-        * \param callback
-        * \param pid process id of the requesting application
+        * \code
+        * subscribeToProperty(Vehicle::EngineSpeed, [](AbstractPropertyType* property) {
+        *   ...
+        * }, this);
+        * \endcode
+        * \arg propertyName
+        * \arg callback
+        * \arg pid process id of the requesting application
         * \return subscription handle
         */
        virtual uint subscribeToProperty(const VehicleProperty::Property & propertyName, PropertyChangedType callback, std::string pid="") = 0;
 
        /*!
         * \brief unsubscribeToProperty
-        * \param handle
+        * \arg handle
         */
        virtual void unsubscribeToProperty(uint handle) = 0;
 
        /*!
         * \brief subscribeToProperty subscribe to changes made to a property value.
-        * \param propertyName name of the property to request a subscription for.
-        * \param self pointer to the sink who is subscribing.
-        * \example
+        * By default, all providers of this property will receive the subscription.  If you need to filter by source, use
+        * \ref subscribeToProperty(const VehicleProperty::Property & propertyName, const std::string & sourceUuidFilter, AbstractSink *self)
+        * \arg propertyName name of the property to request a subscription for.
+        * \arg self pointer to the sink who is subscribing.
+        * \code
         * //somewhere in the sink:
         * routingEngine->subscribeToProperty(VehicleProperty::EngineSpeed, this);
         *
@@ -442,23 +492,24 @@ public:
         *      ...
         *   }
         * }
+        * \endcode
         */
        virtual bool subscribeToProperty(const VehicleProperty::Property & propertyName, AbstractSink* self) = 0;
 
        /*!
         * \brief subscribeToProperty subscribe to changes made to a property value.
-        * \param propertyName name of the property to request a subscription for.
-        * \param sourceUuidFilter source UUID to filter.  Only property updates from this source will be sent to the sink.
-        * \param self pointer to the sink who is subscribing.
+        * \arg propertyName name of the property to request a subscription for.
+        * \arg sourceUuidFilter source UUID to filter.  Only property updates from this source will be sent to the sink.
+        * \arg self pointer to the sink who is subscribing.
         */
        virtual bool subscribeToProperty(const VehicleProperty::Property & propertyName, const std::string & sourceUuidFilter, AbstractSink *self) = 0;
 
        /*!
         * \brief subscribeToProperty subscribe to changes made to a property value.
-        * \param propertyName name of the property to request a subscription for.
-        * \param sourceUuidFilter source UUID to filter.  Only property updates from this source will be sent to the sink.
-        * \param zoneFilter zone to filter.  Only updates from this zone will be passed to the sink.
-        * \param self pointer to the sink who is subscribing.
+        * \arg propertyName name of the property to request a subscription for.
+        * \arg sourceUuidFilter source UUID to filter.  Only property updates from this source will be sent to the sink.
+        * \arg zoneFilter zone to filter.  Only updates from this zone will be passed to the sink.
+        * \arg self pointer to the sink who is subscribing.
         */
        virtual bool subscribeToProperty(const VehicleProperty::Property & propertyName, const std::string & sourceUuidFilter, Zone::Type zoneFilter, AbstractSink *self) = 0;