Antkeeper  0.0.1
Public Types | Public Member Functions | List of all members
timeline Class Reference

Timeline which executes cues (scheduled functions) when advanced over their respective positions in time. More...

#include <timeline.hpp>

Public Types

typedef std::tuple< float, std::function< void()> > cue
 Scheduled function consisting of a time and function object. More...
 
typedef std::list< cuesequence
 List of cues. More...
 

Public Member Functions

 timeline ()
 Creates a timeline. More...
 
void advance (float dt)
 Advances the timeline position (t) by dt, triggering any cues scheduled between t and dt. More...
 
void seek (float t)
 Sets the timeline position to t. More...
 
void add_cue (const cue &c)
 Adds a cue to the timeline. More...
 
void remove_cue (const cue &c)
 Removes a cue from the timeline. More...
 
void remove_cues (float start, float end)
 Removes all cues on [start, end). More...
 
void add_sequence (const sequence &s)
 Adds a sequence of cues to the timeline. More...
 
void remove_sequence (const sequence &s)
 Removes a sequence of cues from the timeline. More...
 
void clear ()
 Removes all cues from the timeline. More...
 
void set_autoremove (bool enabled)
 If enabled, cues will be automatically removed from the timeline when they are triggered. More...
 
float get_position () const
 Returns the current position in time on the timeline. More...
 
sequence get_cues (float start, float end) const
 Returns all the cues on [start, end). More...
 

Detailed Description

Timeline which executes cues (scheduled functions) when advanced over their respective positions in time.

Definition at line 30 of file timeline.hpp.

Member Typedef Documentation

◆ cue

typedef std::tuple<float, std::function<void()> > timeline::cue

Scheduled function consisting of a time and function object.

Definition at line 34 of file timeline.hpp.

◆ sequence

typedef std::list<cue> timeline::sequence

List of cues.

Definition at line 37 of file timeline.hpp.

Constructor & Destructor Documentation

◆ timeline()

timeline::timeline ( )

Creates a timeline.

Definition at line 27 of file timeline.cpp.

Member Function Documentation

◆ add_cue()

void timeline::add_cue ( const cue c)

Adds a cue to the timeline.

Parameters
cCue to add.

Definition at line 56 of file timeline.cpp.

◆ add_sequence()

void timeline::add_sequence ( const sequence s)

Adds a sequence of cues to the timeline.

Parameters
sSequence of cues to add.

Definition at line 73 of file timeline.cpp.

◆ advance()

void timeline::advance ( float  dt)

Advances the timeline position (t) by dt, triggering any cues scheduled between t and dt.

If autoremove is enabled, triggered cues will be removed.

Parameters
dtDelta time by which the timeline position will be advanced.

Definition at line 33 of file timeline.cpp.

◆ clear()

void timeline::clear ( )

Removes all cues from the timeline.

Definition at line 89 of file timeline.cpp.

◆ get_cues()

timeline::sequence timeline::get_cues ( float  start,
float  end 
) const

Returns all the cues on [start, end).

Parameters
startStarting position in time (inclusive).
endEnding position in time (non-inclusive).
Returns
All cues on [start, end).

Definition at line 99 of file timeline.cpp.

◆ get_position()

float timeline::get_position ( ) const
inline

Returns the current position in time on the timeline.

Definition at line 126 of file timeline.hpp.

◆ remove_cue()

void timeline::remove_cue ( const cue c)

Removes a cue from the timeline.

If there are multiple identical cues (same time and function), they will all be removed.

Parameters
cCue to remove.

Definition at line 61 of file timeline.cpp.

◆ remove_cues()

void timeline::remove_cues ( float  start,
float  end 
)

Removes all cues on [start, end).

Parameters
startStarting position in time (inclusive).
endEnding position in time (non-inclusive).

Definition at line 66 of file timeline.cpp.

◆ remove_sequence()

void timeline::remove_sequence ( const sequence s)

Removes a sequence of cues from the timeline.

Parameters
sSequence of cues to remove.

Definition at line 81 of file timeline.cpp.

◆ seek()

void timeline::seek ( float  t)

Sets the timeline position to t.

Parameters
tPosition in time to which the timeline position will be set.

Definition at line 51 of file timeline.cpp.

◆ set_autoremove()

void timeline::set_autoremove ( bool  enabled)

If enabled, cues will be automatically removed from the timeline when they are triggered.

Parameters
enabledWhether to enable autoremove.

Definition at line 94 of file timeline.cpp.


The documentation for this class was generated from the following files: