ShowEpisode.h 2.91 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;

39
class ShowEpisode : public IShowEpisode, public DatabaseHelpers<ShowEpisode>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
40 41
{
    public:
42 43 44 45 46 47
        struct Table
        {
            static const std::string Name;
            static const std::string PrimaryKeyColumn;
            static int64_t ShowEpisode::*const PrimaryKey;
        };
48
        ShowEpisode( MediaLibraryPtr ml, sqlite::Row& row );
49
        ShowEpisode( MediaLibraryPtr ml, int64_t mediaId, unsigned int episodeNumber, int64_t showId );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
50

51
        virtual int64_t id() const override;
52
        virtual unsigned int episodeNumber() const override;
53
        unsigned int seasonNumber() const override;
54
        bool setSeasonNumber(unsigned int seasonNumber);
55
        virtual const std::string& shortSummary() const override;
56
        bool setShortSummary( const std::string& summary );
57
        virtual const std::string& tvdbId() const override;
58
        bool setTvdbId( const std::string& tvdbId );
59
        virtual ShowPtr show() override;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
60

61
        static void createTable( sqlite::Connection* dbConnection );
62
        static std::shared_ptr<ShowEpisode> create( MediaLibraryPtr ml, int64_t mediaId, unsigned int episodeNumber, int64_t showId );
63
        static ShowEpisodePtr fromMedia( MediaLibraryPtr ml, int64_t mediaId );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
64 65

    private:
66
        MediaLibraryPtr m_ml;
67
        int64_t m_id;
68 69
        const int64_t m_mediaId;
        const unsigned int m_episodeNumber;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
70 71 72
        unsigned int m_seasonNumber;
        std::string m_shortSummary;
        std::string m_tvdbId;
73
        const int64_t m_showId;
74
        ShowPtr m_show;
75

76
        friend struct ShowEpisode::Table;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
77 78
};

79 80
}

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