#include "externals.hh" #include "syncedit.hh" #include "globals.hh" /*= T_UndoSyncChanges ==========================================================*/ void T_UndoSyncChanges::undo( ) const noexcept { auto& sync{ Globals::Sync( ) }; const auto n{ changes_.size( ) }; for ( auto i = 0u ; i < n ; i ++ ) { auto const& c( changes_[ i ] ); if ( c.before ) { sync.setCurve( *c.before ); } else { sync.removeCurve( c.inputId ); } } } void T_UndoSyncChanges::redo( ) const noexcept { auto& sync{ Globals::Sync( ) }; const auto n{ changes_.size( ) }; for ( auto i = 0u ; i < n ; i ++ ) { auto const& c( changes_[ i ] ); if ( c.after ) { sync.setCurve( *c.after ); } else { sync.removeCurve( c.inputId ); } } } /*------------------------------------------------------------------------------*/ T_UndoSyncChanges& T_UndoSyncChanges::curveCreation( T_SyncCurve curve ) noexcept { #ifndef NDEBUG { const auto n{ changes_.size( ) }; for ( auto i = 0u ; i < n ; i ++ ) { assert( changes_[ i ].inputId != curve.name ); } } #endif changes_.addNew( true , std::move( curve ) ); return *this; } T_UndoSyncChanges& T_UndoSyncChanges::curveDeletion( T_SyncCurve curve ) noexcept { #ifndef NDEBUG { const auto n{ changes_.size( ) }; for ( auto i = 0u ; i < n ; i ++ ) { assert( changes_[ i ].inputId != curve.name ); } } #endif changes_.addNew( std::move( curve ) ); return *this; } T_UndoSyncChanges& T_UndoSyncChanges::curveReplacement( T_SyncCurve before , T_SyncCurve after ) noexcept { assert( before.name == after.name ); #ifndef NDEBUG { const auto n{ changes_.size( ) }; for ( auto i = 0u ; i < n ; i ++ ) { assert( changes_[ i ].inputId != before.name ); } } #endif changes_.addNew( std::move( before ) , std::move( after ) ); return *this; }