35#ifndef VP_DYNAMIC_FACTORY_H
36#define VP_DYNAMIC_FACTORY_H
38#include <visp3/core/vpConfig.h>
39#include <visp3/core/vpException.h>
41#if defined(VISP_HAVE_NLOHMANN_JSON)
42#include VISP_NLOHMANN_JSON(json.hpp)
58#if defined(VISP_HAVE_NLOHMANN_JSON)
59 void registerType(
const std::string &key,
const std::function<std::shared_ptr<T>(
const nlohmann::json &)> &function)
67 void registerTypeRaw(
const std::string &key,
const std::function<std::shared_ptr<T>(
const std::string &)> function)
95 void setJsonKeyFinder(
const std::function<std::string(
const nlohmann::json &)> &finderFn)
106#if defined(VISP_HAVE_NLOHMANN_JSON)
107 std::map<std::string, std::function<std::shared_ptr<T>(
const nlohmann::json &)>>
m_jsonBuilders;
108 std::map<std::string, std::function<std::shared_ptr<T>(
const std::string &)>>
m_jsonRawBuilders;
void setJsonKeyFinder(const std::function< std::string(const nlohmann::json &)> &finderFn)
std::function< std::string(const nlohmann::json &)> m_keyFinder
std::shared_ptr< T > buildFromJson(const nlohmann::json &j)
void registerType(const std::string &key, const std::function< std::shared_ptr< T >(const nlohmann::json &)> &function)
std::map< std::string, std::function< std::shared_ptr< T >(const std::string &)> > m_jsonRawBuilders
vpDynamicFactory()=default
std::map< std::string, std::function< std::shared_ptr< T >(const nlohmann::json &)> > m_jsonBuilders
virtual ~vpDynamicFactory()
void registerTypeRaw(const std::string &key, const std::function< std::shared_ptr< T >(const std::string &)> function)
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.