AlbumTrack.h 2.96 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
29
#ifndef ALBUMTRACK_H
#define ALBUMTRACK_H

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

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

class Album;
34
class AlbumTrack;
35
class Media;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
36

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
37
38
39
40
41
namespace policy
{
struct AlbumTrackTable
{
    static const std::string Name;
42
    static const std::string PrimaryKeyColumn;
43
    static unsigned int AlbumTrack::*const PrimaryKey;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
44
45
46
};
}

47
class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy::AlbumTrackTable>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
48
49
{
    public:
50
        AlbumTrack( DBConnection dbConnection, sqlite::Row& row );
51
        AlbumTrack(Media* media, unsigned int trackNumber, unsigned int albumId , unsigned int discNumber);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
52

53
        virtual unsigned int id() const override;
54
55
        virtual const std::string& artist() const override;
        bool setArtist( const std::string& artist );
56
57
58
        virtual const std::string& genre() override;
        bool setGenre( const std::string& genre );
        virtual unsigned int trackNumber() override;
59
60
        virtual unsigned int releaseYear() const override;
        bool setReleaseYear( unsigned int year );
61
        virtual unsigned int discNumber() const override;
62
        virtual std::shared_ptr<IAlbum> album() override;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
63

64
        static bool createTable( DBConnection dbConnection );
65
        static std::shared_ptr<AlbumTrack> create(DBConnection dbConnection, unsigned int albumId,
66
                                     Media* media, unsigned int trackNb , unsigned int discNumber);
67

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
68
    private:
69
        DBConnection m_dbConnection;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
70
        unsigned int m_id;
71
        unsigned int m_mediaId;
72
        std::string m_artist;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
73
74
75
        std::string m_genre;
        unsigned int m_trackNumber;
        unsigned int m_albumId;
76
        unsigned int m_releaseYear;
77
        unsigned int m_discNumber;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
78

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
79
80
        std::shared_ptr<Album> m_album;

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
81
        friend struct policy::AlbumTrackTable;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
82
83
84
};

#endif // ALBUMTRACK_H