// Copyright (c) 2021 Nicholas Corgan // SPDX-License-Identifier: BSL-1.0 #pragma once #include #include #include #include #include template struct ScopedPlugin { ScopedPlugin( const std::string& path, ValueType&& value ): path(path) { Pothos::PluginRegistry::add(path, std::forward(value)); } virtual ~ScopedPlugin() { POTHOS_EXCEPTION_TRY { Pothos::PluginRegistry::remove(path); } POTHOS_EXCEPTION_CATCH(const Pothos::Exception& ex) { std::cerr << ex.what() << std::endl; } } std::string path; };