Show.h 3.52 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*****************************************************************************
 * Media Library
 *****************************************************************************
 * Copyright (C) 2015 Hugo Beauzée-Luyssen, Videolabs
 *
 * Authors: Hugo Beauzée-Luyssen<hugo@beauzee.fr>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

23 24 25 26 27
#ifndef SHOW_H
#define SHOW_H

#include <sqlite3.h>

28
#include "database/DatabaseHelpers.h"
29 30
#include "medialibrary/IMediaLibrary.h"
#include "medialibrary/IShow.h"
31

32 33 34
namespace medialibrary
{

35
class Media;
36
class Show;
37
class ShowEpisode;
38

39
class Show : public IShow, public DatabaseHelpers<Show>
40 41
{
    public:
42 43 44 45 46 47
        struct Table
        {
            static const std::string Name;
            static const std::string PrimaryKeyColumn;
            static int64_t Show::*const PrimaryKey;
        };
48
        Show( MediaLibraryPtr ml, sqlite::Row& row );
49
        Show( MediaLibraryPtr ml, const std::string& title );
50

51
        virtual int64_t id() const override;
52
        virtual const std::string& title() const override;
53 54 55 56
        virtual time_t releaseDate() const override;
        bool setReleaseDate( time_t date );
        virtual const std::string& shortSummary() const override;
        bool setShortSummary( const std::string& summary );
57 58
        virtual const std::string& artworkMrl() const override;
        bool setArtworkMrl( const std::string& artworkMrl );
59
        virtual const std::string& tvdbId() const override;
60
        bool setTvdbId( const std::string& summary );
61
        std::shared_ptr<ShowEpisode> addEpisode( Media& media, unsigned int episodeNumber );
62
        virtual Query<IMedia> episodes( const QueryParameters* params ) const override;
63 64
        virtual Query<IMedia> searchEpisodes( const std::string& pattern,
                                              const QueryParameters* params = nullptr ) const override;
65 66
        virtual uint32_t nbSeasons() const override;
        virtual uint32_t nbEpisodes() const override;
67

68
        static void createTable( sqlite::Connection* dbConnection );
69
        static void createTriggers( sqlite::Connection* dbConnection );
70
        static std::shared_ptr<Show> create( MediaLibraryPtr ml, const std::string& title );
71

72
        static Query<IShow> listAll( MediaLibraryPtr ml, const QueryParameters* params );
73 74
        static Query<IShow> search( MediaLibraryPtr ml, const std::string& pattern,
                                    const QueryParameters* params );
75

76 77 78
    private:
        static std::string orderBy( const QueryParameters* params );

79
    protected:
80 81
        MediaLibraryPtr m_ml;

82
        int64_t m_id;
83
        std::string m_title;
84
        time_t m_releaseDate;
85
        std::string m_shortSummary;
86
        std::string m_artworkMrl;
87
        std::string m_tvdbId;
88

89
        friend struct Show::Table;
90 91
};

92 93
}

94
#endif // SHOW_H