[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IMP-dev] Ordering among score_states (and other things)



I am ending up with various score states which have to be updated in the right order. Currently this requires that the user add them to the model in the right order and non-obvious things happen if this is not the case. I think adding an iteration counter to the update call would make this simpler (and the change could be implemented without changing individual score states much).

Model maintains a counter which is incremented each time evaluate is called. It then calls ScoreState::update(int) for each score state passing the counter. This update is a method in the ScoreState base class which simply compares the passed counter to the stored counter and calls the existing update method if the counters are different. ScoreStates which depend on other score states can simply call update on their dependencies with the counter. Each ScoreState is updated exactly once and, unless there are circular dependencies, everything is updated before it is used. The same thing can be used for after_evaluate, although there is currently no need. With slightly more logic we could catch circular dependencies too.

Comments?