Label.h 1021 Bytes
Newer Older
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
1 2 3 4 5 6
#ifndef LABEL_H
#define LABEL_H

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

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
7
class File;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
8

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
9 10 11 12 13 14 15 16 17 18 19 20 21
#include "ILabel.h"
#include "Cache.h"

namespace policy
{
struct LabelTable
{
    static const std::string Name;
    static const std::string CacheColumn;
};
}

class Label : public ILabel, public Cache<Label, ILabel, policy::LabelTable>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
22 23
{
    public:
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
24

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
25
        Label(sqlite3* dbConnection, sqlite3_stmt* stmt);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
26
        Label( const std::string& name );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
27 28

    public:
29
        virtual unsigned int id() const;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
30
        virtual const std::string& name();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
31
        virtual std::vector<std::shared_ptr<IFile>>& files();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
32
        bool insert( sqlite3* dbConnection );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
33 34

        static bool createTable( sqlite3* dbConnection );
35 36
        bool link( IFile* file );
        bool unlink( IFile* file ) const;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
37 38 39 40
    private:
        sqlite3* m_dbConnection;
        unsigned int m_id;
        std::string m_name;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
41 42 43
        std::vector<std::shared_ptr<IFile>>* m_files;

        friend class Cache<Label, ILabel, policy::LabelTable>;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
44 45 46
};

#endif // LABEL_H