Cutelee 6.1.0
templateloader.h
1/*
2 This file is part of the Cutelee template system.
3
4 Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either version
9 2.1 of the Licence, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library. If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#ifndef CUTELEE_TEMPLATELOADER_H
22#define CUTELEE_TEMPLATELOADER_H
23
24#include "cutelee_templates_export.h"
25#include "template.h"
26
27namespace Cutelee
28{
29
30class AbstractLocalizer;
31
33
46class CUTELEE_TEMPLATES_EXPORT AbstractTemplateLoader
47{
48public:
53
58 virtual Template loadByName(const QString &name,
59 Engine const *engine) const = 0;
60
64 virtual std::pair<QString, QString>
65 getMediaUri(const QString &fileName) const = 0;
66
70 virtual bool canLoadTemplate(const QString &name) const = 0;
71};
72
74
76
135class CUTELEE_TEMPLATES_EXPORT FileSystemTemplateLoader
137{
138public:
142 FileSystemTemplateLoader(const std::shared_ptr<AbstractLocalizer> localizer
143 = {});
144
148 ~FileSystemTemplateLoader() override;
149
150 Template loadByName(const QString &name, Engine const *engine) const override;
151
152 bool canLoadTemplate(const QString &name) const override;
153
154 std::pair<QString, QString> getMediaUri(const QString &fileName) const override;
155
159 void setTheme(const QString &themeName);
160
164 QString themeName() const;
165
169 void setTemplateDirs(const QStringList &dirs);
170
174 QStringList templateDirs() const;
175
176private:
177 Q_DECLARE_PRIVATE(FileSystemTemplateLoader)
179};
180
182
193class CUTELEE_TEMPLATES_EXPORT InMemoryTemplateLoader
195{
196public:
198 ~InMemoryTemplateLoader() override;
199
200 Template loadByName(const QString &name, Engine const *engine) const override;
201
202 bool canLoadTemplate(const QString &name) const override;
203
204 std::pair<QString, QString> getMediaUri(const QString &fileName) const override;
205
220 void setTemplate(const QString &name, const QString &content);
221
222private:
223 QHash<QString, QString> m_namedTemplates;
224};
225}
226
227#endif
An retrieval interface to a storage location for Template objects.
virtual Template loadByName(const QString &name, Engine const *engine) const =0
virtual bool canLoadTemplate(const QString &name) const =0
virtual std::pair< QString, QString > getMediaUri(const QString &fileName) const =0
Cutelee::Engine is the main entry point for creating Cutelee Templates.
Definition engine.h:121
The FileSystemTemplateLoader loads Templates from the file system.
The InMemoryTemplateLoader loads Templates set dynamically in memory.
The Template class is a tree of nodes which may be rendered.
Definition template.h:95
The Cutelee namespace holds all public Cutelee API.
Definition Mainpage.dox:8