Template Class EntityWatchdog
Defined in File EntityWatchdog.h
Inheritance Relationships
Base Types
public axr::sdk::utils::IEntityWatchdog
(Class IEntityWatchdog)public std::enable_shared_from_this< EntityWatchdog< T > >
Template Parameter Order
class T
Class Documentation
-
template<class T>
class EntityWatchdog : public axr::sdk::utils::IEntityWatchdog, public std::enable_shared_from_this<EntityWatchdog<T>> EntityWatchdog
is a utility service that provides a simple way to retrieve automatic updates for a registeredEntityBase
object. When registering a callback function for a given entity object the service will begin monitoring the backend service for changes to the object. If a change has been detected the callback function that was registered will be called containing the newly modified entity object. Note that it will not modify the existing object instance used to register the callback. It is the responsibility of the implementor to merge any changes from the new instance to the old one if desired.Also note that the registered callback function will be executed from a different thread where safety is not guaranteed. It is the responsibility of the implementor to enforce any thread-safety needed for the data in question.
WARNING: This class should never be instantiated directly. Use the
EntityWatchdogFactory
class instead. If creating an instance manually, never do so using the local stack or via thenew
operator without assigning to a std::shared_ptr.- Author
Jean-Philippe Steinmetz info@acceleratxr.com
Public Types
Public Functions
-
inline virtual ~EntityWatchdog()
Sets the currently active push notification websocket connection.
-
inline virtual bool NotifyEntityUpdate(Object &message) override
Notifies the watchdog that an entity has been updated.
- Parameters
message – The message object containing the entity update.
- Returns
Returns true if the entity update was handled by this watchdog instance, otherwise returns false.
-
inline virtual void Shutdown() override
Stops watching all entity objects and cleans up the service.
-
inline void Start()
Starts the process.
Registers the provided callback function to be notified whenever changes occur for the specified search query. Note that the callback function will be notified from a different thread of execution. It is recommended that thread-safe handling of the provided data is implemented in the callback function itself.
- Parameters
searchParams – A map of property names to values to search for.
startIndex – The index of the first object to include in the result.
maxResults – The maximum number of objects to evaluate during the search.
sortBy – The property name and order direction to sort the results using. (e.g. “MyProperty=ASC” to sort by MyProperty in ascending order, “MyProperty=DESC” to sort by MyProperty in descending order).
callback – The function call call when an update to the entity object is detected.
- Returns
An identifier for the registered callback. Use this to unregister the callback to stop watching the object.
Registers the provided callback function to be notified whenever an update is detected for the specified entity object. Note that the callback function will be notified from a different thread of execution. It is recommended that thread-safe handling of the provided data is implemented in the callback function itself.
- Parameters
entity – The pointer to the entity object to watch.
callback – The function call call when an update to the entity object is detected. If
nullptr
is passed in as the argument then the object was deleted on the back-end.
- Throws
Throws – if the entity does not exist or have a valid
remoteUrl
.- Returns
An identifier for the registered callback. Use this to unregister the callback to stop watching the object.
Removes the registered callback with the given
id
for the specified entity object.- Parameters
entity – The entity object to stop watching.
id – The id of the callback function to unregister (e.g. the value that was returned from
RegisterCallback
).