ModErn Text Analysis
META Enumerates Textual Applications
analyzer_factory.h
Go to the documentation of this file.
1 
10 #ifndef META_ANALYZER_FACTORY_H_
11 #define META_ANALYZER_FACTORY_H_
12 
13 #include "analyzers/analyzer.h"
14 #include "util/factory.h"
15 #include "util/shim.h"
16 
17 namespace cpptoml
18 {
19 class table;
20 }
21 
22 namespace meta
23 {
24 namespace analyzers
25 {
26 
33  : public util::factory<analyzer_factory, analyzer, const cpptoml::table&,
34  const cpptoml::table&>
35 {
37  friend base_factory;
38 
39  private:
44 
49  template <class Analyzer>
50  void register_analyzer();
51 
53  std::unordered_map<std::string, factory_method> methods_;
54 };
55 
60 template <class Analyzer>
61 std::unique_ptr<analyzer> make_analyzer(const cpptoml::table&,
62  const cpptoml::table&)
63 {
64  return make_unique<Analyzer>();
65 }
66 
71 template <class Analyzer>
73 {
74  analyzer_factory::get().add(Analyzer::id, make_analyzer<Analyzer>);
75 }
76 }
77 }
78 #endif
void register_analyzer()
Adds (registers) an analyzer with this factory so it is able to be created.
Definition: analyzer_factory.cpp:15
Factory that is responsible for creating analyzers from configuration files.
Definition: analyzer_factory.h:32
void add(const std::string &identifier, Function &&fn)
Associates the given identifier with the given factory method.
Definition: factory.h:61
analyzer_factory()
Constructor.
Definition: analyzer_factory.cpp:20
void register_analyzer()
Registration method for analyzers.
Definition: analyzer_factory.h:72
Generic factory that can be subclassed to create factories for specific types.
Definition: factory.h:27
static analyzer_factory & get()
Obtains the singleton.
Definition: factory.h:48
std::unique_ptr< analyzer > make_analyzer(const cpptoml::table &, const cpptoml::table &)
Factory method for creating an analyzer.
Definition: analyzer_factory.h:61
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
std::unordered_map< std::string, factory_method > methods_
maps id strings to the factory method used to create that class
Definition: analyzer_factory.h:53
Definition: analyzer.h:19
friend base_factory
friend the base class
Definition: analyzer_factory.h:37