diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-04-16 22:42:24 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-04-16 22:42:24 -0400 |
commit | fa80a23079d642a3e984712c9dfa9ac47d2457fa (patch) | |
tree | bdeb67e02ce15c27e2dd0ad3e69dcbfe52e9edd9 /rst_parser/arc_ff_factory.h | |
parent | 8aff3bd109b82b57c32a0b14a019c99c1ec35705 (diff) |
refactor some code, simplify, fix typos
Diffstat (limited to 'rst_parser/arc_ff_factory.h')
-rw-r--r-- | rst_parser/arc_ff_factory.h | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/rst_parser/arc_ff_factory.h b/rst_parser/arc_ff_factory.h deleted file mode 100644 index 4237fd5d..00000000 --- a/rst_parser/arc_ff_factory.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _ARC_FF_FACTORY_H_ -#define _ARC_FF_FACTORY_H_ - -#include <string> -#include <map> -#include <boost/shared_ptr.hpp> - -struct ArcFFFactoryBase { - virtual boost::shared_ptr<ArcFeatureFunction> Create(const std::string& param) const = 0; -}; - -template<class FF> -struct ArcFFFactory : public ArcFFFactoryBase { - boost::shared_ptr<ArcFeatureFunction> Create(const std::string& param) const { - return boost::shared_ptr<ArcFeatureFunction>(new FF(param)); - } -}; - -struct ArcFFRegistry { - boost::shared_ptr<ArcFeatureFunction> Create(const std::string& name, const std::string& param) const { - std::map<std::string, ArcFFFactoryBase*>::const_iterator it = facts.find(name); - assert(it != facts.end()); - return it->second->Create(param); - } - - void Register(const std::string& name, ArcFFFactoryBase* fact) { - ArcFFFactoryBase*& f = facts[name]; - assert(f == NULL); - f = fact; - } - std::map<std::string, ArcFFFactoryBase*> facts; -}; - -std::ostream& operator<<(std::ostream& os, const ArcFFRegistry& reg) { - for (std::map<std::string, ArcFFFactoryBase*>::const_iterator it = reg.facts.begin(); - it != reg.facts.end(); ++it) { - os << " " << it->first << std::endl; - } - return os; -} - -#endif |