Factory template to generate class (or a sub-class) object based on id.
More...
#include <factory.h>
|
void | Register (const std::string &id, const std::function< T *(void)> &func) |
| Register functions to create user defined classes. More...
|
|
void | Register (int id, const std::function< T *(void)> &func) |
| Register functions to create user defined classes. More...
|
|
T * | Create (const std::string &id) |
| create an instance by providing its id More...
|
|
T * | Create (int id) |
| create an instance by providing its id More...
|
|
template<typename T>
class Factory< T >
Factory template to generate class (or a sub-class) object based on id.
- register class creation function that generates a class object based on id.
- call Create() func to call the creation function and return a pointer to the base calss.
template<typename T >
T* Factory< T >::Create |
( |
const std::string & |
id | ) |
|
|
inline |
create an instance by providing its id
- Parameters
-
create an instance by providing its id
- Parameters
-
template<typename T >
void Factory< T >::Register |
( |
const std::string & |
id, |
|
|
const std::function< T *(void)> & |
func |
|
) |
| |
|
inline |
Register functions to create user defined classes.
This function is called by the REGISTER_FACTORY macro.
- Parameters
-
id | Identifier of the creating function/class |
func | a function that creates a layer instance |
template<typename T >
void Factory< T >::Register |
( |
int |
id, |
|
|
const std::function< T *(void)> & |
func |
|
) |
| |
|
inline |
Register functions to create user defined classes.
This function is called by the REGISTER_FACTORY macro.
- Parameters
-
id | Identifier of the creating function/class |
func | a function that creates a layer instance |
The documentation for this class was generated from the following file:
- /home/wangwei/program/asf/release-0.1/apache-singa-incubating-0.1.0-RC1/include/utils/factory.h