| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #ifndef DETERMINISTIC_QUEUE | |||
| 2 | #define DETERMINISTIC_QUEUE | |||
| 3 | ||||
| 4 | #include "types.hpp" | |||
| 5 | #include "parameters.hpp" | |||
| 6 | ||||
| 7 | ✗ | class DeterministicQueue | ||
| 8 | //'Smart' queue object that contains logic to transform to and from the system | |||
| 9 | // time. | |||
| 10 | { | |||
| 11 | ||||
| 12 | public: | |||
| 13 | ||||
| 14 | System* const system; // pointer to containing system | |||
| 15 | DeterministicQueue(System*, double (System::*dt_func)(double), double (System::*td_func)(double)); | |||
| 16 | ||||
| 17 | double current_pos() | |||
| 18 | { | |||
| 19 | ✗ | return current_base; // returns the current 'distance' | ||
| 20 | } | |||
| 21 | ||||
| 22 | void advance_time(double); // advances the parameters to the current system time | |||
| 23 | void store_time(int); // store 'currentBase' in the cache at a given tag position | |||
| 24 | ||||
| 25 | ✗ | double progression(int cache_pos) { return current_base - value_cache[cache_pos]; } | ||
| 26 | ||||
| 27 | // returns the progress of 'currentBase' relative to a given time tag | |||
| 28 | double first_event_time(); // returns the system time of the first scheduled | |||
| 29 | // event | |||
| 30 | DeterministicEvent pop(); // returns and removes the first scheduled event | |||
| 31 | ||||
| 32 | bool empty() | |||
| 33 | { | |||
| 34 | return queue.empty(); // checks whether the queue is empty | |||
| 35 | } | |||
| 36 | ||||
| 37 | void flush(); // empties the queue and resets currentBase | |||
| 38 | void push_global(double, GlobalEventType); // pushes a global event onto the | |||
| 39 | // queue at a certain distance | |||
| 40 | EventTrackingTag push_deterministic(double, EventDescriptorIndex); | |||
| 41 | // pushes a deterministic (MT) event onto the queue at a certain distance | |||
| 42 | ||||
| 43 | private: | |||
| 44 | ||||
| 45 | friend class System; | |||
| 46 | std::priority_queue<DeterministicEvent> queue; // the queue itself | |||
| 47 | double current_base; // the current 'distance' | |||
| 48 | double value_cache[POSITION_CACHE_SIZE]; // cache of previous 'distance' values | |||
| 49 | double (System::* const distance_time_conversion_function)(double); | |||
| 50 | // pointer to a function that converts a distance to a time | |||
| 51 | double (System::* const time_distance_conversion_function)(double); | |||
| 52 | // pointer to a function that converts a time to a distance | |||
| 53 | }; | |||
| 54 | ||||
| 55 | #endif // DETERMINISTIC_QUEUE | |||
| 56 |