Label.h 2.18 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 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"
31

32 33 34 35 36 37
namespace medialibrary
{

class Media;
class Label;

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

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

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

59
    private:
60
        MediaLibraryPtr m_ml;
61
        int64_t m_id;
62
        const std::string m_name;
63

64
        friend struct Label::Table;
65 66
};

67 68
}

69
#endif // LABEL_H