CMetaInterval
-
class CMetaInterval
Bases:
CInterval
This interval contains a list of nested intervals, each of which has its own begin and end times. Some of them may overlap and some of them may not.
Inheritance diagram
-
enum DefType
-
enumerator DT_c_interval = 0
-
enumerator DT_ext_index = 1
-
enumerator DT_push_level = 2
-
enumerator DT_pop_level = 3
-
enumerator DT_c_interval = 0
-
enum RelativeStart
-
enumerator RS_previous_end = 0
-
enumerator RS_previous_begin = 1
-
enumerator RS_level_begin = 2
-
enumerator RS_previous_end = 0
-
explicit CMetaInterval(std::string const &name)
-
CMetaInterval(CMetaInterval const&) = default
-
int add_c_interval(CInterval *c_interval, double rel_time = 0.0, RelativeStart rel_to = RS_previous_end)
Adds a new
CInterval
to the list. The interval will be played when the indicated time (relative to the given point) has been reached.The return value is the index of the def entry representing the new interval.
-
int add_ext_index(int ext_index, std::string const &name, double duration, bool open_ended, double rel_time, RelativeStart rel_to)
Adds a new external interval to the list. This represents some object in the external scripting language that has properties similar to a
CInterval
(for instance, a Python Interval object).The
CMetaInterval
object cannot play this external interval directly, but it records a placeholder for it and will ask the scripting language to play it when it is time, viais_event_ready()
and related methods.The ext_index number itself is simply a handle that the scripting language makes up and associates with its interval object somehow. The
CMetaInterval
object does not attempt to interpret this value.The return value is the index of the def entry representing the new interval.
-
void clear_intervals(void)
Resets the list of intervals and prepares for receiving a new list.
-
CInterval *get_c_interval(int n) const
Return the
CInterval
pointer associated with the nth interval definition. It is only valid to call this if get_def_type(n) returns DT_c_interval.
-
static TypeHandle get_class_type(void)
-
DefType get_def_type(int n) const
Returns the type of the nth interval definition that has been added.
-
int get_event_index(void) const
If a previous call to
is_event_ready()
returned true, this returns the index number (added via add_event_index()) of the external interval that needs to be played.
-
double get_event_t(void) const
If a previous call to
is_event_ready()
returned true, this returns the t value that should be fed to the given interval.
-
CInterval::EventType get_event_type(void) const
If a previous call to
is_event_ready()
returned true, this returns the type of the event (initialize, step, finalize, etc.) for the given interval.
-
int get_ext_index(int n) const
Return the external interval index number associated with the nth interval definition. It is only valid to call this if get_def_type(n) returns DT_ext_index.
-
double get_interval_end_time(std::string const &name) const
Returns the actual end time, relative to the beginning of the interval, of the child interval with the given name, if found, or -1 if the interval is not found.
-
double get_interval_start_time(std::string const &name) const
Returns the actual start time, relative to the beginning of the interval, of the child interval with the given name, if found, or -1 if the interval is not found.
-
int get_num_defs(void) const
Returns the number of interval and push/pop definitions that have been added to the meta interval.
-
double get_precision(void) const
Returns the precision with which time measurements are compared. See
set_precision()
.
-
bool is_event_ready(void)
Returns true if a recent call to
priv_initialize()
,priv_step()
, orpriv_finalize()
has left some external intervals ready to play. If this returns true, callget_event_index()
,get_event_t()
, andpop_event()
to retrieve the relevant information.
-
void pop_event(void)
Acknowledges that the external interval on the top of the queue has been extracted, and is about to be serviced by the scripting language. This prepares the interval so the next call to
is_event_ready()
will return information about the next external interval on the queue, if any.
-
int pop_level(double duration = -1.0)
Finishes a level marked by a previous call to
push_level()
, and returns to the previous level.If the duration is not negative, it represents a phony duration to assign to the level, for the purposes of sequencing later intervals. Otherwise, the level’s duration is computed based on the intervals within the level.
-
int push_level(std::string const &name, double rel_time, RelativeStart rel_to)
Marks the beginning of a nested level of child intervals. Within the nested level, a
RelativeStart
time of RS_level_begin refers to the start of the level, and the first interval added within the level is always relative to the start of the level.The return value is the index of the def entry created by this push.
-
bool set_interval_start_time(std::string const &name, double rel_time, RelativeStart rel_to = RS_level_begin)
Adjusts the start time of the child interval with the given name, if found. This may be either a C++ interval added via
add_c_interval()
, or an external interval added viaadd_ext_index()
; the name must match exactly.If the interval is found, its start time is adjusted, and all subsequent intervals are adjusting accordingly, and true is returned. If a matching interval is not found, nothing is changed and false is returned.
-
void set_precision(double precision)
Indicates the precision with which time measurements are compared. For numerical accuracy, all floating-point time values are converted to integer values internally by scaling by the precision factor. The larger the number given here, the smaller the delta of time that can be differentiated; the limit is the maximum integer that can be represented in the system.
-
void timeline(std::ostream &out) const
Outputs a list of all events in the order in which they occur.
-
enum DefType