Movie.h 2.32 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
#ifndef MOVIE_H
#define MOVIE_H

26
#include "medialibrary/IMovie.h"
27
#include <sqlite3.h>
28
#include "database/DatabaseHelpers.h"
29

30 31 32
namespace medialibrary
{

33 34
class Movie;

35
class Movie : public IMovie, public DatabaseHelpers<Movie>
36 37
{
    public:
38 39 40 41 42 43
        struct Table
        {
            static const std::string Name;
            static const std::string PrimaryKeyColumn;
            static int64_t Movie::*const PrimaryKey;
        };
44
        Movie( MediaLibraryPtr ml, sqlite::Row& row );
45
        Movie( MediaLibraryPtr ml, int64_t mediaId );
46

47
        virtual int64_t id() const override;
48 49 50 51 52
        virtual const std::string& shortSummary() const override;
        bool setShortSummary(const std::string& summary);
        virtual const std::string& imdbId() const override;
        bool setImdbId(const std::string& imdbId);

53
        static void createTable( sqlite::Connection* dbConnection );
54
        static std::shared_ptr<Movie> create( MediaLibraryPtr ml, int64_t mediaId );
55
        static MoviePtr fromMedia( MediaLibraryPtr ml, int64_t mediaId );
56 57

    private:
58
        MediaLibraryPtr m_ml;
59 60
        int64_t m_id;
        int64_t m_mediaId;
61 62 63
        std::string m_summary;
        std::string m_imdbId;

64
        friend struct Movie::Table;
65 66
};

67 68
}

69
#endif // MOVIE_H