diff --git a/ChangeLog b/ChangeLog index 703e882af..30abe3c85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2008-06-06 Tobias Doerffel + + * include/note.h: + * include/serializing_object.h: + * include/instrument_track.h: + * include/sample_buffer.h: + * include/journalling_object.h: + * src/gui/automation_editor.cpp: + * src/core/serializing_object.cpp: + * src/core/journalling_object.cpp: + * src/core/note.cpp: + * Makefile.am: + splitted basic functionality of journallingObject into + serializingObject so that creating note objects, notePlayHandles etc. + does not have all the journalling-overhead (assigning/freeing ID etc.) + 2008-06-06 Paul Giblock * include/knob.h: diff --git a/Makefile.am b/Makefile.am index 8e4b782b7..e6ddf9c8b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -240,6 +240,7 @@ lmms_SOURCES = \ $(srcdir)/src/core/project_version.cpp \ $(srcdir)/src/core/sample_buffer.cpp \ $(srcdir)/src/core/sample_play_handle.cpp \ + $(srcdir)/src/core/serializing_object.cpp \ $(srcdir)/src/core/song.cpp \ $(srcdir)/src/core/surround_area.cpp \ $(srcdir)/src/core/timeline.cpp \ @@ -464,6 +465,7 @@ lmms_SOURCES = \ $(srcdir)/include/rubberband.h \ $(srcdir)/include/base64.h \ $(srcdir)/include/journalling_object.h \ + $(srcdir)/include/serializing_object.h \ $(srcdir)/include/level_object.h \ $(srcdir)/include/project_journal.h \ $(srcdir)/include/shared_object.h \ diff --git a/include/instrument_track.h b/include/instrument_track.h index c76ce8aa2..391804477 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -257,7 +257,7 @@ private: class instrumentTrackWindow : public QWidget, public modelView, - public journallingObjectHook + public serializingObjectHook { Q_OBJECT public: diff --git a/include/journalling_object.h b/include/journalling_object.h index d3cbc4585..c726243f6 100644 --- a/include/journalling_object.h +++ b/include/journalling_object.h @@ -26,29 +26,18 @@ #ifndef _JOURNALLING_OBJECT_H #define _JOURNALLING_OBJECT_H -#ifdef HAVE_CONFIG_H -#include -#endif - #include "types.h" #include "export.h" +#include "serializing_object.h" #include #include #include -class QDomDocument; -class QDomElement; - - typedef uint32_t t_action_id; -class journallingObject; -class journallingObjectHook; - - class journalEntry { public: @@ -99,7 +88,7 @@ private: typedef QVector journalEntryVector; -class EXPORT journallingObject +class EXPORT journallingObject : public serializingObject { public: journallingObject( void ); @@ -144,9 +133,6 @@ public: virtual void restoreState( const QDomElement & _this ); - // to be implemented by actual object - virtual QString nodeName( void ) const = 0; - inline bool isJournalling( void ) const { return( m_journalling ); @@ -164,26 +150,11 @@ public: return( old_journalling ); } - void setHook( journallingObjectHook * _hook ); - - journallingObjectHook * getHook( void ) - { - return( m_hook ); - } - protected: void addJournalEntry( const journalEntry & _je ); // to be implemented by sub-objects - virtual void saveSettings( QDomDocument & _doc, QDomElement & _this ) - { - } - - virtual void loadSettings( const QDomElement & _this ) - { - } - virtual void undoStep( journalEntry & _je ) { } @@ -206,34 +177,6 @@ private: QStack m_journallingStateStack; - journallingObjectHook * m_hook; - -} ; - - -class journallingObjectHook -{ -public: - journallingObjectHook() : - m_hookedIn( NULL ) - { - } - virtual ~journallingObjectHook() - { - if( m_hookedIn != NULL ) - { - m_hookedIn->setHook( NULL ); - } - } - - virtual void saveSettings( QDomDocument & _doc, QDomElement & _this ) = 0; - virtual void loadSettings( const QDomElement & _this ) = 0; - -private: - journallingObject * m_hookedIn; - - friend class journallingObject; - } ; diff --git a/include/note.h b/include/note.h index e157eb81e..18bac6fe9 100644 --- a/include/note.h +++ b/include/note.h @@ -36,7 +36,7 @@ #include "volume.h" #include "panning.h" #include "midi_time.h" -#include "journalling_object.h" +#include "serializing_object.h" class detuningHelper; @@ -83,7 +83,7 @@ const float MaxDetuning = 4 * 12.0f; -class EXPORT note : public journallingObject +class EXPORT note : public serializingObject { public: note( const midiTime & _length = 0, @@ -165,19 +165,19 @@ protected: QDomElement & _parent ); virtual void loadSettings( const QDomElement & _this ); - virtual void undoStep( journalEntry & _je ); - virtual void redoStep( journalEntry & _je ); +/* virtual void undoStep( journalEntry & _je ); + virtual void redoStep( journalEntry & _je );*/ private: - enum Actions +/* enum Actions { ChangeKey, ChangeVolume, ChangePanning, ChangeLength, ChangePosition - } ; + } ;*/ int m_key; diff --git a/include/sample_buffer.h b/include/sample_buffer.h index a265a8f04..386087c87 100644 --- a/include/sample_buffer.h +++ b/include/sample_buffer.h @@ -27,6 +27,7 @@ #define _SAMPLE_BUFFER_H #include +#include #ifdef HAVE_CONFIG_H #include diff --git a/include/serializing_object.h b/include/serializing_object.h new file mode 100644 index 000000000..eaa28c9d1 --- /dev/null +++ b/include/serializing_object.h @@ -0,0 +1,107 @@ +/* + * serializing_object.h - declaration of class serializingObject + * + * Copyright (c) 2008 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + + +#ifndef _SERIALIZING_OBJECT_H +#define _SERIALIZING_OBJECT_H + +#include + +#include "export.h" + + +class QDomDocument; +class QDomElement; + +class serializingObjectHook; + + +class EXPORT serializingObject +{ +public: + serializingObject( void ); + virtual ~serializingObject(); + + virtual QDomElement saveState( QDomDocument & _doc, + QDomElement & _parent ); + + virtual void restoreState( const QDomElement & _this ); + + + // to be implemented by actual object + virtual QString nodeName( void ) const = 0; + + void setHook( serializingObjectHook * _hook ); + + serializingObjectHook * getHook( void ) + { + return( m_hook ); + } + + +protected: + // to be implemented by sub-objects + virtual void saveSettings( QDomDocument & _doc, QDomElement & _this ) + { + } + + virtual void loadSettings( const QDomElement & _this ) + { + } + + +private: + serializingObjectHook * m_hook; + +} ; + + +class serializingObjectHook +{ +public: + serializingObjectHook() : + m_hookedIn( NULL ) + { + } + virtual ~serializingObjectHook() + { + if( m_hookedIn != NULL ) + { + m_hookedIn->setHook( NULL ); + } + } + + virtual void saveSettings( QDomDocument & _doc, QDomElement & _this ) = 0; + virtual void loadSettings( const QDomElement & _this ) = 0; + +private: + serializingObject * m_hookedIn; + + friend class serializingObject; + +} ; + + +#endif + diff --git a/src/core/journalling_object.cpp b/src/core/journalling_object.cpp index 5a23bd47c..6772ebd87 100644 --- a/src/core/journalling_object.cpp +++ b/src/core/journalling_object.cpp @@ -39,8 +39,7 @@ journallingObject::journallingObject( void ) : m_journalEntries(), m_currentJournalEntry( m_journalEntries.end() ), m_journalling( TRUE ), - m_journallingStateStack(), - m_hook( NULL ) + m_journallingStateStack() { } @@ -49,10 +48,6 @@ journallingObject::journallingObject( void ) : journallingObject::~journallingObject() { - if( m_hook ) - { - m_hook->m_hookedIn = NULL; - } if( engine::getProjectJournal() ) { engine::getProjectJournal()->freeID( id() ); @@ -97,9 +92,7 @@ void journallingObject::redo( void ) QDomElement journallingObject::saveState( QDomDocument & _doc, QDomElement & _parent ) { - QDomElement _this = _doc.createElement( nodeName() ); - _parent.appendChild( _this ); - saveSettings( _doc, _this ); + QDomElement _this = serializingObject::saveState( _doc, _parent ); saveJournal( _doc, _this ); return( _this ); } @@ -109,10 +102,9 @@ QDomElement journallingObject::saveState( QDomDocument & _doc, void journallingObject::restoreState( const QDomElement & _this ) { - saveJournallingState( FALSE ); + serializingObject::restoreState( _this ); - // load actual settings - loadSettings( _this ); + saveJournallingState( FALSE ); // search for journal-node QDomNode node = _this.firstChild(); @@ -131,15 +123,6 @@ void journallingObject::restoreState( const QDomElement & _this ) -void journallingObject::setHook( journallingObjectHook * _hook ) -{ - m_hook = _hook; - m_hook->m_hookedIn = this; -} - - - - void journallingObject::addJournalEntry( const journalEntry & _je ) { if( engine::getProjectJournal()->isJournalling() && isJournalling() ) diff --git a/src/core/note.cpp b/src/core/note.cpp index 605997e7f..48223304b 100644 --- a/src/core/note.cpp +++ b/src/core/note.cpp @@ -47,7 +47,7 @@ note::note( const midiTime & _length, const midiTime & _pos, m_pos( _pos ) { //saveJournallingState( FALSE ); - setJournalling( FALSE ); +// setJournalling( FALSE ); if( _detuning ) { @@ -64,7 +64,7 @@ note::note( const midiTime & _length, const midiTime & _pos, note::note( const note & _note ) : - journallingObject( _note ), + serializingObject( _note ), m_key( _note.m_key), m_volume( _note.m_volume ), m_panning( _note.m_panning ), @@ -87,7 +87,7 @@ note::~note() void note::setLength( const midiTime & _length ) { - addJournalEntry( journalEntry( ChangeLength, m_length - _length ) ); +// addJournalEntry( journalEntry( ChangeLength, m_length - _length ) ); m_length = _length; } @@ -96,7 +96,7 @@ void note::setLength( const midiTime & _length ) void note::setPos( const midiTime & _pos ) { - addJournalEntry( journalEntry( ChangePosition, m_pos - _pos ) ); +// addJournalEntry( journalEntry( ChangePosition, m_pos - _pos ) ); m_pos = _pos; } @@ -106,7 +106,7 @@ void note::setPos( const midiTime & _pos ) void note::setKey( const int _key ) { const int k = tLimit( _key, 0, NumKeys ); - addJournalEntry( journalEntry( ChangeKey, m_key - k ) ); +// addJournalEntry( journalEntry( ChangeKey, m_key - k ) ); m_key = k; } @@ -116,7 +116,7 @@ void note::setKey( const int _key ) void note::setVolume( const volume _volume ) { const volume v = tLimit( _volume, MinVolume, MaxVolume ); - addJournalEntry( journalEntry( ChangeVolume, (int) m_volume - v ) ); +// addJournalEntry( journalEntry( ChangeVolume, (int) m_volume - v ) ); m_volume = v; } @@ -126,7 +126,7 @@ void note::setVolume( const volume _volume ) void note::setPanning( const panning _panning ) { const panning p = tLimit( _panning, PanningLeft, PanningRight ); - addJournalEntry( journalEntry( ChangePanning, (int) m_panning - p ) ); +// addJournalEntry( journalEntry( ChangePanning, (int) m_panning - p ) ); m_panning = p; } @@ -197,7 +197,7 @@ void note::loadSettings( const QDomElement & _this ) -void note::undoStep( journalEntry & _je ) +/*void note::undoStep( journalEntry & _je ) { saveJournallingState( FALSE ); switch( static_cast( _je.actionID() ) ) @@ -232,7 +232,7 @@ void note::redoStep( journalEntry & _je ) { journalEntry je( _je.actionID(), -_je.data().toInt() ); undoStep( je ); -} +}*/ diff --git a/src/core/serializing_object.cpp b/src/core/serializing_object.cpp new file mode 100644 index 000000000..fa8e5bdb6 --- /dev/null +++ b/src/core/serializing_object.cpp @@ -0,0 +1,78 @@ +/* + * serializing_object.cpp - implementation of serializingObject + * + * Copyright (c) 2008 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + + +#include + +#include "serializing_object.h" + + + +serializingObject::serializingObject( void ) : + m_hook( NULL ) +{ +} + + + + +serializingObject::~serializingObject() +{ + if( m_hook ) + { + m_hook->m_hookedIn = NULL; + } +} + + + + +QDomElement serializingObject::saveState( QDomDocument & _doc, + QDomElement & _parent ) +{ + QDomElement _this = _doc.createElement( nodeName() ); + _parent.appendChild( _this ); + saveSettings( _doc, _this ); + return( _this ); +} + + + + +void serializingObject::restoreState( const QDomElement & _this ) +{ + // load actual settings + loadSettings( _this ); +} + + + + +void serializingObject::setHook( serializingObjectHook * _hook ) +{ + m_hook = _hook; + m_hook->m_hookedIn = this; +} + + diff --git a/src/gui/automation_editor.cpp b/src/gui/automation_editor.cpp index 1aa924396..161935618 100644 --- a/src/gui/automation_editor.cpp +++ b/src/gui/automation_editor.cpp @@ -396,7 +396,6 @@ void automationEditor::setCurrentPattern( automationPattern * _new_pattern ) m_step = m_pattern->object()->step(); m_scrollLevel = ( m_minLevel + m_maxLevel ) / 2; - timeMap & time_map = m_pattern->getTimeMap(); // resizeEvent() does the rest for us (scrolling, range-checking // of levels and so on...) resizeEvent( NULL );