From 2436859145c16f25661160fe01238ccc59805283 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 29 Oct 2008 14:50:11 -0400 Subject: Initial import --- Emulator.h | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 Emulator.h (limited to 'Emulator.h') diff --git a/Emulator.h b/Emulator.h new file mode 100644 index 0000000..4fa0f83 --- /dev/null +++ b/Emulator.h @@ -0,0 +1,186 @@ +/* + * Copyright 2008 Ben Boeckel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * 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. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +/** + * \file Emulator.h + */ + +#ifndef EMULATOR_H +#define EMULATOR_H + +// EmuDB includes +#include "Profile.h" + +// Qt includes +#include +#include +#include +#include + +// Forward declarations +class Rom; + +/** + * \class Emulator + * \brief Provides information on how to run an emulator. + */ +class Emulator : public QObject +{ + Q_OBJECT + /** + * \var command + * \brief The command used to execute the emulator. + * + * \sa command + * \sa setCommand + */ + Q_PROPERTY(QString command READ command WRITE setCommand) + /** + * \var types + * \brief The types of Roms the emulator supports. + * + * \sa types + * \sa addType + * \sa removeType + */ + Q_PROPERTY(QSet types READ types) + /** + * \var profiles + * \brief Profiles for the emulator. + * + * \sa profiles + * \sa profileNames + * \sa setProfile + * \sa removeProfile + */ + Q_PROPERTY(ProfileMap profiles READ profiles) + + public: + /** + * \typedef ProfileMap + * \brief Storage type for the profiles. + */ + typedef QMap ProfileMap; + + /** + * \brief Default constructor. + */ + Emulator(); + + /** + * \brief Configuration constructor. + */ + Emulator(const KConfigGroup& config); + + /** + * \brief Copy constructor. + * + * \param rhs The profile to copy. + */ + Emulator(const Emulator& rhs); + + /** + * \brief Create a KConfigGroup for saving. + * + * \param name The name of the group. + * \param parent The parent group. + */ + void makeGroup(const QString& name, const KConfigGroup& parent) const; + + /** + * \return The command used to run the emulator. + */ + QString command() const; + + /** + * \return The systems the emulator can run. + */ + QSet types() const; + + /** + * \return All profiles for the emulator. + */ + ProfileMap profiles() const; + + /** + * \return Names of all profiles for the emulator. + */ + QStringList profileNames() const; + + /** + * \param name The name of the profile. + * \return The profile with the given name, or default if it does not exist. + */ + Profile* profile(const QString& name); + + /** + * \brief Assignment method. + * \param rhs Emulator to copy. + */ + Emulator& operator=(const Emulator& rhs); + public slots: + /** + * \brief Set the command used to run the emulator. + * + * \param command + */ + void setCommand(const QString& command); + + /** + * \brief Add a type that the emulator can run. + * + * \param type + */ + void addType(const QString& type); + + /** + * \brief Remove a type from the emulator's support. + * + * \param type + */ + void removeType(const QString& type); + + /** + * \brief Add a profile. + * + * \param name The name of the profile. + * \param profile The profile + */ + void addProfile(const QString& name, const Profile& profile); + + /** + * \brief Delete a profile for the emulator. + * + * \param name The profile to remove. + */ + void removeProfile(const QString& name); + + /** + * \brief Run the emulator. + * + * \param profileName The profile to use. + * \param rom The Rom to play. + */ + void execute(const QString& profileName, const Rom& rom); + private: + QString m_command; + QSet m_types; + ProfileMap m_profiles; +}; +Q_DECLARE_METATYPE(Emulator*) + +#endif -- cgit