/***************************************************************************
 * tabsongsubject.h
 *
 * 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 "tabsongsubject.h"
#include "util/assert.h"

#include "tabsongobserver.h"

TabSongSubject::TabSongSubject()
: mObserver()
{
}

TabSongSubject::~TabSongSubject()
{
}

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

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

void TabSongSubject::notifySongUpdated()
{
	for (iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->songUpdated();
}

void TabSongSubject::notifyTrackAdded(TabTrack* track)
{
	for (iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->trackAdded(track);
}

void TabSongSubject::notifyTrackDeleted(TabTrack* track)
{
	for (iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->trackDeleted(track);
}

void TabSongSubject::notifyPropertyChanged()
{
	for (iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->propertyChanged();
}

void TabSongSubject::notifyKeyChanged()
{
	for (iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->keyChanged();
}

void TabSongSubject::notifyLyricsChanged()
{
	for (iterator it = mObserver.begin(); it != mObserver.end(); ++it)
		(*it)->lyricsChanged();
}
