Centralized scan settings into a dedicated ScanSettings table

This commit is contained in:
emeric
2018-05-20 14:38:04 +02:00
parent 702e3098a4
commit f1c12ebb4d
18 changed files with 290 additions and 410 deletions
+1 -6
View File
@@ -29,11 +29,6 @@
namespace MetaData
{
AvFormat::AvFormat(const ClusterTypes& clusterTypes)
: Parser(clusterTypes)
{
}
boost::optional<Items>
AvFormat::parse(const boost::filesystem::path& p, bool debug)
{
@@ -155,7 +150,7 @@ AvFormat::parse(const boost::filesystem::path& p, bool debug)
{
items.insert( std::make_pair(MetaData::Type::AcoustID, stringTrim(value)) );
}
else if (_clusterTypes.find(tag) != _clusterTypes.end())
else if (_clusterTypeNames.find(tag) != _clusterTypeNames.end())
{
std::vector<std::string> clusterNames = splitString(value, ";,\\");
+1 -4
View File
@@ -31,10 +31,7 @@ namespace MetaData
class AvFormat : public Parser
{
public:
AvFormat(const ClusterTypes& clusterTypes = defaultClusterTypes);
boost::optional<Items> parse(const boost::filesystem::path& p, bool debug = false);
boost::optional<Items> parse(const boost::filesystem::path& p, bool debug = false) override;
};
} // namespace MetaData
-33
View File
@@ -1,33 +0,0 @@
/*
* Copyright (C) 2018 Emeric Poupon
*
* This file is part of LMS.
*
* LMS 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.
*
* LMS 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 LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MetaData.hpp"
namespace MetaData {
const ClusterTypes Parser::defaultClusterTypes =
{
"GENRE",
"ALBUMGROUPING",
"MOOD",
"ALBUMMOOD",
"COMMENT:SONGS-DB_OCCASION",
};
} // namespace MetaData
+2 -10
View File
@@ -63,24 +63,16 @@ namespace MetaData
// See enum Type's comments
using Items = std::map<Type, boost::any>;
using Clusters = std::map<std::string /* type */, std::set<std::string> /* names */>;
using ClusterTypes = std::set<std::string>;
class Parser
{
public:
static const ClusterTypes defaultClusterTypes;
// Provide a map for tag name -> Cluster name
Parser(const ClusterTypes& clusterTypes) : _clusterTypes(clusterTypes) {}
virtual boost::optional<Items> parse(const boost::filesystem::path& p, bool debug = false) = 0;
void updateClusterTypes(const ClusterTypes& clusterTypes) { _clusterTypes = clusterTypes; }
const ClusterTypes& getClusterTypes() const { return _clusterTypes; }
bool isClusterTypeSupported(const std::string& clusterType) const { return _clusterTypes.find(clusterType) != _clusterTypes.end(); }
void setClusterTypeNames(const std::set<std::string>& clusterTypeNames) { _clusterTypeNames = clusterTypeNames; }
protected:
ClusterTypes _clusterTypes;
std::set<std::string> _clusterTypeNames;
};
} // namespace MetaData
+1 -6
View File
@@ -31,11 +31,6 @@
namespace MetaData
{
TagLibParser::TagLibParser(const ClusterTypes& clusterTypes)
: Parser(clusterTypes)
{
}
boost::optional<Items>
TagLibParser::parse(const boost::filesystem::path& p, bool debug)
{
@@ -199,7 +194,7 @@ TagLibParser::parse(const boost::filesystem::path& p, bool debug)
if (items.find(MetaData::Type::HasCover) == items.end())
items.insert( std::make_pair(MetaData::Type::HasCover, true));
}
else if (_clusterTypes.find(tag) != _clusterTypes.end())
else if (_clusterTypeNames.find(tag) != _clusterTypeNames.end())
{
std::set<std::string> clusterNames;
for (const auto& value : values)
+1 -4
View File
@@ -31,10 +31,7 @@ namespace MetaData
class TagLibParser : public Parser
{
public:
TagLibParser(const ClusterTypes& clusterTypes = defaultClusterTypes);
boost::optional<Items> parse(const boost::filesystem::path& p, bool debug = false);
boost::optional<Items> parse(const boost::filesystem::path& p, bool debug = false) override;
};
} // namespace MetaData