dignea  1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
RepFactory.h
Go to the documentation of this file.
1 
12 #ifndef __DIGNEA_REPFACTORY_H__
13 #define __DIGNEA_REPFACTORY_H__
14 
15 #include <dignea/core/Replacement.h>
16 #include <dignea/core/Solution.h>
20 #include <dignea/types/ReplacementTypes.h>
21 
28 template <class S>
29 class RepFactory {
30  private:
31  map<ReplacementTypes, function<unique_ptr<Replacement<S>>()>> factories;
32 
33  public:
34  RepFactory() {
35  factories[ReplacementTypes::Generational] = [] {
36  return make_unique<EGenerational<S>>();
37  };
38  factories[ReplacementTypes::FirstImprove] = [] {
39  return make_unique<FirstImprove<S>>();
40  };
41  factories[ReplacementTypes::ReplaceWorst] = [] {
42  return make_unique<ReplaceWorst<S>>();
43  };
44  }
45 
51  unique_ptr<Replacement<S>> create(ReplacementTypes type) {
52  return factories[type]();
53  }
54 };
55 
56 #endif // __DIGNEA_REPFACTORY_H__
Replacement Factory which allows the user to easily create Replacement Operators.
Definition: RepFactory.h:29
unique_ptr< Replacement< S > > create(ReplacementTypes type)
Creates a unique pointer to a Selection Operator of type.
Definition: RepFactory.h:51