Label.h 2.13 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
#pragma once
24 25 26

#include <string>

27
#include "medialibrary/ILabel.h"
28
#include "database/DatabaseHelpers.h"
29

30 31 32 33 34 35
namespace medialibrary
{

class Media;
class Label;

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

    public:
49
        virtual int64_t id() const override;
50
        virtual const std::string& name() const override;
51
        virtual Query<IMedia> media() override;
52

53
        static LabelPtr create( MediaLibraryPtr ml, const std::string& name );
54
        static void createTable( sqlite::Connection* dbConnection );
55
        static void createTriggers( sqlite::Connection* dbConnection );
56

57
    private:
58
        MediaLibraryPtr m_ml;
59
        int64_t m_id;
60
        const std::string m_name;
61

62
        friend struct Label::Table;
63 64
};

65
}