ShowEpisode.h 3.25 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.
 *****************************************************************************/

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
23 24 25 26 27 28
#ifndef SHOWEPISODE_H
#define SHOWEPISODE_H

#include <string>
#include <sqlite3.h>

29 30
#include "medialibrary/IMediaLibrary.h"
#include "medialibrary/IShowEpisode.h"
31
#include "database/DatabaseHelpers.h"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
32

33 34 35 36 37 38
namespace medialibrary
{

class Show;
class ShowEpisode;

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
39 40 41 42 43
namespace policy
{
struct ShowEpisodeTable
{
    static const std::string Name;
44
    static const std::string PrimaryKeyColumn;
45
    static int64_t ShowEpisode::*const PrimaryKey;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
46 47 48
};
}

49
class ShowEpisode : public IShowEpisode, public DatabaseHelpers<ShowEpisode, policy::ShowEpisodeTable>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
50 51
{
    public:
52
        ShowEpisode( MediaLibraryPtr ml, sqlite::Row& row );
53
        ShowEpisode( MediaLibraryPtr ml, int64_t mediaId, const std::string& name, unsigned int episodeNumber, int64_t showId );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
54

55
        virtual int64_t id() const override;
56 57
        virtual const std::string& artworkMrl() const override;
        bool setArtworkMrl( const std::string& artworkMrl );
58 59
        virtual unsigned int episodeNumber() const override;
        virtual const std::string& name() const override;
60
        unsigned int seasonNumber() const override;
61
        bool setSeasonNumber(unsigned int seasonNumber);
62
        virtual const std::string& shortSummary() const override;
63
        bool setShortSummary( const std::string& summary );
64
        virtual const std::string& tvdbId() const override;
65
        bool setTvdbId( const std::string& tvdbId );
66 67
        virtual ShowPtr show() override;
        virtual std::vector<MediaPtr> files() override;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
68

69
        static void createTable( sqlite::Connection* dbConnection );
70
        static std::shared_ptr<ShowEpisode> create( MediaLibraryPtr ml, int64_t mediaId, const std::string& title, unsigned int episodeNumber, int64_t showId );
71
        static ShowEpisodePtr fromMedia( MediaLibraryPtr ml, int64_t mediaId );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
72 73

    private:
74
        MediaLibraryPtr m_ml;
75 76
        int64_t m_id;
        int64_t m_mediaId;
77
        std::string m_artworkMrl;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
78 79 80 81 82
        unsigned int m_episodeNumber;
        std::string m_name;
        unsigned int m_seasonNumber;
        std::string m_shortSummary;
        std::string m_tvdbId;
83
        int64_t m_showId;
84
        ShowPtr m_show;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
85

86
        friend struct policy::ShowEpisodeTable;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
87 88
};

89 90
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
91
#endif // SHOWEPISODE_H