mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-04-13 05:11:08 +02:00
Cleaning up some accessors/mutators
This commit is contained in:
@@ -45,35 +45,11 @@ CollectionInfo::~CollectionInfo()
|
||||
}
|
||||
}
|
||||
|
||||
std::string CollectionInfo::GetName() const
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
std::string CollectionInfo::GetSettingsPath() const
|
||||
{
|
||||
return Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", GetName());
|
||||
return Utils::CombinePath(Configuration::AbsolutePath, "collections", Name);
|
||||
}
|
||||
|
||||
std::string CollectionInfo::GetListPath() const
|
||||
{
|
||||
return ListPath;
|
||||
}
|
||||
|
||||
std::string CollectionInfo::GetMetadataType() const
|
||||
{
|
||||
return MetadataType;
|
||||
}
|
||||
|
||||
std::string CollectionInfo::GetMetadataPath() const
|
||||
{
|
||||
return MetadataPath;
|
||||
}
|
||||
|
||||
std::string CollectionInfo::GetExtensions() const
|
||||
{
|
||||
return Extensions;
|
||||
}
|
||||
|
||||
void CollectionInfo::GetExtensions(std::vector<std::string> &extensions)
|
||||
{
|
||||
@@ -85,14 +61,11 @@ void CollectionInfo::GetExtensions(std::vector<std::string> &extensions)
|
||||
extensions.push_back(token);
|
||||
}
|
||||
}
|
||||
std::vector<Item *> *CollectionInfo::GetItems()
|
||||
{
|
||||
return &Items;
|
||||
}
|
||||
|
||||
bool CollectionInfo::ItemIsLess(Item const *lhs, Item const *rhs)
|
||||
|
||||
bool CollectionInfo::ItemIsLess(Item *lhs, Item *rhs)
|
||||
{
|
||||
return lhs->GetLCFullTitle() < rhs->GetLCFullTitle();
|
||||
return lhs->LCFullTitle() < rhs->LCFullTitle();
|
||||
}
|
||||
|
||||
void CollectionInfo::SortItems()
|
||||
|
||||
@@ -25,23 +25,17 @@ class CollectionInfo
|
||||
public:
|
||||
CollectionInfo(std::string name, std::string listPath, std::string extensions, std::string metadataType, std::string metadataPath);
|
||||
virtual ~CollectionInfo();
|
||||
std::string GetName() const;
|
||||
std::string GetSettingsPath() const;
|
||||
std::string GetListPath() const;
|
||||
std::string GetMetadataType() const;
|
||||
std::string GetMetadataPath() const;
|
||||
std::string GetExtensions() const;
|
||||
std::vector<Item *> *GetItems();
|
||||
void SortItems();
|
||||
void GetExtensions(std::vector<std::string> &extensions);
|
||||
|
||||
private:
|
||||
static bool ItemIsLess(Item const *lhs, Item const *rhs);
|
||||
|
||||
std::string Name;
|
||||
std::string ListPath;
|
||||
std::string Extensions;
|
||||
std::string MetadataType;
|
||||
std::string MetadataPath;
|
||||
std::vector<Item *> Items;
|
||||
|
||||
private:
|
||||
static bool ItemIsLess(Item *lhs, Item *rhs);
|
||||
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ CollectionInfoBuilder::~CollectionInfoBuilder()
|
||||
|
||||
bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
|
||||
{
|
||||
std::string collectionPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", name);
|
||||
std::string collectionPath = Utils::CombinePath(Configuration::AbsolutePath, "collections", name);
|
||||
|
||||
std::vector<std::string> paths;
|
||||
paths.push_back(collectionPath);
|
||||
@@ -215,11 +215,10 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo * /*info*/, std::stri
|
||||
|
||||
line.erase( std::remove(line.begin(), line.end(), '\r'), line.end() );
|
||||
|
||||
i->SetFullTitle(line);
|
||||
i->SetName(line);
|
||||
i->SetFullTitle(line);
|
||||
i->SetTitle(line);
|
||||
i->SetLauncher(launcher);
|
||||
i->FullTitle = line;
|
||||
i->Name = line;
|
||||
i->Title = line;
|
||||
i->Launcher = launcher;
|
||||
|
||||
list[line] = i;
|
||||
}
|
||||
@@ -232,16 +231,16 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
||||
{
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
std::string path = info->GetListPath();
|
||||
std::string path = info->ListPath;
|
||||
std::map<std::string, Item *> includeFilter;
|
||||
std::map<std::string, Item *> excludeFilter;
|
||||
std::string includeFile = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", info->GetName(), "include.txt");
|
||||
std::string excludeFile = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", info->GetName(), "exclude.txt");
|
||||
std::string includeFile = Utils::CombinePath(Configuration::AbsolutePath, "collections", info->Name, "include.txt");
|
||||
std::string excludeFile = Utils::CombinePath(Configuration::AbsolutePath, "collections", info->Name, "exclude.txt");
|
||||
std::string launcher;
|
||||
bool showMissing = false;
|
||||
|
||||
(void)Conf.GetProperty("collections." + info->GetName() + ".launcher", launcher);
|
||||
(void)Conf.GetProperty("collections." + info->GetName() + ".list.includeMissingItems", showMissing);
|
||||
(void)Conf.GetProperty("collections." + info->Name + ".launcher", launcher);
|
||||
(void)Conf.GetProperty("collections." + info->Name + ".list.includeMissingItems", showMissing);
|
||||
|
||||
ImportBasicList(info, includeFile, launcher, includeFilter);
|
||||
ImportBasicList(info, excludeFile, launcher, excludeFilter);
|
||||
@@ -267,7 +266,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
||||
{
|
||||
if(excludeFilter.find(it->first) == excludeFilter.end())
|
||||
{
|
||||
info->GetItems()->push_back(it->second);
|
||||
info->Items.push_back(it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -295,11 +294,11 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
||||
if(file.compare(start, comparator.length(), *extensionsIt) == 0)
|
||||
{
|
||||
Item *i = new Item();
|
||||
i->SetName(basename);
|
||||
i->SetFullTitle(basename);
|
||||
i->SetTitle(basename);
|
||||
i->SetLauncher(launcher);
|
||||
info->GetItems()->push_back(i);
|
||||
i->Name = basename;
|
||||
i->FullTitle = basename;
|
||||
i->Title = basename;
|
||||
i->Launcher = launcher;
|
||||
info->Items.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,142 +28,24 @@ Item::~Item()
|
||||
{
|
||||
}
|
||||
|
||||
const std::string Item::GetFileName() const
|
||||
std::string Item::FileName()
|
||||
{
|
||||
return Utils::GetFileName(FilePath);
|
||||
}
|
||||
|
||||
const std::string& Item::GetFilePath() const
|
||||
{
|
||||
return FilePath;
|
||||
}
|
||||
|
||||
void Item::SetFilePath(const std::string& filepath)
|
||||
{
|
||||
FilePath = filepath;
|
||||
}
|
||||
|
||||
const std::string& Item::GetLauncher() const
|
||||
{
|
||||
return Launcher;
|
||||
}
|
||||
|
||||
void Item::SetLauncher(const std::string& launcher)
|
||||
{
|
||||
Launcher = launcher;
|
||||
}
|
||||
|
||||
const std::string& Item::GetManufacturer() const
|
||||
{
|
||||
return Manufacturer;
|
||||
}
|
||||
|
||||
void Item::SetManufacturer(const std::string& manufacturer)
|
||||
{
|
||||
Manufacturer = manufacturer;
|
||||
}
|
||||
|
||||
const std::string& Item::GetGenre() const
|
||||
{
|
||||
return Genre;
|
||||
}
|
||||
|
||||
void Item::SetGenre(const std::string& genre)
|
||||
{
|
||||
Genre = genre;
|
||||
}
|
||||
|
||||
const std::string& Item::GetName() const
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
void Item::SetName(const std::string& name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
std::string Item::GetNumberButtons() const
|
||||
{
|
||||
return NumberButtons;
|
||||
}
|
||||
|
||||
|
||||
void Item::SetNumberButtons(std::string numberbuttons)
|
||||
std::string Item::LCTitle()
|
||||
{
|
||||
NumberButtons = numberbuttons;
|
||||
std::string lcstr = Title;
|
||||
std::transform(lcstr.begin(), lcstr.end(), lcstr.begin(), ::tolower);
|
||||
return lcstr;
|
||||
}
|
||||
|
||||
std::string Item::GetNumberPlayers() const
|
||||
std::string Item::LCFullTitle()
|
||||
{
|
||||
return NumberPlayers;
|
||||
std::string lcstr = FullTitle;
|
||||
std::transform(lcstr.begin(), lcstr.end(), lcstr.begin(), ::tolower);
|
||||
return lcstr;
|
||||
}
|
||||
|
||||
void Item::SetNumberPlayers(std::string numberplayers)
|
||||
{
|
||||
NumberPlayers = numberplayers;
|
||||
}
|
||||
|
||||
const std::string& Item::GetTitle() const
|
||||
{
|
||||
return Title;
|
||||
}
|
||||
|
||||
const std::string& Item::GetLCTitle() const
|
||||
{
|
||||
return LCTitle;
|
||||
}
|
||||
|
||||
const std::string& Item::GetLCFullTitle() const
|
||||
{
|
||||
return LCFullTitle;
|
||||
}
|
||||
|
||||
void Item::SetTitle(const std::string& title)
|
||||
{
|
||||
Title = title;
|
||||
LCTitle = Title;
|
||||
std::transform(LCTitle.begin(), LCTitle.end(), LCTitle.begin(), ::tolower);
|
||||
}
|
||||
|
||||
const std::string& Item::GetYear() const
|
||||
{
|
||||
return Year;
|
||||
}
|
||||
|
||||
void Item::SetYear(const std::string& year)
|
||||
{
|
||||
Year = year;
|
||||
}
|
||||
|
||||
bool Item::IsLeaf() const
|
||||
{
|
||||
return Leaf;
|
||||
}
|
||||
|
||||
void Item::SetIsLeaf(bool leaf)
|
||||
{
|
||||
Leaf = leaf;
|
||||
}
|
||||
|
||||
const std::string& Item::GetFullTitle() const
|
||||
{
|
||||
return FullTitle;
|
||||
}
|
||||
|
||||
void Item::SetFullTitle(const std::string& fulltitle)
|
||||
{
|
||||
FullTitle = fulltitle;
|
||||
LCFullTitle = fulltitle;
|
||||
std::transform(LCFullTitle.begin(), LCFullTitle.end(), LCFullTitle.begin(), ::tolower);
|
||||
}
|
||||
|
||||
const std::string& Item::GetCloneOf() const
|
||||
{
|
||||
return CloneOf;
|
||||
}
|
||||
|
||||
void Item::SetCloneOf(const std::string& cloneOf)
|
||||
{
|
||||
CloneOf = cloneOf;
|
||||
}
|
||||
|
||||
@@ -22,42 +22,14 @@ class Item
|
||||
public:
|
||||
Item();
|
||||
virtual ~Item();
|
||||
const std::string GetFileName() const;
|
||||
const std::string& GetFilePath() const;
|
||||
void SetFilePath(const std::string& filepath);
|
||||
const std::string& GetLauncher() const;
|
||||
void SetLauncher(const std::string& launcher);
|
||||
const std::string& GetManufacturer() const;
|
||||
void SetManufacturer(const std::string& manufacturer);
|
||||
const std::string& GetGenre() const;
|
||||
void SetGenre(const std::string& genre);
|
||||
const std::string& GetName() const;
|
||||
void SetName(const std::string& name);
|
||||
void SetNumberButtons(std::string numberbuttons);
|
||||
std::string GetNumberButtons() const;
|
||||
void SetNumberPlayers(std::string numberplayers);
|
||||
std::string GetNumberPlayers() const;
|
||||
const std::string& GetTitle() const;
|
||||
const std::string& GetLCTitle() const;
|
||||
void SetTitle(const std::string& title);
|
||||
const std::string& GetYear() const;
|
||||
void SetYear(const std::string& year);
|
||||
bool IsLeaf() const;
|
||||
void SetIsLeaf(bool leaf);
|
||||
const std::string& GetFullTitle() const;
|
||||
const std::string& GetLCFullTitle() const;
|
||||
void SetFullTitle(const std::string& fulltitle);
|
||||
const std::string& GetCloneOf() const;
|
||||
void SetCloneOf(const std::string& cloneOf);
|
||||
|
||||
private:
|
||||
std::string FileName();
|
||||
std::string LCTitle() ;
|
||||
std::string LCFullTitle();
|
||||
std::string Name;
|
||||
std::string Launcher;
|
||||
std::string FilePath;
|
||||
std::string Name;
|
||||
std::string Title;
|
||||
std::string LCTitle;
|
||||
std::string FullTitle;
|
||||
std::string LCFullTitle;
|
||||
std::string Year;
|
||||
std::string Manufacturer;
|
||||
std::string Genre;
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
bool VectorSort(const Item *d1, const Item *d2)
|
||||
bool VectorSort(Item *d1, Item *d2)
|
||||
{
|
||||
return d1->GetLCTitle() < d2->GetLCTitle();
|
||||
return d1->LCTitle() < d2->LCTitle();
|
||||
}
|
||||
|
||||
MenuParser::MenuParser()
|
||||
@@ -44,7 +44,7 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
|
||||
{
|
||||
bool retVal = false;
|
||||
//todo: magic string
|
||||
std::string menuFilename = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", collection->GetName(), "menu.xml");
|
||||
std::string menuFilename = Utils::CombinePath(Configuration::AbsolutePath, "collections", collection->Name, "menu.xml");
|
||||
rapidxml::xml_document<> doc;
|
||||
rapidxml::xml_node<> * rootNode;
|
||||
|
||||
@@ -88,11 +88,11 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
|
||||
//todo, check for empty string
|
||||
std::string title = collectionAttribute->value();
|
||||
Item *item = new Item();
|
||||
item->SetTitle(title);
|
||||
item->SetFullTitle(title);
|
||||
item->SetName(collectionAttribute->value());
|
||||
item->SetIsLeaf(false);
|
||||
collection->GetItems()->push_back(item);
|
||||
item->Title = title;
|
||||
item->FullTitle = title;
|
||||
item->Name = collectionAttribute->value();
|
||||
item->Leaf = false;
|
||||
collection->Items.push_back(item);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -106,7 +106,7 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
|
||||
}
|
||||
|
||||
// todo: sorting should occur within the collection itself, not externally
|
||||
std::vector<Item *> *items = collection->GetItems();
|
||||
std::vector<Item *> *items = &collection->Items;
|
||||
std::sort( items->begin(), items->end(), VectorSort);
|
||||
|
||||
retVal = true;
|
||||
|
||||
Reference in New Issue
Block a user