summaryrefslogtreecommitdiff
path: root/decoder/ff_factory.h
diff options
context:
space:
mode:
Diffstat (limited to 'decoder/ff_factory.h')
-rw-r--r--decoder/ff_factory.h38
1 files changed, 8 insertions, 30 deletions
diff --git a/decoder/ff_factory.h b/decoder/ff_factory.h
index bfdd3257..1aa8e55f 100644
--- a/decoder/ff_factory.h
+++ b/decoder/ff_factory.h
@@ -1,8 +1,6 @@
#ifndef _FF_FACTORY_H_
#define _FF_FACTORY_H_
-// FsaF* vs F* (regular ff/factory).
-
//TODO: use http://www.boost.org/doc/libs/1_43_0/libs/functional/factory/doc/html/index.html ?
/*TODO: register state identity separately from feature function identity? as
@@ -25,13 +23,15 @@ class FeatureFunction;
class FsaFeatureFunction;
-struct UntypedFactory {
+class UntypedFactory {
+ public:
virtual ~UntypedFactory();
virtual std::string usage(bool params,bool verbose) const = 0;
};
template <class FF>
-struct FactoryBase : public UntypedFactory {
+class FactoryBase : public UntypedFactory {
+ public:
typedef FF F;
typedef boost::shared_ptr<F> FP;
@@ -40,7 +40,8 @@ struct FactoryBase : public UntypedFactory {
/* see cdec_ff.cc for example usage: this create concrete factories to be registered */
template<class FF>
-struct FFFactory : public FactoryBase<FeatureFunction> {
+class FFFactory : public FactoryBase<FeatureFunction> {
+ public:
FP Create(std::string param) const {
FF *ret=new FF(param);
return FP(ret);
@@ -51,18 +52,6 @@ struct FFFactory : public FactoryBase<FeatureFunction> {
};
-// same as above, but we didn't want to require a typedef e.g. Parent in FF class, and template typedef isn't available
-template<class FF>
-struct FsaFactory : public FactoryBase<FsaFeatureFunction> {
- FP Create(std::string param) const {
- FF *ret=new FF(param);
- return FP(ret);
- }
- virtual std::string usage(bool params,bool verbose) const {
- return FF::usage(params,verbose);
- }
-};
-
struct UntypedFactoryRegistry {
std::string usage(std::string const& ffname,bool params=true,bool verbose=true) const;
bool have(std::string const& ffname);
@@ -70,7 +59,6 @@ struct UntypedFactoryRegistry {
void Register(const std::string& ffname, UntypedFactory* factory);
void Register(UntypedFactory* factory);
void clear();
- static bool parse_debug(std::string & param_in_out); // returns true iff param starts w/ debug (and remove that prefix from param)
protected:
typedef boost::shared_ptr<UntypedFactory> FactoryP;
typedef std::map<std::string, FactoryP > Factmap;
@@ -92,26 +80,16 @@ struct FactoryRegistry : public UntypedFactoryRegistry {
Factmap::const_iterator it = reg_.find(ffname);
if (it == reg_.end())
throw std::runtime_error("I don't know how to create feature "+ffname);
- bool debug=parse_debug(param);
- if (debug)
- cerr<<"debug enabled for "<<ffname<< " - remaining options: '"<<param<<"'\n";
FP res = dynamic_cast<FB const&>(*it->second).Create(param);
return res;
}
};
typedef FactoryRegistry<FeatureFunction> FFRegistry;
-typedef FactoryRegistry<FsaFeatureFunction> FsaFFRegistry;
-extern FsaFFRegistry fsa_ff_registry;
-inline FsaFFRegistry & global_fsa_ff_registry() { return fsa_ff_registry; }
extern FFRegistry ff_registry;
-inline FFRegistry & global_ff_registry() { return ff_registry; }
+inline FFRegistry& global_ff_registry() { return ff_registry; }
-void ff_usage(std::string const& name,std::ostream &out=std::cout);
+void ff_usage(std::string const& name,std::ostream& out=std::cerr);
-/*
-extern boost::shared_ptr<FsaFFRegistry> global_fsa_ff_registry;
-extern boost::shared_ptr<FFRegistry> global_ff_registry;
-*/
#endif