-
Notifications
You must be signed in to change notification settings - Fork 0
/
layer_register.h
42 lines (34 loc) · 975 Bytes
/
layer_register.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
#ifndef LAYER_REGISTER_H
#define LAYER_REGISTER_H
#include <vector>
#include <map>
#include <string>
using namespace std;
#include "layer.h"
class LayerRegister
{
public:
typedef int (*Creator)(Layer* &layer);
typedef map<string, Creator> CreatorRegistry;
static CreatorRegistry *_registry;
static CreatorRegistry* Registry();
static void RegisterCreator(const string& layer_type, const Creator &creator);
static void CreateLayer(const string& layer_type, Layer* &layer);
};
class LayerRegistererWrapper
{
public:
explicit LayerRegistererWrapper(const string& layer_type, const LayerRegister::Creator& creator)
{
LayerRegister::RegisterCreator(layer_type, creator);
}
};
class CreateLayerWrapper
{
public:
explicit CreateLayerWrapper(const string& layer_type, Layer* &layer)
{
LayerRegister::CreateLayer(layer_type, layer);
}
};
#endif