OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
ossia::time_sync Class Referencefinal

time_sync is use to describe temporal structure to synchronize each attached time_event evaluation. More...

Detailed Description

time_sync is use to describe temporal structure to synchronize each attached time_event evaluation.

time_sync is also a time_event container.

Todo
the shared_from_this is used at a single point, maybe it should be removed ? or replaced with intrusive_ptr ?

Public Types

enum class  status : uint8_t { NOT_DONE , DONE_TRIGGERED , DONE_MAX_REACHED }
using container = ossia::small_vector<std::shared_ptr<time_event>, 2>
using iterator = container::iterator
using const_iterator = container::const_iterator

Public Member Functions

time_value get_date () const noexcept
 get the date
const expression & get_expression () const noexcept
 get the expression of the time_sync
time_sync & set_expression (expression_ptr) noexcept
 set the expression of the time_sync
iterator emplace (const_iterator, time_event::exec_callback, expression_ptr=expressions::make_expression_true())
 create and store a time_event
iterator insert (const_iterator, std::shared_ptr< time_event >)
void remove (const std::shared_ptr< time_event > &)
auto & get_time_events () noexcept
 get the #time_events of the time_sync
const auto & get_time_events () const noexcept
 get the #time_events of the time_sync
bool is_observing_expression () const noexcept
bool is_evaluating () const noexcept
void start_trigger_request () noexcept
 evaluate all time_event's to make them to happen or to dispose them
void end_trigger_request () noexcept
bool is_autotrigger () const noexcept
void set_autotrigger (bool) noexcept
bool is_start () const noexcept
void set_start (bool) noexcept
void observe_expression (bool)
 enable observation of the ossia::expression
void observe_expression (bool b, auto &&cb)
void observe_expression_impl (bool, ossia::expressions::expression_result_callback cb)
void reset ()
 Resets the internal state. Necessary when restarting an execution.
void cleanup ()
void mute (bool b)
bool muted () const noexcept
status get_status () const noexcept
void set_sync_rate (double syncRatio) noexcept
double get_sync_rate () const noexcept
bool has_sync_rate () const noexcept
void set_trigger_date (time_value v) noexcept
time_value get_trigger_date () const noexcept
bool has_trigger_date () const noexcept
void set_is_being_triggered (bool v) noexcept
bool is_being_triggered () const noexcept

Public Attributes

time_sync_callbacks callbacks
 Execution callbacks.

Member Function Documentation

◆ get_date()

time_value ossia::time_sync::get_date ( ) const
nodiscardnoexcept

get the date

the date is the sum of its previous time_interval durations

a time_sync with na previous #time_intervals have a date equals to 0.

Returns
#TimeValue the date

◆ set_expression()

time_sync & ossia::time_sync::set_expression ( expression_ptr exp)
noexcept

set the expression of the time_sync

setting the expression to ExpressionTrue will defer the evaluation on time_event's expression

setting the expression to ExpressionFalse will mute TimeSync execution

Parameters
expression_ptr
Returns
time_sync the time_sync

◆ emplace()

time_sync::iterator ossia::time_sync::emplace ( const_iterator pos,
time_event::exec_callback callback,
ossia::expression_ptr exp = expressions::make_expression_true() )

create and store a time_event

Parameters
Container<#time_event>::const_iteratorwhere to store the time_event
time_event::ExecutionCallbackto get time_event's status back
expression_ptran std::optional expression to apply to the time_event
Returns
std::shared_ptr<time_event>

◆ get_time_events() [1/2]

auto & ossia::time_sync::get_time_events ( )
inlinenoexcept

get the #time_events of the time_sync

Returns
#Container<time_event>

◆ get_time_events() [2/2]

const auto & ossia::time_sync::get_time_events ( ) const
inlinenodiscardnoexcept

get the #time_events of the time_sync

Returns
#Container<time_event>

◆ start_trigger_request()

void ossia::time_sync::start_trigger_request ( )
noexcept

evaluate all time_event's to make them to happen or to dispose them

Returns
boolean true if the operation succeeded

◆ is_autotrigger()

bool ossia::time_sync::is_autotrigger ( ) const
nodiscardnoexcept

Auto-trigger timesyncs are timesyncs which will directly restart their following graph upon triggering. Else, triggering the timesync will stop the following subgraph. This is only relevant for subgraphs not connected to the root of a ossia::scenario

Member Data Documentation

◆ callbacks

time_sync_callbacks ossia::time_sync::callbacks

Execution callbacks.

Used to be notified when the time_sync is triggered.