forked from yogykwan/design-patterns-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflyweight.h
More file actions
45 lines (36 loc) · 710 Bytes
/
flyweight.h
File metadata and controls
45 lines (36 loc) · 710 Bytes
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
//
// Created by Jennica on 2016/12/29.
//
#ifndef DESIGN_PATTERNS_FLYWEIGHT_H
#define DESIGN_PATTERNS_FLYWEIGHT_H
#include <map>
#include <string>
class User {
public:
User() {}
User(std::string);
std::string GetName();
private:
std::string name_;
};
class Website {
public:
virtual void Use(User *) = 0;
};
class ConcreteWebsite: public Website {
public:
ConcreteWebsite() {}
ConcreteWebsite(std::string);
void Use(User *);
private:
std::string website_name_;
};
class WebsiteFactory {
public:
~WebsiteFactory();
Website* GetWebsiteCategory(std::string);
int GetWebsiteCount();
private:
std::map <std::string, Website*> flyweights_;
};
#endif //DESIGN_PATTERNS_FLYWEIGHT_H