2
* Copyright (C) 2013 Canonical, Ltd.
5
* Jussi Pakkanen <jussi.pakkanen@canonical.com>
7
* This library is free software; you can redistribute it and/or modify it under
8
* the terms of version 3 of the GNU General Public License as published
9
* by the Free Software Foundation.
11
* This library is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
#include"MediaFileBuilder.hh"
21
#include"MediaFile.hh"
24
MediaFileBuilder::MediaFileBuilder(const std::string &fname) {
28
MediaFileBuilder::MediaFileBuilder(const MediaFile &mf) :
30
filename(mf.getFileName()),
31
content_type(mf.getContentType()),
35
author(mf.getAuthor()),
37
album_artist(mf.getAlbumArtist()),
38
track_number(mf.getTrackNumber()),
39
duration(mf.getDuration()) {
42
MediaFile MediaFileBuilder::build() const {
43
return MediaFile(filename, content_type, etag, title, date, author,
44
album, album_artist, track_number, duration, type);
47
void MediaFileBuilder::setType(MediaType t) {
49
throw std::invalid_argument("Tried to set type when it was already set.");
54
void MediaFileBuilder::setETag(const std::string &e) {
56
throw std::invalid_argument("Tried to set filename when it was already set.");
61
void MediaFileBuilder::setContentType(const std::string &c) {
63
throw std::invalid_argument("Tried to set filename when it was already set.");
65
content_type_set = true;
69
void MediaFileBuilder::setTitle(const std::string &t) {
71
throw std::invalid_argument("Tried to set title when it was already set.");
76
void MediaFileBuilder::setDate(const std::string &d) {
78
throw std::invalid_argument("Tried to set date when it was already set.");
83
void MediaFileBuilder::setAuthor(const std::string &a) {
85
throw std::invalid_argument("Tried to set author when it was already set.");
90
void MediaFileBuilder::setAlbum(const std::string &a) {
92
throw std::invalid_argument("Tried to set album when it was already set.");
97
void MediaFileBuilder::setAlbumArtist(const std::string &a) {
99
throw std::invalid_argument("Tried to set album artist when it was already set.");
101
album_artist_set = true;
104
void MediaFileBuilder::setTrackNumber(int n) {
106
throw std::invalid_argument("Tried to set track number when it was already set.");
108
track_number_set = true;
111
void MediaFileBuilder::setDuration(int n) {
113
throw std::invalid_argument("Tried to set duration when it was already set.");