summaryrefslogtreecommitdiff
path: root/src/executableslist.h
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-06-07 17:53:42 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-06-15 14:40:39 -0400
commit4f01b94f01180989abbdf0407cdf95483970dba8 (patch)
treeb62de88f3240aca1b4702848142943510dba3d70 /src/executableslist.h
parent5fb26b2dcbfae9d6a1aaac9d61f017bacf572f09 (diff)
replaced ExecutablesList::getExecutables() by a standard container interface
renamed ExecutablesList::init() to addFromPlugin() renamed ExecutablesList::find() to get() and added a find() that returns an iterator changed some calls from get() to find() so they can handle failure because they didn't seem to handle std::runtime_error at all
Diffstat (limited to 'src/executableslist.h')
-rw-r--r--src/executableslist.h63
1 files changed, 24 insertions, 39 deletions
diff --git a/src/executableslist.h b/src/executableslist.h
index 0e43b337..b8e4cf77 100644
--- a/src/executableslist.h
+++ b/src/executableslist.h
@@ -88,28 +88,33 @@ private:
**/
class ExecutablesList {
public:
+ using vector_type = std::vector<Executable>;
+ using iterator = vector_type::iterator;
+ using const_iterator = vector_type::const_iterator;
/**
- * @brief constructor
- *
- **/
- ExecutablesList();
-
- ~ExecutablesList();
+ * standard container interface
+ */
+ iterator begin();
+ const_iterator begin() const;
+ iterator end();
+ const_iterator end() const;
+ std::size_t size() const;
+ bool empty() const;
/**
- * @brief initialise the list with the executables preconfigured for this game
+ * @brief add the executables preconfigured for this game
**/
- void init(MOBase::IPluginGame const *game);
+ void addFromPlugin(MOBase::IPluginGame const *game);
/**
- * @brief find an executable by its name
+ * @brief get an executable by name
*
* @param title the title of the executable to look up
* @return the executable
- * @exception runtime_error will throw an exception if the name is not correct
+ * @exception runtime_error will throw an exception if the executable is not found
**/
- const Executable &find(const QString &title) const;
+ const Executable &get(const QString &title) const;
/**
* @brief find an executable by its name
@@ -118,7 +123,7 @@ public:
* @return the executable
* @exception runtime_error will throw an exception if the name is not correct
**/
- Executable &find(const QString &title);
+ Executable &get(const QString &title);
/**
* @brief find an executable by a fileinfo structure
@@ -126,7 +131,13 @@ public:
* @return the executable
* @exception runtime_error will throw an exception if the name is not correct
*/
- Executable &findByBinary(const QFileInfo &info);
+ Executable &getByBinary(const QFileInfo &info);
+
+ /**
+ * @brief returns an iterator for the given executable by title, or end()
+ */
+ iterator find(const QString &title);
+ const_iterator find(const QString &title) const;
/**
* @brief determine if an executable exists
@@ -183,33 +194,7 @@ public:
**/
void remove(const QString &title);
- /**
- * @brief retrieve begin and end iterators of the configured executables
- *
- * @param begin iterator to the first executable
- * @param end iterator one past the last executable
- **/
- void getExecutables(std::vector<Executable>::const_iterator &begin, std::vector<Executable>::const_iterator &end) const;
-
- /**
- * @brief retrieve begin and end iterators of the configured executables
- *
- * @param begin iterator to the first executable
- * @param end iterator one past the last executable
- **/
- void getExecutables(std::vector<Executable>::iterator &begin, std::vector<Executable>::iterator &end);
-
- /**
- * @brief get the number of executables (custom or otherwise)
- **/
- size_t size() const {
- return m_Executables.size();
- }
-
private:
-
- std::vector<Executable>::iterator findExe(const QString &title);
-
void addExecutableInternal(const QString &title, const QString &executableName, const QString &arguments,
const QString &workingDirectory,
const QString &steamAppID);