-
Notifications
You must be signed in to change notification settings - Fork 0
/
trafficgeneratorfactory.h
67 lines (54 loc) · 1.63 KB
/
trafficgeneratorfactory.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
/*
* trafficgeneratorfactory.h
* PhoenixSim
*
* Created by Johnnie Chan on 7/8/11.
* Copyright 2011 Johnnie Chan. All rights reserved.
*
*/
/*
* routingpolicyfactory.h
* PhoenixSim
*
* Created by Johnnie Chan on 6/23/11.
* Copyright 2011 Johnnie Chan. All rights reserved.
*
* This is the object factory for all routing policy objects.
*/
#ifndef __TRAFFICGENERATORFACTORY_H__
#define __TRAFFICGENERATORFACTORY_H__
#include <string>
#include <map>
#include "trafficgenerator.h"
namespace PhoenixSim
{
class TrafficGeneratorFactoryDemolisher;
class TrafficGeneratorFactory
{
public:
typedef TrafficGenerator* (*CreateTrafficGeneratorCallback)();
bool RegisterTrafficGenerator(CreateTrafficGeneratorCallback createFunction, std::string identifier);
bool UnregisterTrafficGenerator(std::string identifier);
TrafficGenerator* CreateTrafficGenerator(std::string identifier);
static TrafficGeneratorFactory* Instance();
private:
typedef std::map<std::string, CreateTrafficGeneratorCallback> CreateTrafficGeneratorMap;
CreateTrafficGeneratorMap callbackFunctions;
TrafficGeneratorFactory();
TrafficGeneratorFactory(const TrafficGeneratorFactory&);
~TrafficGeneratorFactory();
static TrafficGeneratorFactory* instance;
friend class TrafficGeneratorFactoryDemolisher;
static TrafficGeneratorFactoryDemolisher demolisher;
};
class TrafficGeneratorFactoryDemolisher
{
public:
TrafficGeneratorFactoryDemolisher();
~TrafficGeneratorFactoryDemolisher();
void SetInstancePointer(TrafficGeneratorFactory* p);
private:
TrafficGeneratorFactory* instance;
};
}
#endif // __TRAFFICGENERATORFACTORY_H__