Still experimenting with unit testing code.
[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 version 2 as published by
9 // the Free Software Foundation and appearing in the file gpl.txt included in the
10 // packaging of this file.
11 //
12 // EmuFront 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 EmuFront.  If not, see <http://www.gnu.org/licenses/>.
19
20 #include <QDebug>
21 #include "setup.h"
22 #include "platform.h"
23 #include "mediatype.h"
24
25 Setup::Setup() : EmuFrontObject(), platform(0), mediaType(0)
26 {
27 }
28
29 Setup::Setup(int id, Platform *plf, MediaType *mt, QStringList fileTypeExtensions)
30     : EmuFrontObject(id,
31         QString("%1%2")
32             .arg(plf ? plf->getName() : "")
33             .arg(mt ? mt->getName() : "")), platform(plf), mediaType(mt),
34             fileTypeExtensions(fileTypeExtensions){
35
36 }
37
38 Setup::~Setup()
39 {
40     delete platform;
41     delete mediaType;
42 }
43
44 Setup::Setup(const Setup &s)
45         : EmuFrontObject(s),
46             fileTypeExtensions(s.fileTypeExtensions)
47 {
48     Platform *p = s.platform;
49     MediaType *m = s.mediaType;
50     platform = new Platform(*p);
51     mediaType = new MediaType(*m);
52 }
53
54 Setup& Setup::operator =(const Setup &sup)
55 {
56     if (this == &sup) return *this;
57     id = sup.id;
58     name = sup.name;
59     if (platform) delete platform;
60     Platform *p = sup.platform;
61     MediaType *m = sup.mediaType;
62     platform = new Platform(*p);
63     if (mediaType) delete mediaType;
64     mediaType = new MediaType(*m);
65     return (*this);
66 }
67
68 // TODO:
69 /*bool Setup::operator ==(const Setup &sup)
70 {
71
72     // TODO: more precise ... this is exact copy from EmuFrontObject
73     return (id >= 0 && id == sup.id);
74
75 }
76
77 bool Setup::operator !=(const Setup &sup)
78 {
79     // TODO: more precise ... this is exact copy from EmuFrontObject
80     return !(*this == sup);
81 }*/
82
83 Platform* Setup::getPlatform() const
84 { return platform; }
85 void Setup::setPlatform(Platform *plf)
86 { platform = plf; }
87
88 MediaType* Setup::getMediaType() const
89 { return mediaType; }
90 void Setup::setMediaType(MediaType *mt)
91 { mediaType = mt; }
92
93 QStringList Setup::getSupportedFileTypeExtensions() const
94 { return fileTypeExtensions; }
95 void Setup::setSupportedFileTypeExtensions(QStringList ftx)
96 { fileTypeExtensions = ftx; }