-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextures.h
More file actions
57 lines (46 loc) · 1.34 KB
/
Textures.h
File metadata and controls
57 lines (46 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <string>
#include <memory>
class ITexture {
public:
virtual ~ITexture() = default;
virtual std::string valeur() const = 0;
};
class TextureVide : public ITexture {
public:
std::string valeur() const override { return ""; }
};
class TextureSimple : public ITexture {
public:
explicit TextureSimple(const std::string& s) : symbole_(s) {}
std::string valeur() const override { return symbole_; }
private:
std::string symbole_;
};
class TextureLibre : public ITexture {
public:
explicit TextureLibre(const std::string& v) : valeur_(v) {}
std::string valeur() const override { return valeur_; }
private:
std::string valeur_;
};
class TextureDecorateur : public ITexture {
public:
explicit TextureDecorateur(std::unique_ptr<ITexture> interne)
: interne_(std::move(interne)) {}
protected:
std::unique_ptr<ITexture> interne_;
};
class TextureMix : public TextureDecorateur {
public:
TextureMix(std::unique_ptr<ITexture> interne,
std::unique_ptr<ITexture> extra)
: TextureDecorateur(std::move(interne)),
extra_(std::move(extra)) {}
std::string valeur() const override {
return interne_->valeur() + extra_->valeur();
}
private:
std::unique_ptr<ITexture> extra_;
};
std::unique_ptr<ITexture> creerTextureDepuisString(const std::string& txt);