Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpDynamicFactory< T > Class Template Reference

#include <vpDynamicFactory.h>

Public Member Functions

void registerType (const std::string &key, const std::function< std::shared_ptr< T >(const nlohmann::json &)> &function)
void registerTypeRaw (const std::string &key, const std::function< std::shared_ptr< T >(const std::string &)> function)
std::shared_ptr< T > buildFromJson (const nlohmann::json &j)
void setJsonKeyFinder (const std::function< std::string(const nlohmann::json &)> &finderFn)
virtual ~vpDynamicFactory ()

Protected Member Functions

 vpDynamicFactory ()=default

Protected Attributes

std::map< std::string, std::function< std::shared_ptr< T >(const nlohmann::json &)> > m_jsonBuilders
std::map< std::string, std::function< std::shared_ptr< T >(const std::string &)> > m_jsonRawBuilders
std::function< std::string(const nlohmann::json &)> m_keyFinder

Detailed Description

template<typename T>
class vpDynamicFactory< T >

Factory-type class that allows for the dynamic registration of subclasses.

Template Parameters
TThe subclass type

Definition at line 55 of file vpDynamicFactory.h.

Constructor & Destructor Documentation

◆ ~vpDynamicFactory()

template<typename T>
virtual vpDynamicFactory< T >::~vpDynamicFactory ( )
inlinevirtual

Definition at line 101 of file vpDynamicFactory.h.

◆ vpDynamicFactory()

template<typename T>
vpDynamicFactory< T >::vpDynamicFactory ( )
protecteddefault

Member Function Documentation

◆ buildFromJson()

template<typename T>
std::shared_ptr< T > vpDynamicFactory< T >::buildFromJson ( const nlohmann::json & j)
inline

Definition at line 78 of file vpDynamicFactory.h.

References m_jsonBuilders, m_jsonRawBuilders, and m_keyFinder.

Referenced by vpRBTracker::loadConfiguration().

◆ registerType()

template<typename T>
void vpDynamicFactory< T >::registerType ( const std::string & key,
const std::function< std::shared_ptr< T >(const nlohmann::json &)> & function )
inline

Definition at line 59 of file vpDynamicFactory.h.

References vpException::badValue, m_jsonBuilders, and m_jsonRawBuilders.

◆ registerTypeRaw()

template<typename T>
void vpDynamicFactory< T >::registerTypeRaw ( const std::string & key,
const std::function< std::shared_ptr< T >(const std::string &)> function )
inline

Definition at line 67 of file vpDynamicFactory.h.

References vpException::badValue, m_jsonBuilders, and m_jsonRawBuilders.

◆ setJsonKeyFinder()

template<typename T>
void vpDynamicFactory< T >::setJsonKeyFinder ( const std::function< std::string(const nlohmann::json &)> & finderFn)
inline

Definition at line 95 of file vpDynamicFactory.h.

References m_keyFinder.

Member Data Documentation

◆ m_jsonBuilders

template<typename T>
std::map<std::string, std::function<std::shared_ptr<T>(const nlohmann::json &)> > vpDynamicFactory< T >::m_jsonBuilders
protected

Definition at line 107 of file vpDynamicFactory.h.

Referenced by buildFromJson(), registerType(), and registerTypeRaw().

◆ m_jsonRawBuilders

template<typename T>
std::map<std::string, std::function<std::shared_ptr<T>(const std::string &)> > vpDynamicFactory< T >::m_jsonRawBuilders
protected

Definition at line 108 of file vpDynamicFactory.h.

Referenced by buildFromJson(), registerType(), and registerTypeRaw().

◆ m_keyFinder

template<typename T>
std::function<std::string(const nlohmann::json &)> vpDynamicFactory< T >::m_keyFinder
protected

Definition at line 110 of file vpDynamicFactory.h.

Referenced by buildFromJson(), and setJsonKeyFinder().