mxnet
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
dmlc::FunctionRegEntryBase< EntryType, FunctionType > Class Template Reference

Common base class for function registry. More...

#include <registry.h>

Collaboration diagram for dmlc::FunctionRegEntryBase< EntryType, FunctionType >:
Collaboration graph

Public Member Functions

EntryType & set_body (FunctionType body)
 Set the function body. More...
 
EntryType & describe (const std::string &description)
 Describe the function. More...
 
EntryType & add_argument (const std::string &name, const std::string &type, const std::string &description)
 Add argument information to the function. More...
 
EntryType & add_arguments (const std::vector< ParamFieldInfo > &args)
 Append list if arguments to the end. More...
 
EntryType & set_return_type (const std::string &type)
 Set the return type. More...
 

Public Attributes

std::string name
 name of the entry More...
 
std::string description
 description of the entry More...
 
std::vector< ParamFieldInfo > arguments
 additional arguments to the factory function More...
 
FunctionType body
 Function body to create ProductType. More...
 
std::string return_type
 Return type of the function. More...
 

Protected Member Functions

EntryType & self ()
 

Detailed Description

template<typename EntryType, typename FunctionType>
class dmlc::FunctionRegEntryBase< EntryType, FunctionType >

Common base class for function registry.

// This example demonstrates how to use Registry to create a factory of trees.
struct TreeFactory :
public FunctionRegEntryBase<TreeFactory, std::function<Tree*()> > {
};
// in a independent cc file
namespace dmlc {
DMLC_REGISTRY_ENABLE(TreeFactory);
}
// register binary tree constructor into the registry.
DMLC_REGISTRY_REGISTER(TreeFactory, TreeFactory, BinaryTree)
.describe("Constructor of BinaryTree")
.set_body([]() { return new BinaryTree(); });
Template Parameters
EntryTypeThe type of subclass that inheritate the base.
FunctionTypeThe function type this registry is registerd.

Member Function Documentation

template<typename EntryType, typename FunctionType>
EntryType& dmlc::FunctionRegEntryBase< EntryType, FunctionType >::add_argument ( const std::string &  name,
const std::string &  type,
const std::string &  description 
)
inline

Add argument information to the function.

Parameters
nameName of the argument.
typeType of the argument.
descriptionDescription of the argument.
Returns
reference to self.
template<typename EntryType, typename FunctionType>
EntryType& dmlc::FunctionRegEntryBase< EntryType, FunctionType >::add_arguments ( const std::vector< ParamFieldInfo > &  args)
inline

Append list if arguments to the end.

Parameters
argsAdditional list of arguments.
Returns
reference to self.
template<typename EntryType, typename FunctionType>
EntryType& dmlc::FunctionRegEntryBase< EntryType, FunctionType >::describe ( const std::string &  description)
inline

Describe the function.

Parameters
descriptionThe description of the factory function.
Returns
reference to self.
template<typename EntryType, typename FunctionType>
EntryType& dmlc::FunctionRegEntryBase< EntryType, FunctionType >::self ( )
inlineprotected
Returns
reference of self as derived type
template<typename EntryType, typename FunctionType>
EntryType& dmlc::FunctionRegEntryBase< EntryType, FunctionType >::set_body ( FunctionType  body)
inline

Set the function body.

Parameters
bodyFunction body to set.
Returns
reference to self.
template<typename EntryType, typename FunctionType>
EntryType& dmlc::FunctionRegEntryBase< EntryType, FunctionType >::set_return_type ( const std::string &  type)
inline

Set the return type.

Parameters
typeReturn type of the function, could be Symbol or Symbol[]
Returns
reference to self.

Member Data Documentation

template<typename EntryType, typename FunctionType>
std::vector<ParamFieldInfo> dmlc::FunctionRegEntryBase< EntryType, FunctionType >::arguments

additional arguments to the factory function

template<typename EntryType, typename FunctionType>
FunctionType dmlc::FunctionRegEntryBase< EntryType, FunctionType >::body

Function body to create ProductType.

template<typename EntryType, typename FunctionType>
std::string dmlc::FunctionRegEntryBase< EntryType, FunctionType >::description

description of the entry

template<typename EntryType, typename FunctionType>
std::string dmlc::FunctionRegEntryBase< EntryType, FunctionType >::name

name of the entry

template<typename EntryType, typename FunctionType>
std::string dmlc::FunctionRegEntryBase< EntryType, FunctionType >::return_type

Return type of the function.


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