aboutsummaryrefslogtreecommitdiff
path: root/composer/Song.cpp
blob: c79350436c982777c87083a986177e15edc181a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "Song.hpp"

#include <iostream>

using std::cout;
using std::cerr;
using std::endl;

map<string,Song *> Song::byname;

Song::Song(string songName)
: name(songName)
{
}

Song *Song::byName(string songName)
{
	if(byname.find(songName) == byname.end())
		byname[songName] = new Song(songName);

	return byname[songName];
}

void Song::print()
{
	cerr << "---- Song: " << name << " ----" << endl;

	for(map<string,Track *>::iterator i = tracks.begin(); i != tracks.end(); i++)
	{
		cerr << "  Track[" << i->first << "]: " << i->first << endl;
	}

	cerr << "---- End song (" << name << ") ----" << endl;
}

Track *Song::getTrackByName(string trackName)
{
	if(tracks.find(trackName) == tracks.end())
		return 0;
	else
		return tracks[trackName];
}