Best practices on how to implement signal/slot
I have an application that needs to detect when a entity enters in a defined field, you can almost think of it as a collection detection.
I have the application setup in the following way:
There is a set of movable entities (class MovableEntity) that is constantly updated over the network
There is a set of defined areas (class Geofence) that defines an area that we want to detect if a MovableEntity goes within its defined field;
There is also a class that is has a list of Geofences associated with the (class Intersection) that needs to be notified when their associated Geofences have a MovableEntity in it
There is a class (class TrackingHandler) that evaluates all MovableEntities to every Geofence to determine if there is a MoveableEntity within a Geofence.
Geofences and Intersections are read from a database therefore intersections associate the geofences to themselves at startup time and do not update throughout run time.
I am interested on how to best setup this the signals and slots to notify the intersection class from the a moveableentity has entered the geofence.
I think there are a few solutions:
- Each intersection has it own TrackingHandler that holds all moveable entities and all geofences associated with that intersection and will signal directly to the intersection
- This situation would require to go through ever intersection class and process the TrackingHandler every whenever the moveable entities area updated (or periodically), I would prefer to do it on all geofences at once
The core app will contain the a TrackingHandler which will have all moveable entities and all geofences and will emit a signal to the core app who will then notify the corresponding intersection that a collision has happened. However, I currently have that the intersections know which geofence they are associated with, however, the geofences do not know anything about the intersections. So I would have to query each intersection to find if it contains that geofence and then have them handle it, which seems inefficient.
I could make some TrackableGeofence class which inherits the Geofence class but also contains a signal that could be emitted if there is a collision, then I could have each intersection connect to the TrackableGeofence and then run it similar to #2, but the signal would be emitted to the intersection class instead of the core app
Any suggestions on how to best implement this scenario, it can be solved many ways but i'm interested in best practices and "good" ways to solve it.
Thanks for any suggestions