Label.h 2.19 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 LABEL_H
#define LABEL_H

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

29
#include "medialibrary/ILabel.h"
30
#include "database/DatabaseHelpers.h"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
31

32
33
34
35
36
37
namespace medialibrary
{

class Media;
class Label;

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
38
39
40
41
42
namespace policy
{
struct LabelTable
{
    static const std::string Name;
43
    static const std::string PrimaryKeyColumn;
44
    static int64_t Label::*const PrimaryKey;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
45
46
47
};
}

48
class Label : public ILabel, public DatabaseHelpers<Label, policy::LabelTable>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
49
50
{
    public:
51
        Label( MediaLibraryPtr ml, sqlite::Row& row );
52
        Label( MediaLibraryPtr ml, const std::string& name );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
53
54

    public:
55
        virtual int64_t id() const override;
56
        virtual const std::string& name() const override;
57
        virtual std::vector<MediaPtr> files() override;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
58

59
        static LabelPtr create( MediaLibraryPtr ml, const std::string& name );
60
        static void createTable( sqlite::Connection* dbConnection );
61
        static void createTriggers( sqlite::Connection* dbConnection );
62

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
63
    private:
64
        MediaLibraryPtr m_ml;
65
        int64_t m_id;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
66
        std::string m_name;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
67

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
68
        friend struct policy::LabelTable;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
69
70
};

71
72
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
73
#endif // LABEL_H