Added new data object class FilePathObject and updated
[emufront] / src / dataobjects / filepathobject.cpp
1 #include "filepathobject.h"
2
3 FilePathObject::FilePathObject()
4 {
5 }
6
7 FilePathObject::FilePathObject(int id, QString name, QString filename, int filetype)
8     : EmuFrontFileObject(id, name, filename, filetype), platform(0), mediaType(0)
9  {}
10
11  FilePathObject::FilePathObject(int id, QString name, QString filename,
12      int filetype, Platform *plf, MediaType *med)
13     : EmuFrontFileObject(id, name, filename, filetype), platform(plf), mediaType(med)
14  {}
15
16 FilePathObject::~FilePathObject()
17 {
18     if (platform) delete platform;
19     if (mediaType) delete mediaType;
20 }
21
22 FilePathObject::FilePathObject(const FilePathObject &fpobj)
23     : EmuFrontFileObject(fpobj.id, fpobj.name, fpobj.filename, fpobj.filetype)
24 {
25     // Note: no need to deep copy members of type QString
26     // QString uses Implicit Data Sharing (http://doc.trolltech.com/4.0/shclass.html)
27     Platform *p = fpobj.platform;
28     platform = new Platform(p->getId(), p->getName(), p->getFilename());
29     MediaType *mt = fpobj.mediaType;
30     mediaType = new MediaType(mt->getId(), mt->getName(), mt->getFilename());
31 }
32
33 FilePathObject& FilePathObject::operator =(const FilePathObject &fpobj)
34 {
35     if (this == &fpobj) return *this;
36     id = fpobj.id;
37     name = fpobj.name;
38     filename = fpobj.filename;
39     filetype = fpobj.filetype;
40     if (platform) delete platform;
41     Platform *p = fpobj.platform;
42     platform = new Platform(p->getId(), p->getName(), p->getFilename());
43     if (mediaType) delete mediaType;
44     MediaType *mt = fpobj.mediaType;
45     mediaType = new MediaType(mt->getId(), mt->getName(), mt->getFilename());
46     return (*this);
47 }