Reranker Framework (ReFr)
Reranking framework for structure prediction and discriminative language modeling
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros
factory.H File Reference

Provides a generic dynamic object factory. More...

#include <iostream>
#include <sstream>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stdexcept>
#include "stream-tokenizer.H"
#include "environment.H"

Go to the source code of this file.

Classes

class  reranker::TypeName< T >
 We use the templated class TypeName to be able to take an actual C++ type and get the type name string used by the Interpreter and Environment classes. More...
 
class  reranker::TypeName< bool >
 A partial specialization so that an object of type bool converts to "bool". More...
 
class  reranker::TypeName< int >
 A partial specialization so that an object of type int converts to "int". More...
 
class  reranker::TypeName< double >
 A partial specialization so that an object of type double converts to "double". More...
 
class  reranker::TypeName< string >
 A partial specialization so that an object of type string converts to "string". More...
 
class  reranker::TypeName< shared_ptr< T > >
 A partial specialization so that an object of type shared_ptr<T>, where T is some Factory-constructible type, converts to the string produced by TypeName<T>. More...
 
class  reranker::TypeName< vector< T > >
 A partial specialization so that an object of type vector<T> gets converted to the type name of T followed by the string "[]", equivalent to the result of executing the following expression: More...
 
class  reranker::MemberInitializer
 An interface for initializers of members of a Factory-constructible object. More...
 
class  reranker::TypedMemberInitializer< T >
 
class  reranker::Initializers
 A container for all the member initializers for a particular Factory-constructible instance. More...
 
class  reranker::FactoryBase
 An interface for all Factory instances, specifying a few pure virtual methods. More...
 
class  reranker::FactoryContainer
 A class to hold all Factory instances that have been created. More...
 
class  reranker::Constructor< T >
 An interface with a single virtual method that constructs a concrete instance of the abstract type T. More...
 
class  reranker::FactoryConstructible
 An interface to make it easier to implement Factory-constructible types by implementing both required methods to do nothing. More...
 
class  reranker::Factory< T >
 Factory for dynamically created instance of the specified type. More...
 

Namespaces

 reranker
 Provides reranking models for discriminative modeling, with some special handling for discriminative language models.
 

Macros

#define DEFINE_CONS_CLASS(TYPE, NAME, BASE)
 A macro to define a subclass of Constructor whose NewInstance method constructs an instance of TYPE, a concrete subclass of BASE. More...
 
#define REGISTER_NAMED(TYPE, NAME, BASE)
 This macro registers the concrete subtype TYPE with the specified factory for instances of type BASE; the TYPE is associated with the specified NAME. More...
 
#define IMPLEMENT_FACTORY(BASE)
 Provides the necessary implementation for a factory for the specified BASE class type. More...
 

Detailed Description

Provides a generic dynamic object factory.

Author
dbike.nosp@m.l@go.nosp@m.ogle..nosp@m.com (Dan Bikel)

Definition in file factory.H.

Macro Definition Documentation

#define DEFINE_CONS_CLASS (   TYPE,
  NAME,
  BASE 
)
Value:
class NAME ## Constructor : public Constructor<BASE> { \
public: virtual BASE *NewInstance() const { return new TYPE(); } };

A macro to define a subclass of Constructor whose NewInstance method constructs an instance of TYPE, a concrete subclass of BASE.

The concrete subclass TYPE must have a no-argument constructor. This is a helper macro used only by the REGISTER macro.

Definition at line 800 of file factory.H.

#define IMPLEMENT_FACTORY (   BASE)
Value:
template<> int Factory<BASE>::initialized_ = 0; \
template<> unordered_map<string, const Constructor<BASE> *> * \
Factory<BASE>::cons_table_ = 0; \
template<> const char *Factory<BASE>::base_name_ = #BASE;

Provides the necessary implementation for a factory for the specified BASE class type.

Definition at line 821 of file factory.H.

#define REGISTER_NAMED (   TYPE,
  NAME,
  BASE 
)
Value:
DEFINE_CONS_CLASS(TYPE,NAME,BASE) \
const Constructor<BASE> *NAME ## _my_protoype = \
Factory<BASE>::Register(string(#NAME), new NAME ## Constructor());
#define DEFINE_CONS_CLASS(TYPE, NAME, BASE)
A macro to define a subclass of Constructor whose NewInstance method constructs an instance of TYPE...
Definition: factory.H:800

This macro registers the concrete subtype TYPE with the specified factory for instances of type BASE; the TYPE is associated with the specified NAME.

This macro—or a macro defined using this macro—should be used in the implementation file for a concrete subclass TYPE of the baseclass BASE. Often, TYPE and NAME may be the exact same string; however, they must be different when TYPE contains characters that may not appear in C++ identifiers, such as colons (e.g., when TYPE is the fully-qualified name of an inner class).

Definition at line 814 of file factory.H.