Implementing class Executable based on EmuFrontObject (changes also on
authorMikko Keinänen <mikko.keinanen@gmail.com>
Mon, 4 Oct 2010 18:30:12 +0000 (21:30 +0300)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Mon, 4 Oct 2010 18:30:12 +0000 (21:30 +0300)
executable db table).

doc/er.dia
doc/uml-data_objects.dia
src/dataobjects/executable.cpp
src/dataobjects/executable.h
src/db/dbcreator.cpp

index 88b667c..2df0a3b 100644 (file)
Binary files a/doc/er.dia and b/doc/er.dia differ
index 869fd38..4e6b50a 100644 (file)
Binary files a/doc/uml-data_objects.dia and b/doc/uml-data_objects.dia differ
index ce157c7..4b45a26 100644 (file)
@@ -10,7 +10,7 @@
 // (at your option) any later version.
 //
 // EmuFront is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// but WITHOUT ANY WARRANTY{} without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
 //
 // along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "executable.h"
+#include "setup.h"
 
-Executable::Executable()
+Executable::Executable() : EmuFrontObject() { }
+
+Executable::Executable(int id, QString name)
+    : EmuFrontObject(id, name) {}
+
+Executable::Executable(int id, QString name, QString executable,
+    QString options, Setup*, int type)
+    : EmuFrontObject(id, name), executable(executable),
+    options(options), setup(setup), type(type)
+{}
+
+Executable::Executable(const Executable &e)
+    : EmuFrontObject(e.id, e.name), executable(e.executable),
+    options(e.options), type(e.type)
+{
+    Setup *s = e.setup;
+    setup = new Setup(*s);
+}
+
+Executable::~Executable()
+{
+    delete setup;
+}
+
+Executable& Executable::operator =(const Executable &e)
 {
+    if (this == &e) return *this;
+    id = e.id;
+    name = e.name;
+    executable = e.executable;
+    options = e.options;
+    type = e.type;
+    Setup *s = e.setup;
+    if (setup) delete setup;
+    setup = new Setup(*s);
+    return (*this);
 }
+
+QString Executable::getExecutable() const
+{ return executable; }
+
+void Executable::setExecutable(QString e)
+{ executable = e; }
+
+QString Executable::getOptions() const
+{ return options; }
+
+void Executable::setOptions(QString o)
+{ options = o; }
+
+Setup* Executable::getSetup() const
+{ return setup; }
+
+void Executable::setSetup(Setup* s)
+{ setup = s; }
+
+int Executable::getType() const
+{ return type; }
+
+void Executable::setType(int t)
+{ type = t; }
index ef2a764..3d0a0ee 100644 (file)
 #ifndef EXECUTABLE_H
 #define EXECUTABLE_H
 
-#include "emufrontfileobject.h"
+#include "emufrontobject.h"
 
-class Executable : public EmuFrontFileObject
+class Setup;
+
+class Executable : public EmuFrontObject
 {
 public:
     Executable();
+    Executable(int id, QString name);
+    Executable(int id, QString name, QString executable, QString options, Setup*, int type);
+    Executable(const Executable &);
+    ~Executable();
+    Executable& operator =(const Executable &);
+    QString getExecutable() const;
+    void setExecutable(QString);
+    QString getOptions() const;
+    void setOptions(QString);
+    Setup* getSetup() const;
+    void setSetup(Setup*);
+    int getType() const;
+    void setType(int);
+private:
+    QString executable;
+    QString options;
+    Setup *setup;
+    int type;
 };
 
 #endif // EXECUTABLE_H
index 8a7df69..60d2b50 100644 (file)
@@ -92,10 +92,10 @@ bool DbCreator::createDB()
         ret = query.exec("CREATE TABLE IF NOT EXISTS executable "
                         "(id INTEGER PRIMARY KEY, "
                         "name TEXT, "
+                        "executable TEXT, "
                         "options TEXT, "
                         "type INTEGER, "
-                        "setupid INTEGER REFERENCES setup(id),"
-                        "fileid INTEGER REFERENCES file(id))");
+                        "setupid INTEGER REFERENCES setup(id))");
 
         /*qDebug() << "Creating TABLE filetype";
             ret = query.exec("CREATE TABLE filetype IF NOT EXISTS"
@@ -166,9 +166,8 @@ bool DbCreator::createDB()
             "BEGIN "
             "   UPDATE platform SET platform.fileid=NULL WHERE platform.fileid = old.id;"
             "   UPDATE mediatype SET mediatype.fileid=NULL WHERE mediatype.fileid = old.id;"
-            "   UPDATE executable SET executable.fileid=NULL WHERE executable.fileid = old.id;"
+            "   DELETE FROM mediaimagecontainer WHERE fileid = old.id;"
             "   DELETE FROM mediaimagecontainer_mediaimage WHERE mediaimagecontainer_mediaimage.fileid = old.id;"
-            "   DELETE FROM mediaimagecontainer WHERE mediaimagecontainer.fileid = old.id;"
             "END;"
         );
     }