Apache Singa
A General Distributed Deep Learning Library
Static Public Member Functions | List of all members
Factory< T, ID > Class Template Reference

Factory template to generate class (or a sub-class) object based on id. More...

#include <factory.h>

Static Public Member Functions

static void Register (const ID &id, const std::function< T *(void)> &creator)
 Register functions to create user defined classes. More...
 
static T * Create (const ID &id)
 create an instance by providing its id More...
 
static const std::vector< ID > GetIDs ()
 

Detailed Description

template<typename T, typename ID = std::string>
class Factory< T, ID >

Factory template to generate class (or a sub-class) object based on id.

  1. register class creation function that generates a class object based on id.
  2. call Create() func to call the creation function and return a pointer to the base calss.

Member Function Documentation

◆ Create()

template<typename T , typename ID = std::string>
static T* Factory< T, ID >::Create ( const ID &  id)
inlinestatic

create an instance by providing its id

Parameters
id

◆ Register()

template<typename T , typename ID = std::string>
static void Factory< T, ID >::Register ( const ID &  id,
const std::function< T *(void)> &  creator 
)
inlinestatic

Register functions to create user defined classes.

This function is called by the REGISTER_FACTORY macro.

Parameters
idIdentifier of the creating function/class
funca function that creates a layer instance

The documentation for this class was generated from the following file: