-UndoAction
-TempoMap::get_memento () const
-{
- return sigc::bind (mem_fun (*(const_cast<TempoMap *> (this)), &StateManager::use_state), _current_state_id);
-}
-
-Change
-TempoMap::restore_state (StateManager::State& state)
-{
- Glib::Mutex::Lock lm (lock);
-
- TempoMapState* tmstate = dynamic_cast<TempoMapState*> (&state);
-
- /* We can't just set the metrics pointer to the address of the metrics list
- stored in the state, cause this would ruin this state for restoring in
- the future. If they have the same address, they are the same list.
- Thus we need to copy all the elements from the state metrics list to the
- current metrics list.
- */
- metrics->clear();
- for (Metrics::iterator i = tmstate->metrics->begin(); i != tmstate->metrics->end(); ++i) {
- TempoSection *ts;
- MeterSection *ms;
-
- if ((ts = dynamic_cast<TempoSection*>(*i)) != 0) {
- metrics->push_back (new TempoSection (*ts));
- } else if ((ms = dynamic_cast<MeterSection*>(*i)) != 0) {
- metrics->push_back (new MeterSection (*ms));
- }
- }
-
- last_bbt_valid = false;
-
- return Change (0);
-}
-
-StateManager::State*
-TempoMap::state_factory (std::string why) const
-{
- TempoMapState* state = new TempoMapState (why);
-
- for (Metrics::iterator i = metrics->begin(); i != metrics->end(); ++i) {
- TempoSection *ts;
- MeterSection *ms;
-
- if ((ts = dynamic_cast<TempoSection*>(*i)) != 0) {
- state->metrics->push_back (new TempoSection (*ts));
- } else if ((ms = dynamic_cast<MeterSection*>(*i)) != 0) {
- state->metrics->push_back (new MeterSection (*ms));
- }
- }
-
- return state;
-}
-
-void
-TempoMap::save_state (std::string why)
-{
- if (!in_set_state) {
- StateManager::save_state (why);
- }
-}