#pragma once #include "atomicsharedptr.hpp" #include "tofrom_string.hpp" #include #include #include template class FuncWrapper : public ToFromString { private: AtomicSharedPtr _impl; public: explicit FuncWrapper(const std::string &name_) { _impl.store(FactoryType::make(name_)); assert(not _impl.is_null()); } public: ReturnType operator()(Args&&... args) { return _impl(std::forward(args)...); //return _impl(args...); } public: std::string to_string() const { return std::string{_impl.load()->name()}; } int from_string(const std::string_view str_) { std::shared_ptr p; p = FactoryType::make(str_); if(!p) return -EINVAL; _impl.store(p); return 0; } };