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.)
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1084 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
16
ChangeLog
16
ChangeLog
@@ -1,3 +1,19 @@
|
||||
2008-06-06 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* 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 <drfaygo/at/gmail/dot/com>
|
||||
|
||||
* include/knob.h:
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -257,7 +257,7 @@ private:
|
||||
|
||||
|
||||
class instrumentTrackWindow : public QWidget, public modelView,
|
||||
public journallingObjectHook
|
||||
public serializingObjectHook
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
@@ -26,29 +26,18 @@
|
||||
#ifndef _JOURNALLING_OBJECT_H
|
||||
#define _JOURNALLING_OBJECT_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
#include "export.h"
|
||||
#include "serializing_object.h"
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QStack>
|
||||
|
||||
|
||||
class QDomDocument;
|
||||
class QDomElement;
|
||||
|
||||
|
||||
typedef uint32_t t_action_id;
|
||||
|
||||
|
||||
class journallingObject;
|
||||
class journallingObjectHook;
|
||||
|
||||
|
||||
class journalEntry
|
||||
{
|
||||
public:
|
||||
@@ -99,7 +88,7 @@ private:
|
||||
typedef QVector<journalEntry> 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<bool> 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;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#define _SAMPLE_BUFFER_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QRect>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
|
||||
107
include/serializing_object.h
Normal file
107
include/serializing_object.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* serializing_object.h - declaration of class serializingObject
|
||||
*
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* 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 <QtCore/QString>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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() )
|
||||
|
||||
@@ -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<Actions>( _je.actionID() ) )
|
||||
@@ -232,7 +232,7 @@ void note::redoStep( journalEntry & _je )
|
||||
{
|
||||
journalEntry je( _je.actionID(), -_je.data().toInt() );
|
||||
undoStep( je );
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
78
src/core/serializing_object.cpp
Normal file
78
src/core/serializing_object.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* serializing_object.cpp - implementation of serializingObject
|
||||
*
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* 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 <Qt/QtXml>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
@@ -396,7 +396,6 @@ void automationEditor::setCurrentPattern( automationPattern * _new_pattern )
|
||||
m_step = m_pattern->object()->step<float>();
|
||||
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 );
|
||||
|
||||
Reference in New Issue
Block a user