[update] Added SortParametersBlock function.
This commit is contained in:
parent
ea55a66247
commit
9d55655c92
@ -2,7 +2,9 @@
|
||||
module sjplayer.AbstractScheduledController;
|
||||
|
||||
import std.algorithm,
|
||||
std.array,
|
||||
std.exception,
|
||||
std.range.primitives,
|
||||
std.typecons;
|
||||
|
||||
import sjscript;
|
||||
@ -103,3 +105,16 @@ abstract class AbstractScheduledController : ScheduledControllerInterface {
|
||||
|
||||
float[string] user_vars_;
|
||||
}
|
||||
|
||||
///
|
||||
ParametersBlock[] SortParametersBlock(R)(R params)
|
||||
if (isInputRange!R && is(ElementType!R == ParametersBlock)) {
|
||||
auto result = params.array;
|
||||
result.sort!"a.period.start < b.period.start";
|
||||
|
||||
auto before = Period(-1, 0);
|
||||
foreach (param; result) {
|
||||
(!param.period.IsPeriodIntersectedToPeriod(before)).enforce();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ import std.algorithm,
|
||||
|
||||
import sjscript;
|
||||
|
||||
import sjplayer.Background,
|
||||
import sjplayer.AbstractScheduledController,
|
||||
sjplayer.Background,
|
||||
sjplayer.ContextBuilderInterface,
|
||||
sjplayer.ScheduledController,
|
||||
sjplayer.VarStoreInterface,
|
||||
@ -45,16 +46,8 @@ struct BackgroundScheduledControllerFactory {
|
||||
///
|
||||
void Create(R)(R params, ContextBuilderInterface builder)
|
||||
if (isInputRange!R && is(ElementType!R == ParametersBlock)) {
|
||||
auto params_array = params.array;
|
||||
params_array.sort!"a.period.start < b.period.start";
|
||||
|
||||
auto before = Period(-1, 0);
|
||||
foreach (param; params_array) {
|
||||
(!param.period.IsPeriodIntersectedToPeriod(before)).enforce();
|
||||
}
|
||||
|
||||
auto ctrl = new BackgroundScheduledController(
|
||||
background_, varstore_, params_array);
|
||||
background_, varstore_, SortParametersBlock(params));
|
||||
builder.AddScheduledController(ctrl);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user