From cfd63c74db25a3e64cd54b005803ceb463321890 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Sat, 28 Sep 2013 11:16:20 -0500 Subject: [PATCH] Refactored GameData to be completely independent of SystemData. --- src/GameData.cpp | 4 ++-- src/GameData.h | 12 +----------- src/SystemData.cpp | 2 +- src/XMLReader.cpp | 2 +- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/GameData.cpp b/src/GameData.cpp index d6f11ca3e..f40764393 100644 --- a/src/GameData.cpp +++ b/src/GameData.cpp @@ -5,8 +5,8 @@ #include #include -GameData::GameData(SystemData* system, std::string path) - : mSystem(system), mPath(path), mBaseName(boost::filesystem::path(path).stem().string()), mMetaData(system->getGameMDD()) +GameData::GameData(const std::string& path, const MetaDataList& metadata) + : mPath(path), mBaseName(boost::filesystem::path(path).stem().string()), mMetaData(metadata) { if(mMetaData.get("name").empty()) mMetaData.set("name", mBaseName); diff --git a/src/GameData.h b/src/GameData.h index 6f40c798b..27ce4f099 100644 --- a/src/GameData.h +++ b/src/GameData.h @@ -4,14 +4,13 @@ #include #include "FileData.h" -#include "SystemData.h" #include "MetaData.h" //This class holds information about a game: at the least, its name, system, and path. Additional information is optional and read by other classes. class GameData : public FileData { public: - GameData(SystemData* system, std::string path); + GameData(const std::string& path, const MetaDataList& metadata); const std::string& getName() const override; const std::string& getPath() const override; @@ -28,18 +27,9 @@ public: MetaDataList* metadata(); private: - SystemData* mSystem; const std::string mPath; const std::string mBaseName; - //extra data - /*std::string mDescription; - std::string mImagePath; - float mRating; - float mUserRating; - size_t mTimesPlayed; - std::time_t mLastPlayed;*/ - MetaDataList mMetaData; }; diff --git a/src/SystemData.cpp b/src/SystemData.cpp index e84a3714b..3fdce18db 100644 --- a/src/SystemData.cpp +++ b/src/SystemData.cpp @@ -147,7 +147,7 @@ void SystemData::populateFolder(FolderData* folder) //if it matches, add it if(chkExt == extension) { - GameData* newGame = new GameData(this, filePath.generic_string()); + GameData* newGame = new GameData(filePath.generic_string(), MetaDataList(getGameMDD())); folder->pushFileData(newGame); isGame = true; break; diff --git a/src/XMLReader.cpp b/src/XMLReader.cpp index 4cb5c6799..80d83f3c2 100644 --- a/src/XMLReader.cpp +++ b/src/XMLReader.cpp @@ -90,7 +90,7 @@ GameData* createGameFromPath(std::string gameAbsPath, SystemData* system) loops++; } - GameData* game = new GameData(system, gameAbsPath); + GameData* game = new GameData(gameAbsPath, MetaDataList(system->getGameMDD())); folder->pushFileData(game); return game; }