Classes | |
class | minxlib::factory_map< K, F, D > |
A registry mapping keys to factory functions. More... | |
class | minxlib::factory< T, K, F, M > |
Object factory for subclasses of type T. More... | |
Functions | |
template<typename B , typename D > | |
B * | minxlib::create_object () |
Create object of type D using new operator and upcast to B. More... | |
template<typename B , typename D , typename A1 > | |
B * | minxlib::create_object (A1 a1) |
Create object of type D using new operator and upcast to B. More... | |
template<typename B , typename D , typename A1 , typename A2 > | |
B * | minxlib::create_object (A1 a1, A2 a2) |
Create object of type D using new operator and upcast to B. More... | |
This file defines classes that provide a generic object factory framework for use in other parts of minxlib.
Here is a sample program illustrating how this framework is meant to be used:
The above code shows classes that are created using their default constructors. The factory::create() methods and create_object() functions have overloads that support up to two arguments.
Moreover, the above sample program does not illustrate the factory_map's support for storing arbitrary, client-supplied data for each class. See the implementations of minxlib::event (in event.hh and event.cc) and minxlib::protocol_error (exception.{hh,cc}) for the low-down on that feature.
B* minxlib::create_object | ( | ) |
Create object of type D using new operator and upcast to B.
When using this object factory framework, more often than not, client classes will need a factory function to create a concrete type. Usually, these factory functions all follow the same pattern. Thus, instead of each client supplying its own factory function, we define this template function that different class hierarchies can use. The sample code at the beginning of this file illustrates how these factory functions can be used.
B* minxlib::create_object | ( | A1 | a1) |
Create object of type D using new operator and upcast to B.
a1 | First constructor argument. |
When using this object factory framework, more often than not, client classes will need a factory function to create a concrete type. Usually, these factory functions all follow the same pattern. Thus, instead of each client supplying its own factory function, we define this template function that different class hierarchies can use. The sample code at the beginning of this file illustrates how these factory functions can be used.
B* minxlib::create_object | ( | A1 | a1, |
A2 | a2 | ||
) |
Create object of type D using new operator and upcast to B.
a1 | First constructor argument. |
a2 | Second constructor argument. |
When using this object factory framework, more often than not, client classes will need a factory function to create a concrete type. Usually, these factory functions all follow the same pattern. Thus, instead of each client supplying its own factory function, we define this template function that different class hierarchies can use. The sample code at the beginning of this file illustrates how these factory functions can be used.