/*
* Copyright (C) 2013 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 .
*/
#ifndef _AUDIO_TYPES_HPP_
#define _AUDIO_TYPES_HPP_
#include
#include
#include
#include
#include
#include
namespace Database {
// Find utilities
struct SearchFilter
{
enum class Field {
Artist, // artist name
Release, // release name
Genre, // genre name
Track, // track name
};
typedef std::map > FieldValues;
// Formulas :
// ((like1-1 LIKE ? OR like1-2 LIKE = ? ...) AND (like2-1 LIKE ? OR like2-2 LIKE ? ...)) AND exact1 = ? AND exact2 = ? ...
std::vector likeMatches;
FieldValues exactMatch;
};
class Track;
class Genre
{
public:
typedef Wt::Dbo::ptr pointer;
typedef Wt::Dbo::dbo_traits::IdType id_type;
Genre();
Genre(const std::string& name);
// Find utility
static pointer getByName(Wt::Dbo::Session& session, const std::string& name);
static pointer getNone(Wt::Dbo::Session& session);
static Wt::Dbo::collection getAll(Wt::Dbo::Session& session, int offset = -1, int size = -1);
static Wt::Dbo::Query > getAllQuery(Wt::Dbo::Session& session, SearchFilter& filter);
static void updateGenreQueryModel(Wt::Dbo::Session& session, Wt::Dbo::QueryModel >& model, SearchFilter filter, const std::vector& columnNames = std::vector());
// Create utility
static pointer create(Wt::Dbo::Session& session, const std::string& name);
// Accessors
const std::string& getName(void) const { return _name; }
bool isNone(void) const;
const Wt::Dbo::collection< Wt::Dbo::ptr