Updates to data object model (not to actual data object classes yet)
[emufront] / src / dataobjects / setup.cpp
1 // EmuFront
2 // Copyright 2010 Mikko Keinänen
3 //
4 // This file is part of EmuFront.
5 //
6 //
7 // EmuFront is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Foobar is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
19
20 #include "setup.h"
21 #include "platform.h"
22 #include "mediatype.h"
23
24 Setup::Setup() : EmuFrontObject(), platform(0), mediaType(0)
25 {
26 }
27
28 Setup::Setup(int id, Platform *plf, MediaType *mt, QStringList fileTypeExtensions)
29     : EmuFrontObject(id,
30         QString("%1%2")
31             .arg(plf ? plf->getName() : "")
32             .arg(mt ? mt->getName() : "")), platform(plf), mediaType(mt),
33             fileTypeExtensions(fileTypeExtensions){
34
35 }
36
37 Setup::~Setup()
38 {
39     delete platform;
40     delete mediaType;
41 }
42
43 Setup::Setup(const Setup &s)
44         : EmuFrontObject(s.getId(), s.getName()),
45             fileTypeExtensions(s.fileTypeExtensions)
46 {
47     Platform *p = s.platform;
48     MediaType *m = s.mediaType;
49     platform = new Platform(*p);
50     mediaType = new MediaType(*m);
51 }
52
53 Setup& Setup::operator =(const Setup &sup)
54 {
55     if (this == &sup) return *this;
56     id = sup.id;
57     name = sup.name;
58     if (platform) delete platform;
59     Platform *p = sup.platform;
60     MediaType *m = sup.mediaType;
61     platform = new Platform(*p);
62     if (mediaType) delete mediaType;
63     mediaType = new MediaType(*m);
64     return (*this);
65 }
66
67 Platform* Setup::getPlatform() const
68 { return platform; }
69 void Setup::setPlatform(Platform *plf)
70 { platform = plf; }
71
72 MediaType* Setup::getMediaType() const
73 { return mediaType; }
74 void Setup::setMediaType(MediaType *mt)
75 { mediaType = mt; }
76
77 QStringList Setup::getSupportedFileTypeExtensions() const
78 { return fileTypeExtensions; }
79 void Setup::setSupportedFileTypeExtensions(QStringList ftx)
80 { fileTypeExtensions = ftx; }