![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Singleton async pathfinding request manager. More...
#include <PathfindingManager.h>
Classes | |
| struct | RequestEntry |
Public Types | |
| using | RequestID = uint64_t |
| Unique identifier for a pathfinding request. | |
Public Member Functions | |
| RequestID | Request (const ::Vector &start, const ::Vector &target, float delaySeconds=0.0f) |
| Submits an async pathfinding request. | |
| bool | IsComplete (RequestID id) |
Returns true if the request identified by id has completed. | |
| std::string | GetPathString (RequestID id) |
Returns the path string computed for id. | |
| void | Cancel (RequestID id) |
| Cancels a pending request and removes its entry. | |
Static Public Member Functions | |
| static PathfindingManager & | Get () |
| Returns the singleton PathfindingManager instance. | |
Static Public Attributes | |
| static constexpr RequestID | INVALID_REQUEST_ID = 0u |
| Sentinel value for an invalid / unsubmitted request. | |
Private Member Functions | |
| PathfindingManager () | |
| ~PathfindingManager ()=default | |
| PathfindingManager (const PathfindingManager &)=delete | |
| PathfindingManager & | operator= (const PathfindingManager &)=delete |
Private Attributes | |
| std::mutex | m_mutex |
| std::unordered_map< RequestID, RequestEntry > | m_requests |
| std::atomic< uint64_t > | m_nextID |
Singleton async pathfinding request manager.
Requests are identified by a uint64 RequestID. Each request spawns a detached thread that computes a straight-line path string and marks the entry as completed. Callers poll IsComplete() and retrieve the result via GetPathString(), then call Cancel() to release the entry.
Definition at line 51 of file PathfindingManager.h.
Unique identifier for a pathfinding request.
Definition at line 55 of file PathfindingManager.h.
|
private |
Definition at line 35 of file PathfindingManager.cpp.
References m_nextID.
|
privatedefault |
|
privatedelete |
Cancels a pending request and removes its entry.
If the request is still in-flight the worker thread will see the cancelled flag and skip writing the result. The entry is removed from the map immediately so subsequent calls to IsComplete()/GetPathString() return the default empty/false values.
Safe to call on an already-completed request (releases the entry).
| id | RequestID returned by Request(). |
Definition at line 141 of file PathfindingManager.cpp.
References GetComponentTypeID_Static(), m_mutex, m_requests, and SYSTEM_LOG.
Referenced by Olympe::Task_RequestPathfinding::Abort(), and Olympe::Task_RequestPathfinding::ExecuteWithContext().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Returns the singleton PathfindingManager instance.
Definition at line 29 of file PathfindingManager.cpp.
Referenced by Olympe::Task_RequestPathfinding::Abort(), and Olympe::Task_RequestPathfinding::ExecuteWithContext().
Here is the caller graph for this function:| std::string Olympe::PathfindingManager::GetPathString | ( | RequestID | id | ) |
Returns the path string computed for id.
Returns an empty string if the request is not complete or unknown.
| id | RequestID returned by Request(). |
Definition at line 126 of file PathfindingManager.cpp.
References GetComponentTypeID_Static(), m_mutex, and m_requests.
Referenced by Olympe::Task_RequestPathfinding::ExecuteWithContext().
Here is the call graph for this function:
Here is the caller graph for this function:Returns true if the request identified by id has completed.
Returns false for unknown or cancelled requests.
| id | RequestID returned by Request(). |
Definition at line 111 of file PathfindingManager.cpp.
References GetComponentTypeID_Static(), m_mutex, and m_requests.
Here is the call graph for this function:
|
privatedelete |
| PathfindingManager::RequestID Olympe::PathfindingManager::Request | ( | const ::Vector & | start, |
| const ::Vector & | target, | ||
| float | delaySeconds = 0.0f |
||
| ) |
Submits an async pathfinding request.
Launches a detached thread that sleeps for delaySeconds (simulating pathfinding work) and then writes a straight-line path string into the result entry unless the request has been cancelled.
| start | Start position. |
| target | Target position. |
| delaySeconds | Simulated computation delay in seconds (0.0 = instant). |
Definition at line 45 of file PathfindingManager.cpp.
References GetComponentTypeID_Static(), m_mutex, m_nextID, m_requests, Olympe::PathfindingManager::RequestEntry::start, SYSTEM_LOG, and Vector::x.
Referenced by Olympe::Task_RequestPathfinding::ExecuteWithContext().
Here is the call graph for this function:
Here is the caller graph for this function:Sentinel value for an invalid / unsubmitted request.
Definition at line 58 of file PathfindingManager.h.
Referenced by Olympe::Task_RequestPathfinding::Abort(), and Olympe::Task_RequestPathfinding::ExecuteWithContext().
|
private |
Definition at line 139 of file PathfindingManager.h.
Referenced by Cancel(), GetPathString(), IsComplete(), and Request().
|
private |
Definition at line 141 of file PathfindingManager.h.
Referenced by PathfindingManager(), and Request().
|
private |
Definition at line 140 of file PathfindingManager.h.
Referenced by Cancel(), GetPathString(), IsComplete(), and Request().