-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlyFactory.h
91 lines (74 loc) · 2.47 KB
/
FlyFactory.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef FLYFACTORY_H
#define FLYFACTORY_H
#include"Pesado.h"
#include<vector>
class FlyFactory{
private:
static FlyFactory * instancia;
vector<shared_ptr<Pesado>> listaPesada;
vector<pair<string,string>> tipos_and_urls;
FlyFactory(){}
public:
static FlyFactory* getInstance(){
if(instancia==nullptr){
instancia=new FlyFactory();
}
return instancia;
}
shared_ptr<Texture> getInstancia(string tipo){
for(auto tipos: tipos_and_urls){
if(tipos.first==tipo){
for(auto elemento : listaPesada){
if(elemento->mismoTipo(tipo)){
return elemento->getInstancia();
}
}
listaPesada.push_back(make_shared<Pesado>(tipos.second,tipo));
return listaPesada.back()->getInstancia();
}else{
continue;
}
}
return nullptr;
}
void agregarTipos(string tipo,string url){
tipos_and_urls.push_back(make_pair(tipo,url));
}
void getElementos()const{
cout << "La fabrica tiene :" << listaPesada.size() << " elementos " << endl;
}
};
FlyFactory * FlyFactory::instancia=nullptr;
#endif // FLYFACTORY_H
/*
class FlyFactory{
private:
vector<shared_ptr<Pesado>> listaPesada;
vector<pair<string,string>> tipos_and_urls;
public:
FlyFactory(){}
shared_ptr<Texture> getInstancia(string tipo){
for(auto tipos: tipos_and_urls){
if(tipos.first==tipo){
for(auto elemento : listaPesada){
if(elemento->mismoTipo(tipo)){
return elemento->getInstancia();
}
}
listaPesada.push_back(make_shared<Pesado>(tipos.second,tipo));
return listaPesada.back()->getInstancia();
}else{
continue;
}
}
return nullptr;
}
void agregarTipos(string tipo,string url){
tipos_and_urls.push_back(make_pair(tipo,url));
}
void getElementos()const{
cout << "La fabrica tiene :" << listaPesada.size() << " elementos " << endl;
}
};
#endif // FLYFACTORY_H
*/