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

#include "IMovie.h"
#include <sqlite3.h>
28
#include "database/DatabaseHelpers.h"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
29 30 31 32 33 34 35 36

class Movie;

namespace policy
{
struct MovieTable
{
    static const std::string Name;
37
    static const std::string PrimaryKeyColumn;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
38 39 40 41
    static unsigned int Movie::*const PrimaryKey;
};
}

42
class Movie : public IMovie, public DatabaseHelpers<Movie, policy::MovieTable>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
43 44
{
    public:
45
        Movie( MediaLibraryPtr ml, sqlite::Row& row );
46
        Movie( MediaLibraryPtr ml, unsigned int mediaId, const std::string& title );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
47

48 49 50 51 52 53
        virtual unsigned int id() const override;
        virtual const std::string& title() const override;
        virtual time_t releaseDate() const override;
        bool setReleaseDate(time_t date);
        virtual const std::string& shortSummary() const override;
        bool setShortSummary(const std::string& summary);
54 55
        virtual const std::string& artworkMrl() const override;
        bool setArtworkMrl(const std::string& artworkMrl);
56 57 58 59
        virtual const std::string& imdbId() const override;
        bool setImdbId(const std::string& imdbId);
        virtual std::vector<MediaPtr> files() override;

60
        static bool createTable( DBConnection dbConnection );
61 62
        static std::shared_ptr<Movie> create( MediaLibraryPtr ml, unsigned int mediaId, const std::string& title );
        static MoviePtr fromMedia( MediaLibraryPtr ml, unsigned int mediaId );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
63 64

    private:
65
        MediaLibraryPtr m_ml;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
66
        unsigned int m_id;
67
        unsigned int m_mediaId;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
68 69 70
        std::string m_title;
        time_t m_releaseDate;
        std::string m_summary;
71
        std::string m_artworkMrl;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
72 73 74 75 76 77
        std::string m_imdbId;

        friend struct policy::MovieTable;
};

#endif // MOVIE_H