ModErn Text Analysis
META Enumerates Textual Applications
ranker_factory.h
Go to the documentation of this file.
1 
9 #ifndef META_RANKER_FACTORY_H_
10 #define META_RANKER_FACTORY_H_
11 
12 #include "index/ranker/ranker.h"
13 #include "util/factory.h"
14 #include "util/shim.h"
15 
16 namespace cpptoml
17 {
18 class table;
19 }
20 
21 namespace meta
22 {
23 namespace index
24 {
25 
31 class ranker_factory : public util::factory<ranker_factory,
32  ranker, const cpptoml::table&>
33 {
35  friend base_factory;
36 
37  private:
42 
46  template <class Ranker>
47  void reg();
48 };
49 
53 std::unique_ptr<ranker> make_ranker(const cpptoml::table&);
54 
60 template <class Ranker>
61 std::unique_ptr<ranker> make_ranker(const cpptoml::table&)
62 {
63  return make_unique<Ranker>();
64 }
65 
70 template <class Ranker>
72 {
73  ranker_factory::get().add(Ranker::id, make_ranker<Ranker>);
74 }
75 
76 }
77 }
78 #endif
void add(const std::string &identifier, Function &&fn)
Associates the given identifier with the given factory method.
Definition: factory.h:61
void register_ranker()
Registration method for rankers.
Definition: ranker_factory.h:71
Factory that is responsible for creating rankers from configuration files.
Definition: ranker_factory.h:31
Generic factory that can be subclassed to create factories for specific types.
Definition: factory.h:27
std::unique_ptr< ranker > make_ranker(const cpptoml::table &)
Convenience method for creating a ranker using the factory.
Definition: ranker_factory.h:61
static ranker_factory & get()
Obtains the singleton.
Definition: factory.h:48
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
ranker_factory()
Constructor.
Definition: ranker_factory.cpp:21
void reg()
Registers a ranking function.
Definition: ranker_factory.cpp:16
Definition: analyzer.h:19
friend base_factory
Friend the base ranker factory.
Definition: ranker_factory.h:35