-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilterFactory.cpp
More file actions
46 lines (40 loc) · 1.09 KB
/
Copy pathFilterFactory.cpp
File metadata and controls
46 lines (40 loc) · 1.09 KB
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
#include "FilterFactory.h"
// Static dictionary of all available filters
std::map<MyString, Filter*> FilterFactory::filtersLibrary = {
{MyString("Blur"), new BlurFilter()},
{MyString("Contrast"), new ContrastFilter()},
{MyString("Sharpen"), new SharpenFilter()},
{MyString("Negative"), new NegativeFilter()},
{MyString("Threshold"), new ThresholdFilter()},
{MyString("ContrastNorm"), new ContrastNormalizationFilter()},
{MyString("Contour"), new ContourFilter()},
};
FilterFactory::FilterFactory()
{
}
// Destructor - frees memory of all filters in the dictionary
FilterFactory::~FilterFactory()
{
for (auto filter : filtersLibrary) {
delete filter.second;
}
}
FilterFactory& FilterFactory::getInstance()
{
static FilterFactory instance;
return instance;
}
// Returns filter by name
Filter* FilterFactory::getByName(MyString name)
{
return filtersLibrary[name];
}
// Returns the list of names of all available filters
MyVector<MyString> FilterFactory::getAvailableFilterNames()
{
MyVector<MyString> names;
for (const auto& pair : filtersLibrary) {
names.push_back(pair.first);
}
return names;
}