-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAgentFactory.h
49 lines (47 loc) · 882 Bytes
/
AgentFactory.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
#pragma once
#include <iostream>
#include <vector>
#include <string>
#include "Agent.h"
#include "Thug.h"
#include "Peasant.h"
#include "Knight.h"
#include <memory>
using namespace std;
class AgentFactory
{
public:
AgentFactory(){}
AgentFactory& operator=(const AgentFactory& rhs);
AgentFactory(const AgentFactory& rhs);
enum TYPE
{
PEASANT, KNIGHT, THUG
};
template <typename T>
shared_ptr<Agent> createVehicle(const AgentFactory::TYPE &_enumType, T _parmater)
{
shared_ptr<Agent> pAgent = nullptr;
switch (_enumType)
{
case AgentFactory::PEASANT:
{
pAgent = make_shared<Peasant>(_parmater);
break;
}
case AgentFactory::KNIGHT :
{
pAgent = make_shared<Knight>(_parmater);
break;
}
case AgentFactory::THUG :
{
pAgent = make_shared<Thug>(_parmater);
break;
}
default:
return pAgent;
}
return pAgent;
}
};