provider_type_register.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 ** (if your name is missing here, please add it)
28 */
29
30
31 #pragma once
32
33 #include "../../Core/IOData/file_system.h"
34 #include "provider_type.h"
35
36 namespace clan
37 {
40
43 template<class ProviderClass>
44 class ProviderType_Register : public ImageProviderType
45 {
48
49 public:
51 ProviderType_Register(const std::string &type) : ImageProviderType(type)
52 {
53 }
54
58
59 public:
61 virtual PixelBuffer load(
62 const std::string &filename,
63 const FileSystem &fs,
64 bool srgb) override
65 {
66 return ProviderClass::load(filename, fs, srgb);
67 }
68
69 virtual PixelBuffer load(
70 IODevice &file,
71 bool srgb) override
72 {
73 return ProviderClass::load(file, srgb);
74 }
75
76 virtual void save(
77 PixelBuffer buffer,
78 const std::string &filename,
79 FileSystem &fs) override
80 {
81 ProviderClass::save(buffer, filename, fs);
82 }
83
84 virtual void save(
85 PixelBuffer buffer,
86 IODevice &file) override
87 {
88 ProviderClass::save(buffer, file);
89 }
90
92 };
93
94 }
95
clan
Definition: clanapp.h:35
clan::IODevice
I/O Device interface.
Definition: iodevice.h:50
clan::PixelBuffer
Pixel data container.
Definition: pixel_buffer.h:68
clan::ProviderType_Register::save
virtual void save(PixelBuffer buffer, IODevice &file) override
Definition: provider_type_register.h:84
clan::ProviderType_Register::ProviderType_Register
ProviderType_Register(const std::string &type)
Registers provider type in the ProviderFactory.
Definition: provider_type_register.h:51
clan::ProviderType_Register::load
virtual PixelBuffer load(const std::string &filename, const FileSystem &fs, bool srgb) override
Called to load an image with this provider type.
Definition: provider_type_register.h:61
clan::StyleTokenType::string
@ keyword
clan::ImageProviderType
Provider type.
Definition: provider_type.h:44
clan::ProviderType_Register::save
virtual void save(PixelBuffer buffer, const std::string &filename, FileSystem &fs) override
Called to save a given PixelBuffer to a file.
Definition: provider_type_register.h:76
clan::ProviderType_Register
Class template to register a provider type.
Definition: provider_type_register.h:44
clan::FileSystem
Virtual File System (VFS).
Definition: file_system.h:47
clan::ProviderType_Register::load
virtual PixelBuffer load(IODevice &file, bool srgb) override
Definition: provider_type_register.h:69