-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMediator.cpp
113 lines (88 loc) · 2.78 KB
/
Mediator.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "../Headers.h"
#pragma hdrstop
#include "Mediator.h"
#include "../Player/PlayerFacade.h"
#include "../ImportExport/ImportExportFacade.h"
#include "../ImportExport/TagImpEx.h"
#include "../Playlist/PlaylistFacade.h"
#include "../Song/SongFacade.h"
#include "../Song/SongProperty.h"
#include "../Database/DatabaseEngine.h"
#include "../Exceptions.h"
#include "../Constants.h"
using namespace std;
Mediator::Mediator()
{
m_pImportexportfacade = 0;
m_pPlayerfacade = 0;
m_pPlaylistfacade = 0;
m_pSongfacade = 0;
m_pDatabaseengine = 0;
}
void Mediator::playSongs(vector<string> a_songfilenames) const
{
if(m_pPlayerfacade == 0)
throw Exception("Mediator::playSongs");
m_pPlayerfacade->playMultiple(a_songfilenames);
}
void Mediator::getSongProperties(int a_song, SongProperty *a_property) const
{
if(m_pSongfacade == 0)
throw Exception("Mediator::getSongProperties");
m_pSongfacade->getSongProperties(a_song, a_property);
}
intvector Mediator::getSongsMatchingProperties(const SongProperty &a_properties) const
{
if(m_pSongfacade == 0)
throw Exception("Mediator::getSongProperties");
return m_pSongfacade->getSongsMatchingProperties(a_properties);
}
void Mediator::removeSongFromPlaylists(int a_song) const
{
// if(m_pPlaylistfacade == 0)
// throw Exception("Mediator::removeSongFromPlaylists");
//
// m_pPlaylistfacade->removeSongFromAllPlaylists(a_song);
}
AnsiString Mediator::getPlayedFilename() const
{
if(m_pPlayerfacade == 0)
throw Exception("Mediator::getPlayedFilename");
return m_pPlayerfacade->getPlayedFile();
}
void Mediator::saveAndStop() const
{
if(m_pPlayerfacade == 0)
throw Exception("Mediator::saveAndStop");
m_pPlayerfacade->saveAndStop();
}
void Mediator::resumePlay() const
{
if(m_pPlayerfacade == 0)
throw Exception("Mediator::resumePlay");
m_pPlayerfacade->resumePlay();
}
const TagImpEx *Mediator::createTagImpEx(AnsiString a_tagtype) const
{
if(m_pImportexportfacade == 0)
throw Exception("Mediator::createTagImpEx");
return m_pImportexportfacade->createTagImpEx(a_tagtype);
}
vector<SongProperty> Mediator::getSongsFromDatabase() const
{
if(m_pDatabaseengine == 0)
throw Exception("Mediator::getSongsFromDatabase");
return m_pDatabaseengine->getSongs();
}
void Mediator::updateSongDatabase(int a_song, const SongProperty &a_properties) const
{
if(m_pDatabaseengine == 0)
throw Exception("Mediator::updateSongDatabase");
m_pDatabaseengine->updateSong(a_song, a_properties);
}
void Mediator::updateSongDatabase(vector<SongProperty> a_songs) const
{
if(m_pDatabaseengine == 0)
throw Exception("Mediator::updateSongDatabase");
m_pDatabaseengine->updateSongs(a_songs);
}