/***************************************************************************
 * tabtracksubject.h: implementation of TabTrack class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2007- the KTabEdit development team <mrgwen@gmail.com>
 ***************************************************************************/

/***************************************************************************
 * 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.
 *
 * See the file COPYING for more information.
 ***************************************************************************/

#include "tabtracksubject.h"
#include "util/assert.h"

#include <QtDebug>

#include "tabtrackobserver.h"

TabTrackSubject::TabTrackSubject()
: mObserver()
{
}

TabTrackSubject::~TabTrackSubject()
{
}

void TabTrackSubject::attach(TabTrackObserver* o)
{
	PRECONDITION( o != 0x0 );
	
	mObserver.push_back(o);
}

void TabTrackSubject::detach(TabTrackObserver* o)
{
	PRECONDITION( o != 0x0 );
	
	mObserver.removeAll(o);
}

void TabTrackSubject::notifyNoteEffectChanged(int bar, int time, int chord)
{
	for(iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->noteEffectChanged(bar, time, chord);
}

void TabTrackSubject::notifyNoteChanged(int bar, int time, int note)
{
	for(iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->noteChanged(bar, time, note);
}

void TabTrackSubject::notifyTimeChordChanged(int bar, int time)
{
	for(iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->timeChordChanged(bar, time);
}

void TabTrackSubject::notifyTimeEffectChanged(int bar, int time)
{
	for(iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->timeEffectChanged(bar, time);
}

void TabTrackSubject::notifyTimeChanged(int bar, int time)
{
	for(iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->timeChanged(bar, time);
}

void TabTrackSubject::notifyBarPropertyChanged(int bar)
{
	for(iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->barPropertyChanged(bar);
}

void TabTrackSubject::notifyBarMixChanged(int bar)
{
	for(iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->barMixChanged(bar);
}

void TabTrackSubject::notifyBarChanged(int bar)
{
	for(iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->barChanged(bar);
}

void TabTrackSubject::notifyTrackPropertyChanged()
{
	for(iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->trackPropertyChanged();
}

void TabTrackSubject::notifyTrackChanged()
{
	for(iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->trackChanged();
}
