AlbumTrack.h 2.84 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/Cache.h"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
32
33

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

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

class AlbumTrack : public IAlbumTrack, public Cache<AlbumTrack, IAlbumTrack, policy::AlbumTrackTable>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
47
{
48
49
    private:
        typedef Cache<AlbumTrack, IAlbumTrack, policy::AlbumTrackTable> _Cache;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
50
    public:
51
        AlbumTrack( DBConnection dbConnection, sqlite3_stmt* stmt );
52
        AlbumTrack( const std::string& title, unsigned int trackNumber, unsigned int albumId );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
53

54
55
56
57
58
59
60
        virtual unsigned int id() const override;
        virtual const std::string& genre() override;
        bool setGenre( const std::string& genre );
        virtual const std::string& title() override;
        virtual unsigned int trackNumber() override;
        virtual std::shared_ptr<IAlbum> album() override;
        virtual std::vector<MediaPtr> files() override;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
61

62
        bool destroy();
63
        static bool createTable( DBConnection dbConnection );
64
        static std::shared_ptr<AlbumTrack> create( DBConnection dbConnection, unsigned int albumId,
65
                                     const std::string& name, unsigned int trackNb );
66

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
67
    private:
68
        DBConnection m_dbConnection;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
69
70
71
72
73
74
        unsigned int m_id;
        std::string m_title;
        std::string m_genre;
        unsigned int m_trackNumber;
        unsigned int m_albumId;

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
75
76
77
        std::shared_ptr<Album> m_album;

        friend class Cache<AlbumTrack, IAlbumTrack, policy::AlbumTrackTable>;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
78
        friend struct policy::AlbumTrackTable;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
79
80
81
};

#endif // ALBUMTRACK_H