#pragma once #include #include #include #include namespace DB { /** Allows you to open a dynamic library and get a pointer to a function from it. */ class SharedLibrary : private boost::noncopyable { public: explicit SharedLibrary(std::string_view path, int flags = RTLD_LAZY); ~SharedLibrary(); template Func get(std::string_view name) { return reinterpret_cast(getImpl(name)); } template Func tryGet(std::string_view name) { return reinterpret_cast(getImpl(name, true)); } private: void * getImpl(std::string_view name, bool no_throw = false); void * handle = nullptr; }; using SharedLibraryPtr = std::shared_ptr; }