diff --git a/src/common/JoyMap.cxx b/src/common/JoyMap.cxx index b0a2d081d..b64cfbc3c 100644 --- a/src/common/JoyMap.cxx +++ b/src/common/JoyMap.cxx @@ -17,11 +17,6 @@ #include "JoyMap.hxx" -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -JoyMap::JoyMap(void) -{ -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void JoyMap::add(const Event::Type event, const JoyMapping& mapping) { diff --git a/src/common/JoyMap.hxx b/src/common/JoyMap.hxx index 42ef087dc..7fd9f22d8 100644 --- a/src/common/JoyMap.hxx +++ b/src/common/JoyMap.hxx @@ -30,7 +30,6 @@ class JoyMap { public: - struct JoyMapping { EventMode mode; @@ -44,10 +43,6 @@ class JoyMap : mode(EventMode(0)), button(0), axis(JoyAxis(0)), adir(JoyDir(0)), hat(0), hdir(JoyHatDir(0)) { } - JoyMapping(const JoyMapping& m) - : mode(m.mode), button(m.button), - axis(m.axis), adir(m.adir), - hat(m.hat), hdir(m.hdir) { } explicit JoyMapping(EventMode c_mode, int c_button, JoyAxis c_axis, JoyDir c_adir, int c_hat, JoyHatDir c_hdir) @@ -65,6 +60,11 @@ class JoyMap axis(JoyAxis::NONE), adir(JoyDir::NONE), hat(c_hat), hdir(c_hdir) { } + JoyMapping(const JoyMapping&) = default; + JoyMapping& operator=(const JoyMapping&) = default; + JoyMapping(JoyMapping&&) = default; + JoyMapping& operator=(JoyMapping&&) = default; + bool operator==(const JoyMapping& other) const { return (mode == other.mode @@ -78,8 +78,7 @@ class JoyMap }; using JoyMappingArray = std::vector; - JoyMap(); - virtual ~JoyMap() = default; + JoyMap() = default; /** Add new mapping for given event */ void add(const Event::Type event, const JoyMapping& mapping); @@ -142,6 +141,12 @@ class JoyMap }; std::unordered_map myMap; + + // Following constructors and assignment operators not supported + JoyMap(const JoyMap&) = delete; + JoyMap(JoyMap&&) = delete; + JoyMap& operator=(const JoyMap&) = delete; + JoyMap& operator=(JoyMap&&) = delete; }; #endif diff --git a/src/common/KeyMap.cxx b/src/common/KeyMap.cxx index 8b79fea1c..2516732f8 100644 --- a/src/common/KeyMap.cxx +++ b/src/common/KeyMap.cxx @@ -14,13 +14,8 @@ // See the file "License.txt" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include "KeyMap.hxx" -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -KeyMap::KeyMap(void) - : myModEnabled(true) -{ -} +#include "KeyMap.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void KeyMap::add(const Event::Type event, const Mapping& mapping) diff --git a/src/common/KeyMap.hxx b/src/common/KeyMap.hxx index f4405a968..363ec1acf 100644 --- a/src/common/KeyMap.hxx +++ b/src/common/KeyMap.hxx @@ -30,7 +30,6 @@ class KeyMap { public: - struct Mapping { EventMode mode; @@ -38,11 +37,14 @@ class KeyMap StellaMod mod; Mapping() : mode(EventMode(0)), key(StellaKey(0)), mod(StellaMod(0)) { } - Mapping(const Mapping& m) : mode(m.mode), key(m.key), mod(m.mod) { } explicit Mapping(EventMode c_mode, StellaKey c_key, StellaMod c_mod) : mode(c_mode), key(c_key), mod(c_mod) { } explicit Mapping(EventMode c_mode, int c_key, int c_mod) : mode(c_mode), key(StellaKey(c_key)), mod(StellaMod(c_mod)) { } + Mapping(const Mapping&) = default; + Mapping& operator=(const Mapping&) = default; + Mapping(Mapping&&) = default; + Mapping& operator=(Mapping&&) = default; bool operator==(const Mapping& other) const { @@ -57,8 +59,7 @@ class KeyMap }; using MappingArray = std::vector; - KeyMap(); - virtual ~KeyMap() = default; + KeyMap() : myModEnabled(true) { } /** Add new mapping for given event */ void add(const Event::Type event, const Mapping& mapping); @@ -122,6 +123,12 @@ class KeyMap // pressing it with a movement key could inadvertantly activate // a Ctrl combo when it isn't wanted) bool myModEnabled; + + // Following constructors and assignment operators not supported + KeyMap(const KeyMap&) = delete; + KeyMap(KeyMap&&) = delete; + KeyMap& operator=(const KeyMap&) = delete; + KeyMap& operator=(KeyMap&&) = delete; }; #endif diff --git a/src/common/Rect.hxx b/src/common/Rect.hxx index 0df7e9e9d..51834a79c 100644 --- a/src/common/Rect.hxx +++ b/src/common/Rect.hxx @@ -112,7 +112,7 @@ struct Rect public: Rect() : top(0), left(0), bottom(0), right(0) { assert(valid()); } Rect(const Rect& s) : top(s.top), left(s.left), bottom(s.bottom), right(s.right) { assert(valid()); } - Rect(const Size& s) : top(0), left(0), bottom(s.h), right(s.w) { assert(valid()); } + explicit Rect(const Size& s) : top(0), left(0), bottom(s.h), right(s.w) { assert(valid()); } Rect& operator=(const Rect&) = default; Rect(uInt32 w, uInt32 h) : top(0), left(0), bottom(h), right(w) { assert(valid()); } Rect(const Point& p, uInt32 w, uInt32 h) : top(p.y), left(p.x), bottom(h), right(w) { assert(valid()); } diff --git a/src/common/RewindManager.cxx b/src/common/RewindManager.cxx index cd5638c54..70010ee0f 100644 --- a/src/common/RewindManager.cxx +++ b/src/common/RewindManager.cxx @@ -255,7 +255,7 @@ string RewindManager::saveAllStates() out.putInt(myStateSize); unique_ptr buffer = make_unique(myStateSize); - for (uInt32 i = 0; i < numStates; i++) + for (uInt32 i = 0; i < numStates; ++i) { RewindState& state = myStateList.current(); Serializer& s = state.data; @@ -310,7 +310,7 @@ string RewindManager::loadAllStates() myStateSize = in.getInt(); unique_ptr buffer = make_unique(myStateSize); - for (uInt32 i = 0; i < numStates; i++) + for (uInt32 i = 0; i < numStates; ++i) { if (myStateList.full()) compressStates(); diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index ab741ce61..cb556c053 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -308,7 +308,8 @@ void SoundSDL2::processFragment(float* stream, uInt32 length) { myResampler->fillFragment(stream, length); - for (uInt32 i = 0; i < length; i++) stream[i] = stream[i] * myVolumeFactor; + for (uInt32 i = 0; i < length; ++i) + stream[i] *= myVolumeFactor; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/repository/KeyValueRepositoryConfigfile.hxx b/src/common/repository/KeyValueRepositoryConfigfile.hxx index ddf9e3546..5c4bfcd2f 100644 --- a/src/common/repository/KeyValueRepositoryConfigfile.hxx +++ b/src/common/repository/KeyValueRepositoryConfigfile.hxx @@ -24,7 +24,7 @@ class KeyValueRepositoryConfigfile : public KeyValueRepository { public: - KeyValueRepositoryConfigfile(const string& filename); + explicit KeyValueRepositoryConfigfile(const string& filename); std::map load() override; diff --git a/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx b/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx index 1d6bc2229..676d98846 100644 --- a/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx +++ b/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx @@ -42,7 +42,7 @@ std::map KeyValueRepositorySqlite::load() myStmtSelect->reset(); } - catch (SqliteError err) { + catch (const SqliteError& err) { Logger::info(err.message); } @@ -68,7 +68,7 @@ void KeyValueRepositorySqlite::save(const std::map& values) tx.commit(); } - catch (SqliteError err) { + catch (const SqliteError& err) { Logger::info(err.message); } } @@ -86,7 +86,7 @@ void KeyValueRepositorySqlite::save(const string& key, const Variant& value) myStmtInsert->reset(); } - catch (SqliteError err) { + catch (const SqliteError& err) { Logger::info(err.message); } } diff --git a/src/common/repository/sqlite/SettingsDb.cxx b/src/common/repository/sqlite/SettingsDb.cxx index 3c48d47a2..e2af68f5a 100644 --- a/src/common/repository/sqlite/SettingsDb.cxx +++ b/src/common/repository/sqlite/SettingsDb.cxx @@ -37,7 +37,7 @@ bool SettingsDb::initialize() mySettingsRepository = make_unique(*myDb, "settings"); mySettingsRepository->initialize(); } - catch (SqliteError err) { + catch (const SqliteError& err) { Logger::info("sqlite DB " + myDb->fileName() + " failed to initialize: " + err.message); myDb.reset(); diff --git a/src/common/repository/sqlite/SqliteError.hxx b/src/common/repository/sqlite/SqliteError.hxx index facb53172..cd23c33ab 100644 --- a/src/common/repository/sqlite/SqliteError.hxx +++ b/src/common/repository/sqlite/SqliteError.hxx @@ -22,9 +22,9 @@ #include "bspf.hxx" struct SqliteError { - SqliteError(const string _message) : message(_message) {} + explicit SqliteError(const string& _message) : message(_message) {} - SqliteError(sqlite3* handle) : message(sqlite3_errmsg(handle)) {} + explicit SqliteError(sqlite3* handle) : message(sqlite3_errmsg(handle)) {} const string message; }; diff --git a/src/common/repository/sqlite/SqliteTransaction.hxx b/src/common/repository/sqlite/SqliteTransaction.hxx index f4e0df342..1485ac614 100644 --- a/src/common/repository/sqlite/SqliteTransaction.hxx +++ b/src/common/repository/sqlite/SqliteTransaction.hxx @@ -23,7 +23,7 @@ class SqliteDatabase; class SqliteTransaction { public: - SqliteTransaction(SqliteDatabase& db); + explicit SqliteTransaction(SqliteDatabase& db); ~SqliteTransaction(); diff --git a/src/common/sdl_blitter/HqBlitter.hxx b/src/common/sdl_blitter/HqBlitter.hxx index 285019db7..ea90f4e7d 100644 --- a/src/common/sdl_blitter/HqBlitter.hxx +++ b/src/common/sdl_blitter/HqBlitter.hxx @@ -26,7 +26,7 @@ class HqBlitter : public Blitter { public: - HqBlitter(FrameBufferSDL2& fb); + explicit HqBlitter(FrameBufferSDL2& fb); static bool isSupported(FrameBufferSDL2 &fb);